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 | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Scott Baker | f3816ac | 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 | 55a2e29 | 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 | 08898c1 | 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 | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 17 | |
Scott Baker | 08898c1 | 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 | 08898c1 | 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 | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 27 | def get_REST_patterns(): |
| 28 | return patterns('', |
| 29 | url(r'^plstackapi/$', api_root), |
| 30 | |
| 31 | url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 32 | url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
| 33 | |
| 34 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 35 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
| 36 | |
| 37 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 38 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
| 39 | |
| 40 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 41 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
| 42 | |
| 43 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 44 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
| 45 | |
| 46 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 47 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
| 48 | |
| 49 | url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 50 | url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
| 51 | |
| 52 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 53 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
| 54 | |
| 55 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 56 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
| 57 | |
| 58 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 59 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
| 60 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 61 | url(r'plstackapi/controllernetworks/$', ControllerNetworksList.as_view(), name='controllernetworks-list'), |
| 62 | url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworksDetail.as_view(), name ='controllernetworks-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 63 | |
| 64 | url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 65 | url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
| 66 | |
| 67 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 68 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 69 | |
| 70 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 71 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 72 | |
| 73 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 74 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 75 | |
| 76 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 77 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 78 | |
| 79 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 80 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 81 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 82 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 83 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 84 | |
| 85 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 86 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 87 | |
| 88 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 89 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 90 | |
| 91 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 92 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 93 | |
| 94 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 95 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 96 | |
| 97 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 98 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 99 | |
| 100 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 101 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 102 | |
| 103 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 104 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 105 | |
| 106 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 107 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 108 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 109 | url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'), |
| 110 | url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 111 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 112 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 113 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 114 | |
| 115 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 116 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 117 | |
| 118 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 119 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 120 | |
| 121 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 122 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 123 | |
| 124 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 125 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 126 | |
| 127 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 128 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 129 | url(r'plstackapi/Controller/$', ControllerList.as_view(), name='controller-list'), |
| 130 | url(r'plstackapi/Controller/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 131 | |
| 132 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 133 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 134 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 135 | url(r'plstackapi/controllerslices/$', ControllerSlicesList.as_view(), name='controllerslices-list'), |
| 136 | url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicesDetail.as_view(), name ='controllerslices-detail'), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 137 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 138 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 139 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 140 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 141 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 142 | url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 143 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 144 | url(r'plstackapi/controllerusers/$', ControllerUsersList.as_view(), name='controllerusers-list'), |
| 145 | url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUsersDetail.as_view(), name ='controllerusers-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 146 | |
| 147 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 148 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 149 | |
| 150 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 151 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 152 | |
| 153 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 154 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 155 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 156 | url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'), |
| 157 | url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 158 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 159 | url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 160 | url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 161 | |
| 162 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 163 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 164 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 165 | url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'), |
| 166 | url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 167 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 168 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 169 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 170 | |
| 171 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 172 | url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'), |
| 173 | |
| 174 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 175 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 176 | |
| 177 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 178 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 179 | |
| 180 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 181 | |
| 182 | @api_view(['GET']) |
| 183 | def api_root(request, format=None): |
| 184 | return Response({ |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 185 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
| 186 | 'images': reverse('image-list', request=request, format=format), |
| 187 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 188 | 'sites': reverse('site-list', request=request, format=format), |
| 189 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 190 | 'tags': reverse('tag-list', request=request, format=format), |
| 191 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 192 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 193 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
| 194 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 195 | 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 196 | 'flavors': reverse('flavor-list', request=request, format=format), |
| 197 | 'projects': reverse('project-list', request=request, format=format), |
| 198 | 'slices': reverse('slice-list', request=request, format=format), |
| 199 | 'networks': reverse('network-list', request=request, format=format), |
| 200 | 'services': reverse('service-list', request=request, format=format), |
| 201 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 202 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 203 | 'charges': reverse('charge-list', request=request, format=format), |
| 204 | 'roles': reverse('role-list', request=request, format=format), |
| 205 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
| 206 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 207 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 208 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 209 | 'nodes': reverse('node-list', request=request, format=format), |
| 210 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 211 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 212 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
| 213 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 214 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
| 215 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 216 | 'users': reverse('user-list', request=request, format=format), |
| 217 | 'deployments': reverse('deployment-list', request=request, format=format), |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 218 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 219 | 'reservations': reverse('reservation-list', request=request, format=format), |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 220 | 'controllersliceses': reverse('controllerslices-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 221 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 222 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 223 | 'controlleruserses': reverse('controllerusers-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 224 | 'accounts': reverse('account-list', request=request, format=format), |
| 225 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 226 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 227 | 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format), |
| 228 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 229 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 230 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 231 | 'controllersiteses': reverse('controllersites-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 232 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
| 233 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
| 234 | 'routers': reverse('router-list', request=request, format=format), |
| 235 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
| 236 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 237 | }) |
| 238 | |
| 239 | # Based on serializers.py |
| 240 | |
| 241 | |
| 242 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 243 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 244 | id = serializers.Field() |
| 245 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 246 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 247 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 248 | def getHumanReadableName(self, obj):
|
| 249 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 250 | def getValidators(self, obj): |
| 251 | try: |
| 252 | return obj.getValidators() |
| 253 | except: |
| 254 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 255 | class Meta: |
| 256 | model = ServiceAttribute |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 257 | 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] | 258 | |
| 259 | class ServiceAttributeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 260 | id = serializers.Field() |
| 261 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 262 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 263 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 264 | def getHumanReadableName(self, obj):
|
| 265 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 266 | def getValidators(self, obj):
|
| 267 | try: |
| 268 | return obj.getValidators() |
| 269 | except: |
| 270 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 271 | class Meta: |
| 272 | model = ServiceAttribute |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 273 | 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] | 274 | |
| 275 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 276 | |
| 277 | |
| 278 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 279 | id = serializers.Field() |
| 280 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 281 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 282 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 283 | def getHumanReadableName(self, obj):
|
| 284 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 285 | def getValidators(self, obj): |
| 286 | try: |
| 287 | return obj.getValidators() |
| 288 | except: |
| 289 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 290 | class Meta: |
| 291 | model = Image |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 292 | 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] | 293 | |
| 294 | class ImageIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 295 | id = serializers.Field() |
| 296 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 297 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 298 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 299 | def getHumanReadableName(self, obj):
|
| 300 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 301 | def getValidators(self, obj):
|
| 302 | try: |
| 303 | return obj.getValidators() |
| 304 | except: |
| 305 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 306 | class Meta: |
| 307 | model = Image |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 308 | 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] | 309 | |
| 310 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 311 | |
| 312 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 313 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 314 | id = serializers.Field() |
| 315 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 316 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 317 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 318 | def getHumanReadableName(self, obj):
|
| 319 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 320 | def getValidators(self, obj): |
| 321 | try: |
| 322 | return obj.getValidators() |
| 323 | except: |
| 324 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 325 | class Meta: |
| 326 | model = NetworkParameter |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 327 | 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] | 328 | |
| 329 | class NetworkParameterIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 330 | id = serializers.Field() |
| 331 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 332 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 333 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 334 | def getHumanReadableName(self, obj):
|
| 335 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 336 | def getValidators(self, obj):
|
| 337 | try: |
| 338 | return obj.getValidators() |
| 339 | except: |
| 340 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 341 | class Meta: |
| 342 | model = NetworkParameter |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 343 | 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] | 344 | |
| 345 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 346 | |
| 347 | |
| 348 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 349 | id = serializers.Field() |
| 350 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 351 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 352 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 353 | def getHumanReadableName(self, obj):
|
| 354 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 355 | def getValidators(self, obj): |
| 356 | try: |
| 357 | return obj.getValidators() |
| 358 | except: |
| 359 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 360 | class Meta: |
| 361 | model = Site |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 362 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 363 | |
| 364 | class SiteIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 365 | id = serializers.Field() |
| 366 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 367 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 368 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 369 | def getHumanReadableName(self, obj):
|
| 370 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 371 | def getValidators(self, obj):
|
| 372 | try: |
| 373 | return obj.getValidators() |
| 374 | except: |
| 375 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 376 | class Meta: |
| 377 | model = Site |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 378 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 379 | |
| 380 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 381 | |
| 382 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 383 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 384 | id = serializers.Field() |
| 385 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 386 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 387 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 388 | def getHumanReadableName(self, obj):
|
| 389 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 390 | def getValidators(self, obj): |
| 391 | try: |
| 392 | return obj.getValidators() |
| 393 | except: |
| 394 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 395 | class Meta: |
| 396 | model = SliceRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 397 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 398 | |
| 399 | class SliceRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 400 | id = serializers.Field() |
| 401 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 402 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 403 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 404 | def getHumanReadableName(self, obj):
|
| 405 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 406 | def getValidators(self, obj):
|
| 407 | try: |
| 408 | return obj.getValidators() |
| 409 | except: |
| 410 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 411 | class Meta: |
| 412 | model = SliceRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 413 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 414 | |
| 415 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 416 | |
| 417 | |
| 418 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 419 | id = serializers.Field() |
| 420 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 421 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 422 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 423 | def getHumanReadableName(self, obj):
|
| 424 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 425 | def getValidators(self, obj): |
| 426 | try: |
| 427 | return obj.getValidators() |
| 428 | except: |
| 429 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 430 | class Meta: |
| 431 | model = Tag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 432 | 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] | 433 | |
| 434 | class TagIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 435 | id = serializers.Field() |
| 436 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 437 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 438 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 439 | def getHumanReadableName(self, obj):
|
| 440 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 441 | def getValidators(self, obj):
|
| 442 | try: |
| 443 | return obj.getValidators() |
| 444 | except: |
| 445 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 446 | class Meta: |
| 447 | model = Tag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 448 | 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] | 449 | |
| 450 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 451 | |
| 452 | |
| 453 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 454 | id = serializers.Field() |
| 455 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 456 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 457 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 458 | def getHumanReadableName(self, obj):
|
| 459 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 460 | def getValidators(self, obj): |
| 461 | try: |
| 462 | return obj.getValidators() |
| 463 | except: |
| 464 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 465 | class Meta: |
| 466 | model = Invoice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 467 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 468 | |
| 469 | class InvoiceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 470 | id = serializers.Field() |
| 471 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 472 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 473 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 474 | def getHumanReadableName(self, obj):
|
| 475 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 476 | def getValidators(self, obj):
|
| 477 | try: |
| 478 | return obj.getValidators() |
| 479 | except: |
| 480 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 481 | class Meta: |
| 482 | model = Invoice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 483 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 484 | |
| 485 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 486 | |
| 487 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 488 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 489 | id = serializers.Field() |
| 490 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 491 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 492 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 493 | def getHumanReadableName(self, obj):
|
| 494 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 495 | def getValidators(self, obj): |
| 496 | try: |
| 497 | return obj.getValidators() |
| 498 | except: |
| 499 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 500 | class Meta: |
| 501 | model = SlicePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 502 | 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] | 503 | |
| 504 | class SlicePrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 505 | id = serializers.Field() |
| 506 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 507 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 508 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 509 | def getHumanReadableName(self, obj):
|
| 510 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 511 | def getValidators(self, obj):
|
| 512 | try: |
| 513 | return obj.getValidators() |
| 514 | except: |
| 515 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 516 | class Meta: |
| 517 | model = SlicePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 518 | 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] | 519 | |
| 520 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 521 | |
| 522 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 523 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 524 | id = serializers.Field() |
| 525 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 526 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 527 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 528 | def getHumanReadableName(self, obj):
|
| 529 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 530 | def getValidators(self, obj): |
| 531 | try: |
| 532 | return obj.getValidators() |
| 533 | except: |
| 534 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 535 | class Meta: |
| 536 | model = PlanetStackRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 537 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 538 | |
| 539 | class PlanetStackRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 540 | id = serializers.Field() |
| 541 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 542 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 543 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 544 | def getHumanReadableName(self, obj):
|
| 545 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 546 | def getValidators(self, obj):
|
| 547 | try: |
| 548 | return obj.getValidators() |
| 549 | except: |
| 550 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 551 | class Meta: |
| 552 | model = PlanetStackRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 553 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 554 | |
| 555 | |
| 556 | |
| 557 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 558 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 559 | id = serializers.Field() |
| 560 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 561 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 562 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 563 | def getHumanReadableName(self, obj):
|
| 564 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 565 | def getValidators(self, obj): |
| 566 | try: |
| 567 | return obj.getValidators() |
| 568 | except: |
| 569 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 570 | class Meta: |
| 571 | model = NetworkSliver |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 572 | 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] | 573 | |
| 574 | class NetworkSliverIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 575 | id = serializers.Field() |
| 576 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 577 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 578 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 579 | def getHumanReadableName(self, obj):
|
| 580 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 581 | def getValidators(self, obj):
|
| 582 | try: |
| 583 | return obj.getValidators() |
| 584 | except: |
| 585 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 586 | class Meta: |
| 587 | model = NetworkSliver |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 588 | 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] | 589 | |
| 590 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 591 | |
| 592 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 593 | class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 594 | id = serializers.Field() |
| 595 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 596 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 597 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 598 | def getHumanReadableName(self, obj):
|
| 599 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 600 | def getValidators(self, obj): |
| 601 | try: |
| 602 | return obj.getValidators() |
| 603 | except: |
| 604 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 605 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 606 | model = ControllerNetworks |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 607 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 608 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 609 | class ControllerNetworksIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 610 | id = serializers.Field() |
| 611 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 612 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 613 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 614 | def getHumanReadableName(self, obj):
|
| 615 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 616 | def getValidators(self, obj):
|
| 617 | try: |
| 618 | return obj.getValidators() |
| 619 | except: |
| 620 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 621 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 622 | model = ControllerNetworks |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 623 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 624 | |
| 625 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 626 | |
| 627 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 628 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 629 | id = serializers.Field() |
| 630 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 631 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 632 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 633 | def getHumanReadableName(self, obj):
|
| 634 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 635 | def getValidators(self, obj): |
| 636 | try: |
| 637 | return obj.getValidators() |
| 638 | except: |
| 639 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 640 | class Meta: |
| 641 | model = Flavor |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 642 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 643 | |
| 644 | class FlavorIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 645 | id = serializers.Field() |
| 646 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 647 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 648 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 649 | def getHumanReadableName(self, obj):
|
| 650 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 651 | def getValidators(self, obj):
|
| 652 | try: |
| 653 | return obj.getValidators() |
| 654 | except: |
| 655 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 656 | class Meta: |
| 657 | model = Flavor |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 658 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 664 | id = serializers.Field() |
| 665 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 666 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 667 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 668 | def getHumanReadableName(self, obj):
|
| 669 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 670 | def getValidators(self, obj): |
| 671 | try: |
| 672 | return obj.getValidators() |
| 673 | except: |
| 674 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 675 | class Meta: |
| 676 | model = Project |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 677 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 678 | |
| 679 | class ProjectIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 680 | id = serializers.Field() |
| 681 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 682 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 683 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 684 | def getHumanReadableName(self, obj):
|
| 685 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 686 | def getValidators(self, obj):
|
| 687 | try: |
| 688 | return obj.getValidators() |
| 689 | except: |
| 690 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 691 | class Meta: |
| 692 | model = Project |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 693 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 694 | |
| 695 | |
| 696 | |
| 697 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 698 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 699 | id = serializers.Field() |
| 700 | |
| 701 | |
| 702 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 703 | |
| 704 | |
| 705 | |
| 706 | availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 707 | |
| 708 | |
| 709 | |
| 710 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 711 | |
| 712 | |
| 713 | |
| 714 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 715 | |
| 716 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 717 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 718 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 719 | def getHumanReadableName(self, obj):
|
| 720 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 721 | def getValidators(self, obj): |
| 722 | try: |
| 723 | return obj.getValidators() |
| 724 | except: |
| 725 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 726 | class Meta: |
| 727 | model = Slice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 728 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 729 | |
| 730 | class SliceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 731 | id = serializers.Field() |
| 732 | |
| 733 | |
| 734 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 735 | |
| 736 | |
| 737 | |
| 738 | availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 739 | |
| 740 | |
| 741 | |
| 742 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 743 | |
| 744 | |
| 745 | |
| 746 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 747 | |
| 748 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 749 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 750 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 751 | def getHumanReadableName(self, obj):
|
| 752 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 753 | def getValidators(self, obj):
|
| 754 | try: |
| 755 | return obj.getValidators() |
| 756 | except: |
| 757 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 758 | class Meta: |
| 759 | model = Slice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 760 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 761 | |
| 762 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 763 | |
| 764 | |
| 765 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 766 | id = serializers.Field() |
| 767 | |
| 768 | |
| 769 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 770 | |
| 771 | |
| 772 | |
| 773 | availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 774 | |
| 775 | |
| 776 | |
| 777 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 778 | |
| 779 | |
| 780 | |
| 781 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 782 | |
| 783 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 784 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 785 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 786 | def getHumanReadableName(self, obj):
|
| 787 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 788 | def getValidators(self, obj): |
| 789 | try: |
| 790 | return obj.getValidators() |
| 791 | except: |
| 792 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 793 | class Meta: |
| 794 | model = Network |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 795 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 796 | |
| 797 | class NetworkIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 798 | id = serializers.Field() |
| 799 | |
| 800 | |
| 801 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 802 | |
| 803 | |
| 804 | |
| 805 | availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 806 | |
| 807 | |
| 808 | |
| 809 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 810 | |
| 811 | |
| 812 | |
| 813 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 814 | |
| 815 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 816 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 817 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 818 | def getHumanReadableName(self, obj):
|
| 819 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 820 | def getValidators(self, obj):
|
| 821 | try: |
| 822 | return obj.getValidators() |
| 823 | except: |
| 824 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 825 | class Meta: |
| 826 | model = Network |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 827 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 828 | |
| 829 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 830 | |
| 831 | |
| 832 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 833 | id = serializers.Field() |
| 834 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 835 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 836 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 837 | def getHumanReadableName(self, obj):
|
| 838 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 839 | def getValidators(self, obj): |
| 840 | try: |
| 841 | return obj.getValidators() |
| 842 | except: |
| 843 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 844 | class Meta: |
| 845 | model = Service |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 846 | 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] | 847 | |
| 848 | class ServiceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 849 | id = serializers.Field() |
| 850 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 851 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 852 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 853 | def getHumanReadableName(self, obj):
|
| 854 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 855 | def getValidators(self, obj):
|
| 856 | try: |
| 857 | return obj.getValidators() |
| 858 | except: |
| 859 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 860 | class Meta: |
| 861 | model = Service |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 862 | 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] | 863 | |
| 864 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 865 | |
| 866 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 867 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 868 | id = serializers.Field() |
| 869 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 870 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 871 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 872 | def getHumanReadableName(self, obj):
|
| 873 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 874 | def getValidators(self, obj): |
| 875 | try: |
| 876 | return obj.getValidators() |
| 877 | except: |
| 878 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 879 | class Meta: |
| 880 | model = ServiceClass |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 881 | 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] | 882 | |
| 883 | class ServiceClassIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 884 | id = serializers.Field() |
| 885 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 886 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 887 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 888 | def getHumanReadableName(self, obj):
|
| 889 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 890 | def getValidators(self, obj):
|
| 891 | try: |
| 892 | return obj.getValidators() |
| 893 | except: |
| 894 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 895 | class Meta: |
| 896 | model = ServiceClass |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 897 | 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] | 898 | |
| 899 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 900 | |
| 901 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 902 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 903 | id = serializers.Field() |
| 904 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 905 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 906 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 907 | def getHumanReadableName(self, obj):
|
| 908 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 909 | def getValidators(self, obj): |
| 910 | try: |
| 911 | return obj.getValidators() |
| 912 | except: |
| 913 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 914 | class Meta: |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 915 | model = Payment |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 916 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 917 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 918 | class PaymentIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 919 | id = serializers.Field() |
| 920 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 921 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 922 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 923 | def getHumanReadableName(self, obj):
|
| 924 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 925 | def getValidators(self, obj):
|
| 926 | try: |
| 927 | return obj.getValidators() |
| 928 | except: |
| 929 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 930 | class Meta: |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 931 | model = Payment |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 932 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 933 | |
| 934 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 935 | |
| 936 | |
| 937 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 938 | id = serializers.Field() |
| 939 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 940 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 941 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 942 | def getHumanReadableName(self, obj):
|
| 943 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 944 | def getValidators(self, obj): |
| 945 | try: |
| 946 | return obj.getValidators() |
| 947 | except: |
| 948 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 949 | class Meta: |
| 950 | model = Charge |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 951 | 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] | 952 | |
| 953 | class ChargeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 954 | id = serializers.Field() |
| 955 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 956 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 957 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 958 | def getHumanReadableName(self, obj):
|
| 959 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 960 | def getValidators(self, obj):
|
| 961 | try: |
| 962 | return obj.getValidators() |
| 963 | except: |
| 964 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 965 | class Meta: |
| 966 | model = Charge |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 967 | 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] | 968 | |
| 969 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 970 | |
| 971 | |
| 972 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 973 | id = serializers.Field() |
| 974 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 975 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 976 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 977 | def getHumanReadableName(self, obj):
|
| 978 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 979 | def getValidators(self, obj): |
| 980 | try: |
| 981 | return obj.getValidators() |
| 982 | except: |
| 983 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 984 | class Meta: |
| 985 | model = Role |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 986 | 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] | 987 | |
| 988 | class RoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 989 | id = serializers.Field() |
| 990 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 991 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 992 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 993 | def getHumanReadableName(self, obj):
|
| 994 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 995 | def getValidators(self, obj):
|
| 996 | try: |
| 997 | return obj.getValidators() |
| 998 | except: |
| 999 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1000 | class Meta: |
| 1001 | model = Role |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1002 | 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] | 1003 | |
| 1004 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1005 | |
| 1006 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1007 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1008 | id = serializers.Field() |
| 1009 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1010 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1011 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1012 | def getHumanReadableName(self, obj):
|
| 1013 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1014 | def getValidators(self, obj): |
| 1015 | try: |
| 1016 | return obj.getValidators() |
| 1017 | except: |
| 1018 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1019 | class Meta: |
| 1020 | model = UsableObject |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1021 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1022 | |
| 1023 | class UsableObjectIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1024 | id = serializers.Field() |
| 1025 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1026 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1027 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1028 | def getHumanReadableName(self, obj):
|
| 1029 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1030 | def getValidators(self, obj):
|
| 1031 | try: |
| 1032 | return obj.getValidators() |
| 1033 | except: |
| 1034 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1035 | class Meta: |
| 1036 | model = UsableObject |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1037 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1038 | |
| 1039 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1040 | |
| 1041 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1042 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1043 | id = serializers.Field() |
| 1044 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1045 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1046 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1047 | def getHumanReadableName(self, obj):
|
| 1048 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1049 | def getValidators(self, obj): |
| 1050 | try: |
| 1051 | return obj.getValidators() |
| 1052 | except: |
| 1053 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1054 | class Meta: |
| 1055 | model = SiteRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1056 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1057 | |
| 1058 | class SiteRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1059 | id = serializers.Field() |
| 1060 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1061 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1062 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1063 | def getHumanReadableName(self, obj):
|
| 1064 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1065 | def getValidators(self, obj):
|
| 1066 | try: |
| 1067 | return obj.getValidators() |
| 1068 | except: |
| 1069 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1070 | class Meta: |
| 1071 | model = SiteRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1072 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1073 | |
| 1074 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1075 | |
| 1076 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1077 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1078 | id = serializers.Field() |
| 1079 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1080 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1081 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1082 | def getHumanReadableName(self, obj):
|
| 1083 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1084 | def getValidators(self, obj): |
| 1085 | try: |
| 1086 | return obj.getValidators() |
| 1087 | except: |
| 1088 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1089 | class Meta: |
| 1090 | model = SliceCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1091 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1092 | |
| 1093 | class SliceCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1094 | id = serializers.Field() |
| 1095 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1096 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1097 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1098 | def getHumanReadableName(self, obj):
|
| 1099 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1100 | def getValidators(self, obj):
|
| 1101 | try: |
| 1102 | return obj.getValidators() |
| 1103 | except: |
| 1104 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1105 | class Meta: |
| 1106 | model = SliceCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1107 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1108 | |
| 1109 | |
| 1110 | |
| 1111 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1112 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1113 | id = serializers.Field() |
| 1114 | |
| 1115 | |
| 1116 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1117 | |
| 1118 | |
| 1119 | |
| 1120 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1121 | |
| 1122 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1123 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1124 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1125 | def getHumanReadableName(self, obj):
|
| 1126 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1127 | def getValidators(self, obj): |
| 1128 | try: |
| 1129 | return obj.getValidators() |
| 1130 | except: |
| 1131 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1132 | class Meta: |
| 1133 | model = Sliver |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1134 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1135 | |
| 1136 | class SliverIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1137 | id = serializers.Field() |
| 1138 | |
| 1139 | |
| 1140 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1145 | |
| 1146 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1147 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1148 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1149 | def getHumanReadableName(self, obj):
|
| 1150 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1151 | def getValidators(self, obj):
|
| 1152 | try: |
| 1153 | return obj.getValidators() |
| 1154 | except: |
| 1155 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1156 | class Meta: |
| 1157 | model = Sliver |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1158 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1159 | |
| 1160 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1161 | |
| 1162 | |
| 1163 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1164 | id = serializers.Field() |
| 1165 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1166 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1167 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1168 | def getHumanReadableName(self, obj):
|
| 1169 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1170 | def getValidators(self, obj): |
| 1171 | try: |
| 1172 | return obj.getValidators() |
| 1173 | except: |
| 1174 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1175 | class Meta: |
| 1176 | model = Node |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1177 | 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] | 1178 | |
| 1179 | class NodeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1180 | id = serializers.Field() |
| 1181 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1182 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1183 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1184 | def getHumanReadableName(self, obj):
|
| 1185 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1186 | def getValidators(self, obj):
|
| 1187 | try: |
| 1188 | return obj.getValidators() |
| 1189 | except: |
| 1190 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1191 | class Meta: |
| 1192 | model = Node |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1193 | 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] | 1194 | |
| 1195 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1196 | |
| 1197 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1198 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1199 | id = serializers.Field() |
| 1200 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1201 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1202 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1203 | def getHumanReadableName(self, obj):
|
| 1204 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1205 | def getValidators(self, obj): |
| 1206 | try: |
| 1207 | return obj.getValidators() |
| 1208 | except: |
| 1209 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1210 | class Meta: |
| 1211 | model = DashboardView |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1212 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1213 | |
| 1214 | class DashboardViewIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1215 | id = serializers.Field() |
| 1216 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1217 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1218 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1219 | def getHumanReadableName(self, obj):
|
| 1220 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1221 | def getValidators(self, obj):
|
| 1222 | try: |
| 1223 | return obj.getValidators() |
| 1224 | except: |
| 1225 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1226 | class Meta: |
| 1227 | model = DashboardView |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1228 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1229 | |
| 1230 | |
| 1231 | |
| 1232 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1233 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1234 | id = serializers.Field() |
| 1235 | |
| 1236 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1237 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1238 | def getHumanReadableName(self, obj):
|
| 1239 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1240 | def getValidators(self, obj): |
| 1241 | try: |
| 1242 | return obj.getValidators() |
| 1243 | except: |
| 1244 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1245 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1246 | model = ControllerImages |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1247 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1248 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1249 | class ControllerImagesIdSerializer(serializers.ModelSerializer): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1250 | id = serializers.Field() |
| 1251 | |
| 1252 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1253 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1254 | def getHumanReadableName(self, obj):
|
| 1255 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1256 | def getValidators(self, obj):
|
| 1257 | try: |
| 1258 | return obj.getValidators() |
| 1259 | except: |
| 1260 | return None
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1261 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1262 | model = ControllerImages |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1263 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1264 | |
| 1265 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1266 | |
| 1267 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1268 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1269 | id = serializers.Field() |
| 1270 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1271 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1272 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1273 | def getHumanReadableName(self, obj):
|
| 1274 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1275 | def getValidators(self, obj): |
| 1276 | try: |
| 1277 | return obj.getValidators() |
| 1278 | except: |
| 1279 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1280 | class Meta: |
| 1281 | model = ReservedResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1282 | 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] | 1283 | |
| 1284 | class ReservedResourceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1285 | id = serializers.Field() |
| 1286 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1287 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1288 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1289 | def getHumanReadableName(self, obj):
|
| 1290 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1291 | def getValidators(self, obj):
|
| 1292 | try: |
| 1293 | return obj.getValidators() |
| 1294 | except: |
| 1295 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1296 | class Meta: |
| 1297 | model = ReservedResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1298 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1299 | |
| 1300 | |
| 1301 | |
| 1302 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1303 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1304 | id = serializers.Field() |
| 1305 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1306 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1307 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1308 | def getHumanReadableName(self, obj):
|
| 1309 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1310 | def getValidators(self, obj): |
| 1311 | try: |
| 1312 | return obj.getValidators() |
| 1313 | except: |
| 1314 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1315 | class Meta: |
| 1316 | model = NetworkSlice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1317 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1318 | |
| 1319 | class NetworkSliceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1320 | id = serializers.Field() |
| 1321 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1322 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1323 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1324 | def getHumanReadableName(self, obj):
|
| 1325 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1326 | def getValidators(self, obj):
|
| 1327 | try: |
| 1328 | return obj.getValidators() |
| 1329 | except: |
| 1330 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1331 | class Meta: |
| 1332 | model = NetworkSlice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1333 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1334 | |
| 1335 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1336 | |
| 1337 | |
| 1338 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1339 | id = serializers.Field() |
| 1340 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1341 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1342 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1343 | def getHumanReadableName(self, obj):
|
| 1344 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1345 | def getValidators(self, obj): |
| 1346 | try: |
| 1347 | return obj.getValidators() |
| 1348 | except: |
| 1349 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1350 | class Meta: |
| 1351 | model = UserDashboardView |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1352 | 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] | 1353 | |
| 1354 | class UserDashboardViewIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1355 | id = serializers.Field() |
| 1356 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1357 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1358 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1359 | def getHumanReadableName(self, obj):
|
| 1360 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1361 | def getValidators(self, obj):
|
| 1362 | try: |
| 1363 | return obj.getValidators() |
| 1364 | except: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1365 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1366 | class Meta: |
| 1367 | model = UserDashboardView |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1368 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1369 | |
| 1370 | |
| 1371 | |
| 1372 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1373 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1374 | id = serializers.Field() |
| 1375 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1376 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1377 | validators = serializers.SerializerMethodField("getValidators") |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1378 | def getHumanReadableName(self, obj): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1379 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1380 | def getValidators(self, obj): |
| 1381 | try: |
| 1382 | return obj.getValidators() |
| 1383 | except: |
| 1384 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1385 | class Meta: |
| 1386 | model = PlanetStackPrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1387 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1388 | |
| 1389 | class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1390 | id = serializers.Field() |
| 1391 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1392 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1393 | validators = serializers.SerializerMethodField("getValidators") |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1394 | def getHumanReadableName(self, obj): |
| 1395 | return str(obj) |
| 1396 | def getValidators(self, obj): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1397 | try: |
| 1398 | return obj.getValidators() |
| 1399 | except: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1400 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1401 | class Meta: |
| 1402 | model = PlanetStackPrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1403 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1404 | |
| 1405 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1406 | |
| 1407 | |
| 1408 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1409 | id = serializers.Field() |
| 1410 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1411 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1412 | validators = serializers.SerializerMethodField("getValidators") |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1413 | def getHumanReadableName(self, obj): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1414 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1415 | def getValidators(self, obj): |
| 1416 | try: |
| 1417 | return obj.getValidators() |
| 1418 | except: |
| 1419 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1420 | class Meta: |
| 1421 | model = User |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1422 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1423 | |
| 1424 | class UserIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1425 | id = serializers.Field() |
| 1426 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1427 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1428 | validators = serializers.SerializerMethodField("getValidators") |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1429 | def getHumanReadableName(self, obj): |
| 1430 | return str(obj) |
| 1431 | def getValidators(self, obj): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1432 | try: |
| 1433 | return obj.getValidators() |
| 1434 | except: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1435 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1436 | class Meta: |
| 1437 | model = User |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1438 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1439 | |
| 1440 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1441 | |
| 1442 | |
| 1443 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1444 | id = serializers.Field() |
| 1445 | |
| 1446 | |
| 1447 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1448 | |
| 1449 | |
| 1450 | |
| 1451 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1452 | |
| 1453 | |
| 1454 | |
| 1455 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1456 | |
| 1457 | |
| 1458 | |
| 1459 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1460 | |
| 1461 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1462 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1463 | validators = serializers.SerializerMethodField("getValidators") |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1464 | def getHumanReadableName(self, obj): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1465 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1466 | def getValidators(self, obj): |
| 1467 | try: |
| 1468 | return obj.getValidators() |
| 1469 | except: |
| 1470 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1471 | class Meta: |
| 1472 | model = Deployment |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1473 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','sites','sites','flavors','flavors',) |
| 1474 | |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1475 | class DeploymentIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1476 | id = serializers.Field() |
| 1477 | |
| 1478 | |
| 1479 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1480 | |
| 1481 | |
| 1482 | |
| 1483 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1484 | |
| 1485 | |
| 1486 | |
| 1487 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1488 | |
| 1489 | |
| 1490 | |
| 1491 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1492 | |
| 1493 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1494 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1495 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1496 | def getHumanReadableName(self, obj):
|
| 1497 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1498 | def getValidators(self, obj):
|
| 1499 | try: |
| 1500 | return obj.getValidators() |
| 1501 | except: |
| 1502 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1503 | class Meta: |
| 1504 | model = Deployment |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1505 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1506 | |
| 1507 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1508 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
| 1509 | id = serializers.Field() |
| 1510 | site_deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sitedeployment-detail') |
| 1511 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1512 | validators = serializers.SerializerMethodField("getValidators") |
| 1513 | def getHumanReadableName(self, obj): |
| 1514 | return str(obj) |
| 1515 | def getValidators(self, obj): |
| 1516 | try: |
| 1517 | return obj.getValidators() |
| 1518 | except: |
| 1519 | return None |
| 1520 | class Meta: |
| 1521 | model = Controller |
| 1522 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','admin_user','admin_password','admin_tenant','auth_url','backend_type') |
| 1523 | |
| 1524 | |
| 1525 | class ControllerIdSerializer(serializers.ModelSerializer): |
| 1526 | id = serializers.Field() |
Tony Mack | 528d422 | 2014-12-05 17:13:08 -0500 | [diff] [blame] | 1527 | site_deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sitedeployment-detail') |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1528 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1529 | validators = serializers.SerializerMethodField("getValidators") |
| 1530 | def getHumanReadableName(self, obj): |
| 1531 | return str(obj) |
| 1532 | def getValidators(self, obj): |
| 1533 | try: |
| 1534 | return obj.getValidators() |
| 1535 | except: |
| 1536 | return None |
| 1537 | class Meta: |
| 1538 | model = Controller |
| 1539 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','admin_user','admin_password','admin_tenant','auth_url','backend_type') |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1540 | |
| 1541 | |
| 1542 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1543 | id = serializers.Field() |
| 1544 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1545 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1546 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1547 | def getHumanReadableName(self, obj):
|
| 1548 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1549 | def getValidators(self, obj): |
| 1550 | try: |
| 1551 | return obj.getValidators() |
| 1552 | except: |
| 1553 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1554 | class Meta: |
| 1555 | model = Reservation |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1556 | 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] | 1557 | |
| 1558 | class ReservationIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1559 | id = serializers.Field() |
| 1560 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1561 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1562 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1563 | def getHumanReadableName(self, obj):
|
| 1564 | return str(obj)
|
Scott Baker | 351148c | 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 | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1570 | class Meta: |
| 1571 | model = Reservation |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1572 | 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] | 1573 | |
| 1574 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1575 | |
| 1576 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1577 | class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1578 | id = serializers.Field() |
| 1579 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1580 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1581 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1582 | def getHumanReadableName(self, obj):
|
| 1583 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1584 | def getValidators(self, obj): |
| 1585 | try: |
| 1586 | return obj.getValidators() |
| 1587 | except: |
| 1588 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1589 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1590 | model = ControllerSlices |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1591 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1592 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1593 | class ControllerSlicesIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1594 | id = serializers.Field() |
| 1595 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1596 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1597 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1598 | def getHumanReadableName(self, obj):
|
| 1599 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1600 | def getValidators(self, obj):
|
| 1601 | try: |
| 1602 | return obj.getValidators() |
| 1603 | except: |
| 1604 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1605 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1606 | model = ControllerSlices |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1607 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1608 | |
| 1609 | |
| 1610 | |
| 1611 | |
| 1612 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 1613 | id = serializers.Field() |
| 1614 | |
| 1615 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1616 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1617 | def getHumanReadableName(self, obj):
|
| 1618 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1619 | def getValidators(self, obj): |
| 1620 | try: |
| 1621 | return obj.getValidators() |
| 1622 | except: |
| 1623 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1624 | class Meta: |
| 1625 | model = SitePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1626 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1627 | |
| 1628 | class SitePrivilegeIdSerializer(serializers.ModelSerializer): |
| 1629 | id = serializers.Field() |
| 1630 | |
| 1631 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1632 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1633 | def getHumanReadableName(self, obj):
|
| 1634 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1635 | def getValidators(self, obj):
|
| 1636 | try: |
| 1637 | return obj.getValidators() |
| 1638 | except: |
| 1639 | return None
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1640 | class Meta: |
| 1641 | model = SitePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1642 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1643 | |
| 1644 | |
| 1645 | |
| 1646 | |
| 1647 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
| 1648 | id = serializers.Field() |
| 1649 | |
| 1650 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1651 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1652 | def getHumanReadableName(self, obj):
|
| 1653 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1654 | def getValidators(self, obj): |
| 1655 | try: |
| 1656 | return obj.getValidators() |
| 1657 | except: |
| 1658 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1659 | class Meta: |
| 1660 | model = PlanetStack |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1661 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1662 | |
| 1663 | class PlanetStackIdSerializer(serializers.ModelSerializer): |
| 1664 | id = serializers.Field() |
| 1665 | |
| 1666 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1667 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1668 | def getHumanReadableName(self, obj):
|
| 1669 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1670 | def getValidators(self, obj):
|
| 1671 | try: |
| 1672 | return obj.getValidators() |
| 1673 | except: |
| 1674 | return None
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1675 | class Meta: |
| 1676 | model = PlanetStack |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1677 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1678 | |
| 1679 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1680 | |
| 1681 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1682 | class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1683 | id = serializers.Field() |
| 1684 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1685 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1686 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1687 | def getHumanReadableName(self, obj):
|
| 1688 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1689 | def getValidators(self, obj): |
| 1690 | try: |
| 1691 | return obj.getValidators() |
| 1692 | except: |
| 1693 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1694 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1695 | model = ControllerUsers |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1696 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1697 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1698 | class ControllerUsersIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1699 | id = serializers.Field() |
| 1700 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1701 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1702 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1703 | def getHumanReadableName(self, obj):
|
| 1704 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1705 | def getValidators(self, obj):
|
| 1706 | try: |
| 1707 | return obj.getValidators() |
| 1708 | except: |
| 1709 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1710 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1711 | model = ControllerUsers |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1712 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1713 | |
| 1714 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1715 | |
| 1716 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1717 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1718 | id = serializers.Field() |
| 1719 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1720 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1721 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1722 | def getHumanReadableName(self, obj):
|
| 1723 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1724 | def getValidators(self, obj): |
| 1725 | try: |
| 1726 | return obj.getValidators() |
| 1727 | except: |
| 1728 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1729 | class Meta: |
| 1730 | model = Account |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1731 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1732 | |
| 1733 | class AccountIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1734 | id = serializers.Field() |
| 1735 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1736 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1737 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1738 | def getHumanReadableName(self, obj):
|
| 1739 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1740 | def getValidators(self, obj):
|
| 1741 | try: |
| 1742 | return obj.getValidators() |
| 1743 | except: |
| 1744 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1745 | class Meta: |
| 1746 | model = Account |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1747 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1748 | |
| 1749 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1750 | |
| 1751 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1752 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1753 | id = serializers.Field() |
| 1754 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1755 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1756 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1757 | def getHumanReadableName(self, obj):
|
| 1758 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1759 | def getValidators(self, obj): |
| 1760 | try: |
| 1761 | return obj.getValidators() |
| 1762 | except: |
| 1763 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1764 | class Meta: |
| 1765 | model = NetworkParameterType |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1766 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1767 | |
| 1768 | class NetworkParameterTypeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1769 | id = serializers.Field() |
| 1770 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1771 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1772 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1773 | def getHumanReadableName(self, obj):
|
| 1774 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1775 | def getValidators(self, obj):
|
| 1776 | try: |
| 1777 | return obj.getValidators() |
| 1778 | except: |
| 1779 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1780 | class Meta: |
| 1781 | model = NetworkParameterType |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1782 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1783 | |
| 1784 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1785 | |
| 1786 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1787 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1788 | id = serializers.Field() |
| 1789 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1790 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1791 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1792 | def getHumanReadableName(self, obj):
|
| 1793 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1794 | def getValidators(self, obj): |
| 1795 | try: |
| 1796 | return obj.getValidators() |
| 1797 | except: |
| 1798 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1799 | class Meta: |
| 1800 | model = SiteCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1801 | 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] | 1802 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1803 | class SiteCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1804 | id = serializers.Field() |
| 1805 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1806 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1807 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1808 | def getHumanReadableName(self, obj):
|
| 1809 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1810 | def getValidators(self, obj):
|
| 1811 | try: |
| 1812 | return obj.getValidators() |
| 1813 | except: |
| 1814 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1815 | class Meta: |
| 1816 | model = SiteCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1817 | 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] | 1818 | |
| 1819 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1820 | |
| 1821 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1822 | class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1823 | id = serializers.Field() |
| 1824 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1825 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1826 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1827 | def getHumanReadableName(self, obj):
|
| 1828 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1829 | def getValidators(self, obj): |
| 1830 | try: |
| 1831 | return obj.getValidators() |
| 1832 | except: |
| 1833 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1834 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1835 | model = ControllerPrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1836 | 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] | 1837 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1838 | class ControllerPrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1839 | id = serializers.Field() |
| 1840 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1841 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1842 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1843 | def getHumanReadableName(self, obj):
|
| 1844 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1845 | def getValidators(self, obj):
|
| 1846 | try: |
| 1847 | return obj.getValidators() |
| 1848 | except: |
| 1849 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1850 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1851 | model = ControllerPrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1852 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1853 | |
| 1854 | |
| 1855 | |
| 1856 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1857 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1858 | id = serializers.Field() |
| 1859 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1860 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1861 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1862 | def getHumanReadableName(self, obj):
|
| 1863 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1864 | def getValidators(self, obj): |
| 1865 | try: |
| 1866 | return obj.getValidators() |
| 1867 | except: |
| 1868 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1869 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1870 | model = ControllerRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1871 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1872 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1873 | class ControllerRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1874 | id = serializers.Field() |
| 1875 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1876 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1877 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1878 | def getHumanReadableName(self, obj):
|
| 1879 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1880 | def getValidators(self, obj):
|
| 1881 | try: |
| 1882 | return obj.getValidators() |
| 1883 | except: |
| 1884 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1885 | class Meta: |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1886 | model = ControllerRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1887 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1888 | |
| 1889 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1890 | |
| 1891 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1892 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1893 | id = serializers.Field() |
| 1894 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1895 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1896 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1897 | def getHumanReadableName(self, obj):
|
| 1898 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1899 | def getValidators(self, obj): |
| 1900 | try: |
| 1901 | return obj.getValidators() |
| 1902 | except: |
| 1903 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1904 | class Meta: |
| 1905 | model = UserCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1906 | 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] | 1907 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1908 | class UserCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1909 | id = serializers.Field() |
| 1910 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1911 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1912 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1913 | def getHumanReadableName(self, obj):
|
| 1914 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1915 | def getValidators(self, obj):
|
| 1916 | try: |
| 1917 | return obj.getValidators() |
| 1918 | except: |
| 1919 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1920 | class Meta: |
| 1921 | model = UserCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1922 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1923 | |
| 1924 | |
| 1925 | |
| 1926 | |
| 1927 | class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 1928 | id = serializers.Field() |
| 1929 | |
| 1930 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1931 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1932 | def getHumanReadableName(self, obj):
|
| 1933 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1934 | def getValidators(self, obj): |
| 1935 | try: |
| 1936 | return obj.getValidators() |
| 1937 | except: |
| 1938 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1939 | class Meta: |
| 1940 | model = SiteDeployments |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1941 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1942 | |
| 1943 | class SiteDeploymentsIdSerializer(serializers.ModelSerializer): |
| 1944 | id = serializers.Field() |
| 1945 | |
| 1946 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1947 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1948 | def getHumanReadableName(self, obj):
|
| 1949 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1950 | def getValidators(self, obj):
|
| 1951 | try: |
| 1952 | return obj.getValidators() |
| 1953 | except: |
| 1954 | return None
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1955 | class Meta: |
| 1956 | model = SiteDeployments |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1957 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment') |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1958 | |
| 1959 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1960 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1961 | id = serializers.Field() |
| 1962 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1963 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1964 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1965 | def getHumanReadableName(self, obj):
|
| 1966 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1967 | def getValidators(self, obj): |
| 1968 | try: |
| 1969 | return obj.getValidators() |
| 1970 | except: |
| 1971 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1972 | class Meta: |
| 1973 | model = SliceTag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1974 | 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] | 1975 | |
| 1976 | class SliceTagIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1977 | id = serializers.Field() |
| 1978 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1979 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1980 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1981 | def getHumanReadableName(self, obj):
|
| 1982 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1983 | def getValidators(self, obj):
|
| 1984 | try: |
| 1985 | return obj.getValidators() |
| 1986 | except: |
| 1987 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1988 | class Meta: |
| 1989 | model = SliceTag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1990 | 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] | 1991 | |
| 1992 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1993 | |
| 1994 | |
| 1995 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1996 | id = serializers.Field() |
| 1997 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1998 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1999 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2000 | def getHumanReadableName(self, obj):
|
| 2001 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2002 | def getValidators(self, obj): |
| 2003 | try: |
| 2004 | return obj.getValidators() |
| 2005 | except: |
| 2006 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2007 | class Meta: |
| 2008 | model = NetworkTemplate |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2009 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2010 | |
| 2011 | class NetworkTemplateIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2012 | id = serializers.Field() |
| 2013 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2014 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2015 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2016 | def getHumanReadableName(self, obj):
|
| 2017 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2018 | def getValidators(self, obj):
|
| 2019 | try: |
| 2020 | return obj.getValidators() |
| 2021 | except: |
| 2022 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2023 | class Meta: |
| 2024 | model = NetworkTemplate |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2025 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2026 | |
| 2027 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2028 | |
| 2029 | |
| 2030 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2031 | id = serializers.Field() |
| 2032 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2033 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2034 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2035 | def getHumanReadableName(self, obj):
|
| 2036 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2037 | def getValidators(self, obj): |
| 2038 | try: |
| 2039 | return obj.getValidators() |
| 2040 | except: |
| 2041 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2042 | class Meta: |
| 2043 | model = Router |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2044 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2045 | |
| 2046 | class RouterIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2047 | id = serializers.Field() |
| 2048 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2049 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2050 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2051 | def getHumanReadableName(self, obj):
|
| 2052 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2053 | def getValidators(self, obj):
|
| 2054 | try: |
| 2055 | return obj.getValidators() |
| 2056 | except: |
| 2057 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2058 | class Meta: |
| 2059 | model = Router |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2060 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2061 | |
| 2062 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2063 | |
| 2064 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2065 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2066 | id = serializers.Field() |
| 2067 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2068 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2069 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2070 | def getHumanReadableName(self, obj):
|
| 2071 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2072 | def getValidators(self, obj): |
| 2073 | try: |
| 2074 | return obj.getValidators() |
| 2075 | except: |
| 2076 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2077 | class Meta: |
| 2078 | model = ServiceResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2079 | 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] | 2080 | |
| 2081 | class ServiceResourceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2082 | id = serializers.Field() |
| 2083 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2084 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2085 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2086 | def getHumanReadableName(self, obj):
|
| 2087 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2088 | def getValidators(self, obj):
|
| 2089 | try: |
| 2090 | return obj.getValidators() |
| 2091 | except: |
| 2092 | return None
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2093 | class Meta: |
| 2094 | model = ServiceResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2095 | 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] | 2096 | |
| 2097 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2098 | |
| 2099 | |
| 2100 | serializerLookUp = { |
| 2101 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2102 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2103 | |
| 2104 | Image: ImageSerializer, |
| 2105 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2106 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2107 | |
| 2108 | Site: SiteSerializer, |
| 2109 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2110 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2111 | |
| 2112 | Tag: TagSerializer, |
| 2113 | |
| 2114 | Invoice: InvoiceSerializer, |
| 2115 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2116 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2117 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2118 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2119 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2120 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2121 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2122 | ControllerNetworks: ControllerNetworksSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2123 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2124 | Flavor: FlavorSerializer, |
| 2125 | |
| 2126 | Project: ProjectSerializer, |
| 2127 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2128 | Slice: SliceSerializer, |
| 2129 | |
| 2130 | Network: NetworkSerializer, |
| 2131 | |
| 2132 | Service: ServiceSerializer, |
| 2133 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2134 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2135 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2136 | Payment: PaymentSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2137 | |
| 2138 | Charge: ChargeSerializer, |
| 2139 | |
| 2140 | Role: RoleSerializer, |
| 2141 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2142 | UsableObject: UsableObjectSerializer, |
| 2143 | |
| 2144 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2145 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2146 | SliceCredential: SliceCredentialSerializer, |
| 2147 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2148 | Sliver: SliverSerializer, |
| 2149 | |
| 2150 | Node: NodeSerializer, |
| 2151 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2152 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2153 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2154 | ControllerImages: ControllerImagesSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2155 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2156 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2157 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2158 | NetworkSlice: NetworkSliceSerializer, |
| 2159 | |
| 2160 | UserDashboardView: UserDashboardViewSerializer, |
| 2161 | |
| 2162 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2163 | |
| 2164 | User: UserSerializer, |
| 2165 | |
| 2166 | Deployment: DeploymentSerializer, |
| 2167 | |
| 2168 | Reservation: ReservationSerializer, |
| 2169 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2170 | ControllerSlices: ControllerSlicesSerializer, |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2171 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2172 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2173 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2174 | PlanetStack: PlanetStackSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2175 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2176 | ControllerUsers: ControllerUsersSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2177 | |
| 2178 | Account: AccountSerializer, |
| 2179 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2180 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2181 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2182 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2183 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2184 | ControllerPrivilege: ControllerPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2185 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2186 | ControllerRole: ControllerRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2187 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2188 | UserCredential: UserCredentialSerializer, |
| 2189 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2190 | SiteDeployments: SiteDeploymentsSerializer, |
| 2191 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2192 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2193 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2194 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2195 | |
| 2196 | Router: RouterSerializer, |
| 2197 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2198 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2199 | |
| 2200 | None: None, |
| 2201 | } |
| 2202 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2203 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2204 | |
| 2205 | # To handle fine-grained field permissions, we have to check can_update |
| 2206 | # the object has been updated but before it has been saved. |
| 2207 | |
| 2208 | def update(self, request, *args, **kwargs):
|
| 2209 | partial = kwargs.pop('partial', False)
|
| 2210 | self.object = self.get_object_or_none()
|
| 2211 |
|
| 2212 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2213 | files=request.FILES, partial=partial)
|
| 2214 |
|
| 2215 | if not serializer.is_valid():
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2216 | response = {"error": "validation",
|
| 2217 | "specific_error": "not serializer.is_valid()",
|
| 2218 | "reasons": serializer.errors}
|
| 2219 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2220 |
|
| 2221 | try:
|
| 2222 | self.pre_save(serializer.object)
|
| 2223 | except ValidationError as err:
|
| 2224 | # full_clean on model instance may be called in pre_save,
|
| 2225 | # so we have to handle eventual errors.
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2226 | response = {"error": "validation",
|
| 2227 | "specific_error": "ValidationError in pre_save",
|
| 2228 | "reasons": err.message_dict}
|
| 2229 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2230 |
|
| 2231 | if serializer.object is not None:
|
| 2232 | if not serializer.object.can_update(request.user):
|
| 2233 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2234 |
|
| 2235 | if self.object is None:
|
| 2236 | self.object = serializer.save(force_insert=True)
|
| 2237 | self.post_save(self.object, created=True)
|
| 2238 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2239 |
|
| 2240 | self.object = serializer.save(force_update=True)
|
| 2241 | self.post_save(self.object, created=False)
|
| 2242 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2243 | |
| 2244 | def destroy(self, request, *args, **kwargs): |
| 2245 | obj = self.get_object() |
| 2246 | if obj.can_update(request.user): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2247 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2248 | else: |
| 2249 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2250 | |
| 2251 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2252 | # Based on core/views/*.py |
| 2253 | |
| 2254 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2255 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 2256 | queryset = ServiceAttribute.objects.select_related().all() |
| 2257 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2258 | id_serializer_class = ServiceAttributeIdSerializer |
| 2259 | filter_backends = (filters.DjangoFilterBackend,) |
| 2260 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 2261 | |
| 2262 | def get_serializer_class(self): |
| 2263 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2264 | if (no_hyperlinks): |
| 2265 | return self.id_serializer_class |
| 2266 | else: |
| 2267 | return self.serializer_class |
| 2268 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2269 | def get_queryset(self): |
| 2270 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2271 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2272 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2273 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2274 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2275 | response = {"error": "validation", |
| 2276 | "specific_error": "not serializer.is_valid()",
|
| 2277 | "reasons": serializer.errors}
|
| 2278 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2279 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2280 | obj.caller = request.user |
| 2281 | if obj.can_update(request.user): |
| 2282 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2283 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2284 | raise Exception("failed obj.can_update") |
| 2285 | |
| 2286 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2287 | if (ret.status_code%100 != 200): |
| 2288 | raise Exception(ret.data) |
| 2289 | |
| 2290 | return ret |
| 2291 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2292 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2293 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2294 | queryset = ServiceAttribute.objects.select_related().all() |
| 2295 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2296 | id_serializer_class = ServiceAttributeIdSerializer |
| 2297 | |
| 2298 | def get_serializer_class(self): |
| 2299 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2300 | if (no_hyperlinks): |
| 2301 | return self.id_serializer_class |
| 2302 | else: |
| 2303 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2304 | |
| 2305 | def get_queryset(self): |
| 2306 | return ServiceAttribute.select_by_user(self.request.user) |
| 2307 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2308 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2309 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2310 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2311 | |
| 2312 | |
| 2313 | |
| 2314 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2315 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2316 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2317 | id_serializer_class = ImageIdSerializer |
| 2318 | filter_backends = (filters.DjangoFilterBackend,) |
| 2319 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
| 2320 | |
| 2321 | def get_serializer_class(self): |
| 2322 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2323 | if (no_hyperlinks): |
| 2324 | return self.id_serializer_class |
| 2325 | else: |
| 2326 | return self.serializer_class |
| 2327 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2328 | def get_queryset(self): |
| 2329 | return Image.select_by_user(self.request.user) |
| 2330 | |
| 2331 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2332 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2333 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2334 | response = {"error": "validation", |
| 2335 | "specific_error": "not serializer.is_valid()",
|
| 2336 | "reasons": serializer.errors}
|
| 2337 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2338 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2339 | obj.caller = request.user |
| 2340 | if obj.can_update(request.user): |
| 2341 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2342 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2343 | raise Exception("failed obj.can_update") |
| 2344 | |
| 2345 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2346 | if (ret.status_code%100 != 200): |
| 2347 | raise Exception(ret.data) |
| 2348 | |
| 2349 | return ret |
| 2350 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2351 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2352 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2353 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2354 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2355 | id_serializer_class = ImageIdSerializer |
| 2356 | |
| 2357 | def get_serializer_class(self): |
| 2358 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2359 | if (no_hyperlinks): |
| 2360 | return self.id_serializer_class |
| 2361 | else: |
| 2362 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2363 | |
| 2364 | def get_queryset(self): |
| 2365 | return Image.select_by_user(self.request.user) |
| 2366 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2367 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2368 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2369 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2370 | |
| 2371 | |
| 2372 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2373 | class NetworkParameterList(generics.ListCreateAPIView): |
| 2374 | queryset = NetworkParameter.objects.select_related().all() |
| 2375 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2376 | id_serializer_class = NetworkParameterIdSerializer |
| 2377 | filter_backends = (filters.DjangoFilterBackend,) |
| 2378 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 2379 | |
| 2380 | def get_serializer_class(self): |
| 2381 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2382 | if (no_hyperlinks): |
| 2383 | return self.id_serializer_class |
| 2384 | else: |
| 2385 | return self.serializer_class |
| 2386 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2387 | def get_queryset(self): |
| 2388 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2389 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2390 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2391 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2392 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2393 | response = {"error": "validation", |
| 2394 | "specific_error": "not serializer.is_valid()",
|
| 2395 | "reasons": serializer.errors}
|
| 2396 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2397 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2398 | obj.caller = request.user |
| 2399 | if obj.can_update(request.user): |
| 2400 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2401 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2402 | raise Exception("failed obj.can_update") |
| 2403 | |
| 2404 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2405 | if (ret.status_code%100 != 200): |
| 2406 | raise Exception(ret.data) |
| 2407 | |
| 2408 | return ret |
| 2409 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2410 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2411 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2412 | queryset = NetworkParameter.objects.select_related().all() |
| 2413 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2414 | id_serializer_class = NetworkParameterIdSerializer |
| 2415 | |
| 2416 | def get_serializer_class(self): |
| 2417 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2418 | if (no_hyperlinks): |
| 2419 | return self.id_serializer_class |
| 2420 | else: |
| 2421 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2422 | |
| 2423 | def get_queryset(self): |
| 2424 | return NetworkParameter.select_by_user(self.request.user) |
| 2425 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2426 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2427 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2428 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2429 | |
| 2430 | |
| 2431 | |
| 2432 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2433 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2434 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2435 | id_serializer_class = SiteIdSerializer |
| 2436 | filter_backends = (filters.DjangoFilterBackend,) |
| 2437 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
| 2438 | |
| 2439 | def get_serializer_class(self): |
| 2440 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2441 | if (no_hyperlinks): |
| 2442 | return self.id_serializer_class |
| 2443 | else: |
| 2444 | return self.serializer_class |
| 2445 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2446 | def get_queryset(self): |
| 2447 | return Site.select_by_user(self.request.user) |
| 2448 | |
| 2449 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2450 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2451 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2452 | response = {"error": "validation", |
| 2453 | "specific_error": "not serializer.is_valid()",
|
| 2454 | "reasons": serializer.errors}
|
| 2455 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2456 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2457 | obj.caller = request.user |
| 2458 | if obj.can_update(request.user): |
| 2459 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2460 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2461 | raise Exception("failed obj.can_update") |
| 2462 | |
| 2463 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2464 | if (ret.status_code%100 != 200): |
| 2465 | raise Exception(ret.data) |
| 2466 | |
| 2467 | return ret |
| 2468 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2469 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2470 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2471 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2472 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2473 | id_serializer_class = SiteIdSerializer |
| 2474 | |
| 2475 | def get_serializer_class(self): |
| 2476 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2477 | if (no_hyperlinks): |
| 2478 | return self.id_serializer_class |
| 2479 | else: |
| 2480 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2481 | |
| 2482 | def get_queryset(self): |
| 2483 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2484 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2485 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2486 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2487 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2488 | |
| 2489 | |
| 2490 | |
| 2491 | class SliceRoleList(generics.ListCreateAPIView): |
| 2492 | queryset = SliceRole.objects.select_related().all() |
| 2493 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2494 | id_serializer_class = SliceRoleIdSerializer |
| 2495 | filter_backends = (filters.DjangoFilterBackend,) |
| 2496 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2497 | |
| 2498 | def get_serializer_class(self): |
| 2499 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2500 | if (no_hyperlinks): |
| 2501 | return self.id_serializer_class |
| 2502 | else: |
| 2503 | return self.serializer_class |
| 2504 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2505 | def get_queryset(self): |
| 2506 | return SliceRole.select_by_user(self.request.user) |
| 2507 | |
| 2508 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2509 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2510 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2511 | response = {"error": "validation", |
| 2512 | "specific_error": "not serializer.is_valid()",
|
| 2513 | "reasons": serializer.errors}
|
| 2514 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2515 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2516 | obj.caller = request.user |
| 2517 | if obj.can_update(request.user): |
| 2518 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2519 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2520 | raise Exception("failed obj.can_update") |
| 2521 | |
| 2522 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2523 | if (ret.status_code%100 != 200): |
| 2524 | raise Exception(ret.data) |
| 2525 | |
| 2526 | return ret |
| 2527 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2528 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2529 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2530 | queryset = SliceRole.objects.select_related().all() |
| 2531 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2532 | id_serializer_class = SliceRoleIdSerializer |
| 2533 | |
| 2534 | def get_serializer_class(self): |
| 2535 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2536 | if (no_hyperlinks): |
| 2537 | return self.id_serializer_class |
| 2538 | else: |
| 2539 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2540 | |
| 2541 | def get_queryset(self): |
| 2542 | return SliceRole.select_by_user(self.request.user) |
| 2543 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2544 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2545 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2546 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2547 | |
| 2548 | |
| 2549 | |
| 2550 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2551 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2552 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2553 | id_serializer_class = TagIdSerializer |
| 2554 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2555 | 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] | 2556 | |
| 2557 | def get_serializer_class(self): |
| 2558 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2559 | if (no_hyperlinks): |
| 2560 | return self.id_serializer_class |
| 2561 | else: |
| 2562 | return self.serializer_class |
| 2563 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2564 | def get_queryset(self): |
| 2565 | return Tag.select_by_user(self.request.user) |
| 2566 | |
| 2567 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2568 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2569 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2570 | response = {"error": "validation", |
| 2571 | "specific_error": "not serializer.is_valid()",
|
| 2572 | "reasons": serializer.errors}
|
| 2573 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2574 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2575 | obj.caller = request.user |
| 2576 | if obj.can_update(request.user): |
| 2577 | return super(TagList, self).create(request, *args, **kwargs) |
| 2578 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2579 | raise Exception("failed obj.can_update") |
| 2580 | |
| 2581 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 2582 | if (ret.status_code%100 != 200): |
| 2583 | raise Exception(ret.data) |
| 2584 | |
| 2585 | return ret |
| 2586 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2587 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2588 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2589 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2590 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2591 | id_serializer_class = TagIdSerializer |
| 2592 | |
| 2593 | def get_serializer_class(self): |
| 2594 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2595 | if (no_hyperlinks): |
| 2596 | return self.id_serializer_class |
| 2597 | else: |
| 2598 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2599 | |
| 2600 | def get_queryset(self): |
| 2601 | return Tag.select_by_user(self.request.user) |
| 2602 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2603 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2604 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2605 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2606 | |
| 2607 | |
| 2608 | |
| 2609 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2610 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2611 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2612 | id_serializer_class = InvoiceIdSerializer |
| 2613 | filter_backends = (filters.DjangoFilterBackend,) |
| 2614 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 2615 | |
| 2616 | def get_serializer_class(self): |
| 2617 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2618 | if (no_hyperlinks): |
| 2619 | return self.id_serializer_class |
| 2620 | else: |
| 2621 | return self.serializer_class |
| 2622 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2623 | def get_queryset(self): |
| 2624 | return Invoice.select_by_user(self.request.user) |
| 2625 | |
| 2626 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2627 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2628 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2629 | response = {"error": "validation", |
| 2630 | "specific_error": "not serializer.is_valid()",
|
| 2631 | "reasons": serializer.errors}
|
| 2632 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2633 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2634 | obj.caller = request.user |
| 2635 | if obj.can_update(request.user): |
| 2636 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 2637 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2638 | raise Exception("failed obj.can_update") |
| 2639 | |
| 2640 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 2641 | if (ret.status_code%100 != 200): |
| 2642 | raise Exception(ret.data) |
| 2643 | |
| 2644 | return ret |
| 2645 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2646 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2647 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2648 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2649 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2650 | id_serializer_class = InvoiceIdSerializer |
| 2651 | |
| 2652 | def get_serializer_class(self): |
| 2653 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2654 | if (no_hyperlinks): |
| 2655 | return self.id_serializer_class |
| 2656 | else: |
| 2657 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2658 | |
| 2659 | def get_queryset(self): |
| 2660 | return Invoice.select_by_user(self.request.user) |
| 2661 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2662 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2663 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2664 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2665 | |
| 2666 | |
| 2667 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2668 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 2669 | queryset = SlicePrivilege.objects.select_related().all() |
| 2670 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2671 | id_serializer_class = SlicePrivilegeIdSerializer |
| 2672 | filter_backends = (filters.DjangoFilterBackend,) |
| 2673 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 2674 | |
| 2675 | def get_serializer_class(self): |
| 2676 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2677 | if (no_hyperlinks): |
| 2678 | return self.id_serializer_class |
| 2679 | else: |
| 2680 | return self.serializer_class |
| 2681 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2682 | def get_queryset(self): |
| 2683 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2684 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2685 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2686 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2687 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2688 | response = {"error": "validation", |
| 2689 | "specific_error": "not serializer.is_valid()",
|
| 2690 | "reasons": serializer.errors}
|
| 2691 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2692 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2693 | obj.caller = request.user |
| 2694 | if obj.can_update(request.user): |
| 2695 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 2696 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2697 | raise Exception("failed obj.can_update") |
| 2698 | |
| 2699 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 2700 | if (ret.status_code%100 != 200): |
| 2701 | raise Exception(ret.data) |
| 2702 | |
| 2703 | return ret |
| 2704 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2705 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2706 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2707 | queryset = SlicePrivilege.objects.select_related().all() |
| 2708 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2709 | id_serializer_class = SlicePrivilegeIdSerializer |
| 2710 | |
| 2711 | def get_serializer_class(self): |
| 2712 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2713 | if (no_hyperlinks): |
| 2714 | return self.id_serializer_class |
| 2715 | else: |
| 2716 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2717 | |
| 2718 | def get_queryset(self): |
| 2719 | return SlicePrivilege.select_by_user(self.request.user) |
| 2720 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2721 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2722 | |
| 2723 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2724 | |
| 2725 | |
| 2726 | |
| 2727 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 2728 | queryset = PlanetStackRole.objects.select_related().all() |
| 2729 | serializer_class = PlanetStackRoleSerializer |
| 2730 | id_serializer_class = PlanetStackRoleIdSerializer |
| 2731 | filter_backends = (filters.DjangoFilterBackend,) |
| 2732 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2733 | |
| 2734 | def get_serializer_class(self): |
| 2735 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2736 | if (no_hyperlinks): |
| 2737 | return self.id_serializer_class |
| 2738 | else: |
| 2739 | return self.serializer_class |
| 2740 | |
| 2741 | def get_queryset(self): |
| 2742 | return PlanetStackRole.select_by_user(self.request.user) |
| 2743 | |
| 2744 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2745 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2746 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2747 | response = {"error": "validation", |
| 2748 | "specific_error": "not serializer.is_valid()",
|
| 2749 | "reasons": serializer.errors}
|
| 2750 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2751 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2752 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2753 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2754 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2755 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2756 | raise Exception("failed obj.can_update") |
| 2757 | |
| 2758 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 2759 | if (ret.status_code%100 != 200): |
| 2760 | raise Exception(ret.data) |
| 2761 | |
| 2762 | return ret |
| 2763 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2764 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2765 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2766 | queryset = PlanetStackRole.objects.select_related().all() |
| 2767 | serializer_class = PlanetStackRoleSerializer |
| 2768 | id_serializer_class = PlanetStackRoleIdSerializer |
| 2769 | |
| 2770 | def get_serializer_class(self): |
| 2771 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2772 | if (no_hyperlinks): |
| 2773 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2774 | else: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2775 | return self.serializer_class |
| 2776 | |
| 2777 | def get_queryset(self): |
| 2778 | return PlanetStackRole.select_by_user(self.request.user) |
| 2779 | |
| 2780 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2781 | |
| 2782 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2783 | |
| 2784 | |
| 2785 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2786 | class NetworkSliverList(generics.ListCreateAPIView): |
| 2787 | queryset = NetworkSliver.objects.select_related().all() |
| 2788 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2789 | id_serializer_class = NetworkSliverIdSerializer |
| 2790 | filter_backends = (filters.DjangoFilterBackend,) |
| 2791 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 2792 | |
| 2793 | def get_serializer_class(self): |
| 2794 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2795 | if (no_hyperlinks): |
| 2796 | return self.id_serializer_class |
| 2797 | else: |
| 2798 | return self.serializer_class |
| 2799 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2800 | def get_queryset(self): |
| 2801 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2802 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2803 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2804 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2805 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2806 | response = {"error": "validation", |
| 2807 | "specific_error": "not serializer.is_valid()",
|
| 2808 | "reasons": serializer.errors}
|
| 2809 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2810 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2811 | obj.caller = request.user |
| 2812 | if obj.can_update(request.user): |
| 2813 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 2814 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2815 | raise Exception("failed obj.can_update") |
| 2816 | |
| 2817 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 2818 | if (ret.status_code%100 != 200): |
| 2819 | raise Exception(ret.data) |
| 2820 | |
| 2821 | return ret |
| 2822 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2823 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2824 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2825 | queryset = NetworkSliver.objects.select_related().all() |
| 2826 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2827 | id_serializer_class = NetworkSliverIdSerializer |
| 2828 | |
| 2829 | def get_serializer_class(self): |
| 2830 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2831 | if (no_hyperlinks): |
| 2832 | return self.id_serializer_class |
| 2833 | else: |
| 2834 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2835 | |
| 2836 | def get_queryset(self): |
| 2837 | return NetworkSliver.select_by_user(self.request.user) |
| 2838 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2839 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2840 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2841 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2842 | |
| 2843 | |
| 2844 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2845 | class ControllerNetworksList(generics.ListCreateAPIView): |
| 2846 | queryset = ControllerNetworks.objects.select_related().all() |
| 2847 | serializer_class = ControllerNetworksSerializer |
| 2848 | id_serializer_class = ControllerNetworksIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2849 | filter_backends = (filters.DjangoFilterBackend,) |
| 2850 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
| 2851 | |
| 2852 | def get_serializer_class(self): |
| 2853 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2854 | if (no_hyperlinks): |
| 2855 | return self.id_serializer_class |
| 2856 | else: |
| 2857 | return self.serializer_class |
| 2858 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2859 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2860 | return ControllerNetworks.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2861 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2862 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2863 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2864 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2865 | response = {"error": "validation", |
| 2866 | "specific_error": "not serializer.is_valid()",
|
| 2867 | "reasons": serializer.errors}
|
| 2868 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2869 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2870 | obj.caller = request.user |
| 2871 | if obj.can_update(request.user): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2872 | return super(ControllerNetworksList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2873 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2874 | raise Exception("failed obj.can_update") |
| 2875 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2876 | ret = super(ControllerNetworksList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2877 | if (ret.status_code%100 != 200): |
| 2878 | raise Exception(ret.data) |
| 2879 | |
| 2880 | return ret |
| 2881 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2882 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2883 | class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2884 | queryset = ControllerNetworks.objects.select_related().all() |
| 2885 | serializer_class = ControllerNetworksSerializer |
| 2886 | id_serializer_class = ControllerNetworksIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2887 | |
| 2888 | def get_serializer_class(self): |
| 2889 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2890 | if (no_hyperlinks): |
| 2891 | return self.id_serializer_class |
| 2892 | else: |
| 2893 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2894 | |
| 2895 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 2896 | return ControllerNetworks.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2897 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2898 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2899 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2900 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2901 | |
| 2902 | |
| 2903 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2904 | class FlavorList(generics.ListCreateAPIView): |
| 2905 | queryset = Flavor.objects.select_related().all() |
| 2906 | serializer_class = FlavorSerializer |
| 2907 | id_serializer_class = FlavorIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2908 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2909 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2910 | |
| 2911 | def get_serializer_class(self): |
| 2912 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2913 | if (no_hyperlinks): |
| 2914 | return self.id_serializer_class |
| 2915 | else: |
| 2916 | return self.serializer_class |
| 2917 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2918 | def get_queryset(self): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2919 | return Flavor.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2920 | |
| 2921 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2922 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2923 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2924 | response = {"error": "validation", |
| 2925 | "specific_error": "not serializer.is_valid()",
|
| 2926 | "reasons": serializer.errors}
|
| 2927 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2928 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2929 | obj.caller = request.user |
| 2930 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2931 | return super(FlavorList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2932 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2933 | raise Exception("failed obj.can_update") |
| 2934 | |
| 2935 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 2936 | if (ret.status_code%100 != 200): |
| 2937 | raise Exception(ret.data) |
| 2938 | |
| 2939 | return ret |
| 2940 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2941 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2942 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2943 | queryset = Flavor.objects.select_related().all() |
| 2944 | serializer_class = FlavorSerializer |
| 2945 | id_serializer_class = FlavorIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2946 | |
| 2947 | def get_serializer_class(self): |
| 2948 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2949 | if (no_hyperlinks): |
| 2950 | return self.id_serializer_class |
| 2951 | else: |
| 2952 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2953 | |
| 2954 | def get_queryset(self): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2955 | return Flavor.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2956 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2957 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2958 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2959 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2960 | |
| 2961 | |
| 2962 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2963 | class ProjectList(generics.ListCreateAPIView): |
| 2964 | queryset = Project.objects.select_related().all() |
| 2965 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2966 | id_serializer_class = ProjectIdSerializer |
| 2967 | filter_backends = (filters.DjangoFilterBackend,) |
| 2968 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 2969 | |
| 2970 | def get_serializer_class(self): |
| 2971 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2972 | if (no_hyperlinks): |
| 2973 | return self.id_serializer_class |
| 2974 | else: |
| 2975 | return self.serializer_class |
| 2976 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2977 | def get_queryset(self): |
| 2978 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2979 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2980 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2981 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2982 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2983 | response = {"error": "validation", |
| 2984 | "specific_error": "not serializer.is_valid()",
|
| 2985 | "reasons": serializer.errors}
|
| 2986 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2987 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2988 | obj.caller = request.user |
| 2989 | if obj.can_update(request.user): |
| 2990 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 2991 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2992 | raise Exception("failed obj.can_update") |
| 2993 | |
| 2994 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 2995 | if (ret.status_code%100 != 200): |
| 2996 | raise Exception(ret.data) |
| 2997 | |
| 2998 | return ret |
| 2999 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3000 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3001 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3002 | queryset = Project.objects.select_related().all() |
| 3003 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3004 | id_serializer_class = ProjectIdSerializer |
| 3005 | |
| 3006 | def get_serializer_class(self): |
| 3007 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3008 | if (no_hyperlinks): |
| 3009 | return self.id_serializer_class |
| 3010 | else: |
| 3011 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3012 | |
| 3013 | def get_queryset(self): |
| 3014 | return Project.select_by_user(self.request.user) |
| 3015 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3016 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3017 | |
| 3018 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3019 | |
| 3020 | |
| 3021 | |
| 3022 | class SliceList(generics.ListCreateAPIView): |
| 3023 | queryset = Slice.objects.select_related().all() |
| 3024 | serializer_class = SliceSerializer |
| 3025 | id_serializer_class = SliceIdSerializer |
| 3026 | filter_backends = (filters.DjangoFilterBackend,) |
| 3027 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',) |
| 3028 | |
| 3029 | def get_serializer_class(self): |
| 3030 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3031 | if (no_hyperlinks): |
| 3032 | return self.id_serializer_class |
| 3033 | else: |
| 3034 | return self.serializer_class |
| 3035 | |
| 3036 | def get_queryset(self): |
| 3037 | return Slice.select_by_user(self.request.user) |
| 3038 | |
| 3039 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3040 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3041 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3042 | response = {"error": "validation", |
| 3043 | "specific_error": "not serializer.is_valid()",
|
| 3044 | "reasons": serializer.errors}
|
| 3045 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3046 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3047 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3048 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3049 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3050 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3051 | raise Exception("failed obj.can_update") |
| 3052 | |
| 3053 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3054 | if (ret.status_code%100 != 200): |
| 3055 | raise Exception(ret.data) |
| 3056 | |
| 3057 | return ret |
| 3058 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3059 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3060 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3061 | queryset = Slice.objects.select_related().all() |
| 3062 | serializer_class = SliceSerializer |
| 3063 | id_serializer_class = SliceIdSerializer |
| 3064 | |
| 3065 | def get_serializer_class(self): |
| 3066 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3067 | if (no_hyperlinks): |
| 3068 | return self.id_serializer_class |
| 3069 | else: |
| 3070 | return self.serializer_class |
| 3071 | |
| 3072 | def get_queryset(self): |
| 3073 | return Slice.select_by_user(self.request.user) |
| 3074 | |
| 3075 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3076 | |
| 3077 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3078 | |
| 3079 | |
| 3080 | |
| 3081 | class NetworkList(generics.ListCreateAPIView): |
| 3082 | queryset = Network.objects.select_related().all() |
| 3083 | serializer_class = NetworkSerializer |
| 3084 | id_serializer_class = NetworkIdSerializer |
| 3085 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 3086 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3087 | |
| 3088 | def get_serializer_class(self): |
| 3089 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3090 | if (no_hyperlinks): |
| 3091 | return self.id_serializer_class |
| 3092 | else: |
| 3093 | return self.serializer_class |
| 3094 | |
| 3095 | def get_queryset(self): |
| 3096 | return Network.select_by_user(self.request.user) |
| 3097 | |
| 3098 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3099 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3100 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3101 | response = {"error": "validation", |
| 3102 | "specific_error": "not serializer.is_valid()",
|
| 3103 | "reasons": serializer.errors}
|
| 3104 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3105 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3106 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3107 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3108 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3109 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3110 | raise Exception("failed obj.can_update") |
| 3111 | |
| 3112 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3113 | if (ret.status_code%100 != 200): |
| 3114 | raise Exception(ret.data) |
| 3115 | |
| 3116 | return ret |
| 3117 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3118 | |
| 3119 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3120 | queryset = Network.objects.select_related().all() |
| 3121 | serializer_class = NetworkSerializer |
| 3122 | id_serializer_class = NetworkIdSerializer |
| 3123 | |
| 3124 | def get_serializer_class(self): |
| 3125 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3126 | if (no_hyperlinks): |
| 3127 | return self.id_serializer_class |
| 3128 | else: |
| 3129 | return self.serializer_class |
| 3130 | |
| 3131 | def get_queryset(self): |
| 3132 | return Network.select_by_user(self.request.user) |
| 3133 | |
| 3134 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3135 | |
| 3136 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3137 | |
| 3138 | |
| 3139 | |
| 3140 | class ServiceList(generics.ListCreateAPIView): |
| 3141 | queryset = Service.objects.select_related().all() |
| 3142 | serializer_class = ServiceSerializer |
| 3143 | id_serializer_class = ServiceIdSerializer |
| 3144 | filter_backends = (filters.DjangoFilterBackend,) |
| 3145 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 3146 | |
| 3147 | def get_serializer_class(self): |
| 3148 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3149 | if (no_hyperlinks): |
| 3150 | return self.id_serializer_class |
| 3151 | else: |
| 3152 | return self.serializer_class |
| 3153 | |
| 3154 | def get_queryset(self): |
| 3155 | return Service.select_by_user(self.request.user) |
| 3156 | |
| 3157 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3158 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3159 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3160 | response = {"error": "validation", |
| 3161 | "specific_error": "not serializer.is_valid()",
|
| 3162 | "reasons": serializer.errors}
|
| 3163 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3164 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3165 | obj.caller = request.user |
| 3166 | if obj.can_update(request.user): |
| 3167 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3168 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3169 | raise Exception("failed obj.can_update") |
| 3170 | |
| 3171 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3172 | if (ret.status_code%100 != 200): |
| 3173 | raise Exception(ret.data) |
| 3174 | |
| 3175 | return ret |
| 3176 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3177 | |
| 3178 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3179 | queryset = Service.objects.select_related().all() |
| 3180 | serializer_class = ServiceSerializer |
| 3181 | id_serializer_class = ServiceIdSerializer |
| 3182 | |
| 3183 | def get_serializer_class(self): |
| 3184 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3185 | if (no_hyperlinks): |
| 3186 | return self.id_serializer_class |
| 3187 | else: |
| 3188 | return self.serializer_class |
| 3189 | |
| 3190 | def get_queryset(self): |
| 3191 | return Service.select_by_user(self.request.user) |
| 3192 | |
| 3193 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3194 | |
| 3195 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3196 | |
| 3197 | |
| 3198 | |
| 3199 | class ServiceClassList(generics.ListCreateAPIView): |
| 3200 | queryset = ServiceClass.objects.select_related().all() |
| 3201 | serializer_class = ServiceClassSerializer |
| 3202 | id_serializer_class = ServiceClassIdSerializer |
| 3203 | filter_backends = (filters.DjangoFilterBackend,) |
| 3204 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 3205 | |
| 3206 | def get_serializer_class(self): |
| 3207 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3208 | if (no_hyperlinks): |
| 3209 | return self.id_serializer_class |
| 3210 | else: |
| 3211 | return self.serializer_class |
| 3212 | |
| 3213 | def get_queryset(self): |
| 3214 | return ServiceClass.select_by_user(self.request.user) |
| 3215 | |
| 3216 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3217 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3218 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3219 | response = {"error": "validation", |
| 3220 | "specific_error": "not serializer.is_valid()",
|
| 3221 | "reasons": serializer.errors}
|
| 3222 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3223 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3224 | obj.caller = request.user |
| 3225 | if obj.can_update(request.user): |
| 3226 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3227 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3228 | raise Exception("failed obj.can_update") |
| 3229 | |
| 3230 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3231 | if (ret.status_code%100 != 200): |
| 3232 | raise Exception(ret.data) |
| 3233 | |
| 3234 | return ret |
| 3235 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3236 | |
| 3237 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3238 | queryset = ServiceClass.objects.select_related().all() |
| 3239 | serializer_class = ServiceClassSerializer |
| 3240 | id_serializer_class = ServiceClassIdSerializer |
| 3241 | |
| 3242 | def get_serializer_class(self): |
| 3243 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3244 | if (no_hyperlinks): |
| 3245 | return self.id_serializer_class |
| 3246 | else: |
| 3247 | return self.serializer_class |
| 3248 | |
| 3249 | def get_queryset(self): |
| 3250 | return ServiceClass.select_by_user(self.request.user) |
| 3251 | |
| 3252 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3253 | |
| 3254 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3255 | |
| 3256 | |
| 3257 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3258 | class PaymentList(generics.ListCreateAPIView): |
| 3259 | queryset = Payment.objects.select_related().all() |
| 3260 | serializer_class = PaymentSerializer |
| 3261 | id_serializer_class = PaymentIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3262 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3263 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3264 | |
| 3265 | def get_serializer_class(self): |
| 3266 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3267 | if (no_hyperlinks): |
| 3268 | return self.id_serializer_class |
| 3269 | else: |
| 3270 | return self.serializer_class |
| 3271 | |
| 3272 | def get_queryset(self): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3273 | return Payment.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3274 | |
| 3275 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3276 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3277 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3278 | response = {"error": "validation", |
| 3279 | "specific_error": "not serializer.is_valid()",
|
| 3280 | "reasons": serializer.errors}
|
| 3281 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3282 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3283 | obj.caller = request.user |
| 3284 | if obj.can_update(request.user): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3285 | return super(PaymentList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3286 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3287 | raise Exception("failed obj.can_update") |
| 3288 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3289 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3290 | if (ret.status_code%100 != 200): |
| 3291 | raise Exception(ret.data) |
| 3292 | |
| 3293 | return ret |
| 3294 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3295 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3296 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3297 | queryset = Payment.objects.select_related().all() |
| 3298 | serializer_class = PaymentSerializer |
| 3299 | id_serializer_class = PaymentIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3300 | |
| 3301 | def get_serializer_class(self): |
| 3302 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3303 | if (no_hyperlinks): |
| 3304 | return self.id_serializer_class |
| 3305 | else: |
| 3306 | return self.serializer_class |
| 3307 | |
| 3308 | def get_queryset(self): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3309 | return Payment.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3310 | |
| 3311 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3312 | |
| 3313 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3314 | |
| 3315 | |
| 3316 | |
| 3317 | class ChargeList(generics.ListCreateAPIView): |
| 3318 | queryset = Charge.objects.select_related().all() |
| 3319 | serializer_class = ChargeSerializer |
| 3320 | id_serializer_class = ChargeIdSerializer |
| 3321 | filter_backends = (filters.DjangoFilterBackend,) |
| 3322 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 3323 | |
| 3324 | def get_serializer_class(self): |
| 3325 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3326 | if (no_hyperlinks): |
| 3327 | return self.id_serializer_class |
| 3328 | else: |
| 3329 | return self.serializer_class |
| 3330 | |
| 3331 | def get_queryset(self): |
| 3332 | return Charge.select_by_user(self.request.user) |
| 3333 | |
| 3334 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3335 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3336 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3337 | response = {"error": "validation", |
| 3338 | "specific_error": "not serializer.is_valid()",
|
| 3339 | "reasons": serializer.errors}
|
| 3340 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3341 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3342 | obj.caller = request.user |
| 3343 | if obj.can_update(request.user): |
| 3344 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3345 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3346 | raise Exception("failed obj.can_update") |
| 3347 | |
| 3348 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3349 | if (ret.status_code%100 != 200): |
| 3350 | raise Exception(ret.data) |
| 3351 | |
| 3352 | return ret |
| 3353 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3354 | |
| 3355 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3356 | queryset = Charge.objects.select_related().all() |
| 3357 | serializer_class = ChargeSerializer |
| 3358 | id_serializer_class = ChargeIdSerializer |
| 3359 | |
| 3360 | def get_serializer_class(self): |
| 3361 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3362 | if (no_hyperlinks): |
| 3363 | return self.id_serializer_class |
| 3364 | else: |
| 3365 | return self.serializer_class |
| 3366 | |
| 3367 | def get_queryset(self): |
| 3368 | return Charge.select_by_user(self.request.user) |
| 3369 | |
| 3370 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3371 | |
| 3372 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3373 | |
| 3374 | |
| 3375 | |
| 3376 | class RoleList(generics.ListCreateAPIView): |
| 3377 | queryset = Role.objects.select_related().all() |
| 3378 | serializer_class = RoleSerializer |
| 3379 | id_serializer_class = RoleIdSerializer |
| 3380 | filter_backends = (filters.DjangoFilterBackend,) |
| 3381 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 3382 | |
| 3383 | def get_serializer_class(self): |
| 3384 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3385 | if (no_hyperlinks): |
| 3386 | return self.id_serializer_class |
| 3387 | else: |
| 3388 | return self.serializer_class |
| 3389 | |
| 3390 | def get_queryset(self): |
| 3391 | return Role.select_by_user(self.request.user) |
| 3392 | |
| 3393 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3394 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3395 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3396 | response = {"error": "validation", |
| 3397 | "specific_error": "not serializer.is_valid()",
|
| 3398 | "reasons": serializer.errors}
|
| 3399 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3400 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3401 | obj.caller = request.user |
| 3402 | if obj.can_update(request.user): |
| 3403 | return super(RoleList, self).create(request, *args, **kwargs) |
| 3404 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3405 | raise Exception("failed obj.can_update") |
| 3406 | |
| 3407 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 3408 | if (ret.status_code%100 != 200): |
| 3409 | raise Exception(ret.data) |
| 3410 | |
| 3411 | return ret |
| 3412 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3413 | |
| 3414 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3415 | queryset = Role.objects.select_related().all() |
| 3416 | serializer_class = RoleSerializer |
| 3417 | id_serializer_class = RoleIdSerializer |
| 3418 | |
| 3419 | def get_serializer_class(self): |
| 3420 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3421 | if (no_hyperlinks): |
| 3422 | return self.id_serializer_class |
| 3423 | else: |
| 3424 | return self.serializer_class |
| 3425 | |
| 3426 | def get_queryset(self): |
| 3427 | return Role.select_by_user(self.request.user) |
| 3428 | |
| 3429 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3430 | |
| 3431 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3432 | |
| 3433 | |
| 3434 | |
| 3435 | class UsableObjectList(generics.ListCreateAPIView): |
| 3436 | queryset = UsableObject.objects.select_related().all() |
| 3437 | serializer_class = UsableObjectSerializer |
| 3438 | id_serializer_class = UsableObjectIdSerializer |
| 3439 | filter_backends = (filters.DjangoFilterBackend,) |
| 3440 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3441 | |
| 3442 | def get_serializer_class(self): |
| 3443 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3444 | if (no_hyperlinks): |
| 3445 | return self.id_serializer_class |
| 3446 | else: |
| 3447 | return self.serializer_class |
| 3448 | |
| 3449 | def get_queryset(self): |
| 3450 | return UsableObject.select_by_user(self.request.user) |
| 3451 | |
| 3452 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3453 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3454 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3455 | response = {"error": "validation", |
| 3456 | "specific_error": "not serializer.is_valid()",
|
| 3457 | "reasons": serializer.errors}
|
| 3458 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3459 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3460 | obj.caller = request.user |
| 3461 | if obj.can_update(request.user): |
| 3462 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3463 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3464 | raise Exception("failed obj.can_update") |
| 3465 | |
| 3466 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3467 | if (ret.status_code%100 != 200): |
| 3468 | raise Exception(ret.data) |
| 3469 | |
| 3470 | return ret |
| 3471 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3472 | |
| 3473 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3474 | queryset = UsableObject.objects.select_related().all() |
| 3475 | serializer_class = UsableObjectSerializer |
| 3476 | id_serializer_class = UsableObjectIdSerializer |
| 3477 | |
| 3478 | def get_serializer_class(self): |
| 3479 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3480 | if (no_hyperlinks): |
| 3481 | return self.id_serializer_class |
| 3482 | else: |
| 3483 | return self.serializer_class |
| 3484 | |
| 3485 | def get_queryset(self): |
| 3486 | return UsableObject.select_by_user(self.request.user) |
| 3487 | |
| 3488 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3489 | |
| 3490 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3491 | |
| 3492 | |
| 3493 | |
| 3494 | class SiteRoleList(generics.ListCreateAPIView): |
| 3495 | queryset = SiteRole.objects.select_related().all() |
| 3496 | serializer_class = SiteRoleSerializer |
| 3497 | id_serializer_class = SiteRoleIdSerializer |
| 3498 | filter_backends = (filters.DjangoFilterBackend,) |
| 3499 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3500 | |
| 3501 | def get_serializer_class(self): |
| 3502 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3503 | if (no_hyperlinks): |
| 3504 | return self.id_serializer_class |
| 3505 | else: |
| 3506 | return self.serializer_class |
| 3507 | |
| 3508 | def get_queryset(self): |
| 3509 | return SiteRole.select_by_user(self.request.user) |
| 3510 | |
| 3511 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3512 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3513 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3514 | response = {"error": "validation", |
| 3515 | "specific_error": "not serializer.is_valid()",
|
| 3516 | "reasons": serializer.errors}
|
| 3517 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3518 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3519 | obj.caller = request.user |
| 3520 | if obj.can_update(request.user): |
| 3521 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3522 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3523 | raise Exception("failed obj.can_update") |
| 3524 | |
| 3525 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3526 | if (ret.status_code%100 != 200): |
| 3527 | raise Exception(ret.data) |
| 3528 | |
| 3529 | return ret |
| 3530 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3531 | |
| 3532 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3533 | queryset = SiteRole.objects.select_related().all() |
| 3534 | serializer_class = SiteRoleSerializer |
| 3535 | id_serializer_class = SiteRoleIdSerializer |
| 3536 | |
| 3537 | def get_serializer_class(self): |
| 3538 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3539 | if (no_hyperlinks): |
| 3540 | return self.id_serializer_class |
| 3541 | else: |
| 3542 | return self.serializer_class |
| 3543 | |
| 3544 | def get_queryset(self): |
| 3545 | return SiteRole.select_by_user(self.request.user) |
| 3546 | |
| 3547 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3548 | |
| 3549 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3550 | |
| 3551 | |
| 3552 | |
| 3553 | class SliceCredentialList(generics.ListCreateAPIView): |
| 3554 | queryset = SliceCredential.objects.select_related().all() |
| 3555 | serializer_class = SliceCredentialSerializer |
| 3556 | id_serializer_class = SliceCredentialIdSerializer |
| 3557 | filter_backends = (filters.DjangoFilterBackend,) |
| 3558 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 3559 | |
| 3560 | def get_serializer_class(self): |
| 3561 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3562 | if (no_hyperlinks): |
| 3563 | return self.id_serializer_class |
| 3564 | else: |
| 3565 | return self.serializer_class |
| 3566 | |
| 3567 | def get_queryset(self): |
| 3568 | return SliceCredential.select_by_user(self.request.user) |
| 3569 | |
| 3570 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3571 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3572 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3573 | response = {"error": "validation", |
| 3574 | "specific_error": "not serializer.is_valid()",
|
| 3575 | "reasons": serializer.errors}
|
| 3576 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3577 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3578 | obj.caller = request.user |
| 3579 | if obj.can_update(request.user): |
| 3580 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3581 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3582 | raise Exception("failed obj.can_update") |
| 3583 | |
| 3584 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3585 | if (ret.status_code%100 != 200): |
| 3586 | raise Exception(ret.data) |
| 3587 | |
| 3588 | return ret |
| 3589 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3590 | |
| 3591 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3592 | queryset = SliceCredential.objects.select_related().all() |
| 3593 | serializer_class = SliceCredentialSerializer |
| 3594 | id_serializer_class = SliceCredentialIdSerializer |
| 3595 | |
| 3596 | def get_serializer_class(self): |
| 3597 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3598 | if (no_hyperlinks): |
| 3599 | return self.id_serializer_class |
| 3600 | else: |
| 3601 | return self.serializer_class |
| 3602 | |
| 3603 | def get_queryset(self): |
| 3604 | return SliceCredential.select_by_user(self.request.user) |
| 3605 | |
| 3606 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3607 | |
| 3608 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3609 | |
| 3610 | |
| 3611 | |
| 3612 | class SliverList(generics.ListCreateAPIView): |
| 3613 | queryset = Sliver.objects.select_related().all() |
| 3614 | serializer_class = SliverSerializer |
| 3615 | id_serializer_class = SliverIdSerializer |
| 3616 | filter_backends = (filters.DjangoFilterBackend,) |
| 3617 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',) |
| 3618 | |
| 3619 | def get_serializer_class(self): |
| 3620 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3621 | if (no_hyperlinks): |
| 3622 | return self.id_serializer_class |
| 3623 | else: |
| 3624 | return self.serializer_class |
| 3625 | |
| 3626 | def get_queryset(self): |
| 3627 | return Sliver.select_by_user(self.request.user) |
| 3628 | |
| 3629 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3630 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3631 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3632 | response = {"error": "validation", |
| 3633 | "specific_error": "not serializer.is_valid()",
|
| 3634 | "reasons": serializer.errors}
|
| 3635 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3636 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3637 | obj.caller = request.user |
| 3638 | if obj.can_update(request.user): |
| 3639 | return super(SliverList, self).create(request, *args, **kwargs) |
| 3640 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3641 | raise Exception("failed obj.can_update") |
| 3642 | |
| 3643 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 3644 | if (ret.status_code%100 != 200): |
| 3645 | raise Exception(ret.data) |
| 3646 | |
| 3647 | return ret |
| 3648 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3649 | |
| 3650 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3651 | queryset = Sliver.objects.select_related().all() |
| 3652 | serializer_class = SliverSerializer |
| 3653 | id_serializer_class = SliverIdSerializer |
| 3654 | |
| 3655 | def get_serializer_class(self): |
| 3656 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3657 | if (no_hyperlinks): |
| 3658 | return self.id_serializer_class |
| 3659 | else: |
| 3660 | return self.serializer_class |
| 3661 | |
| 3662 | def get_queryset(self): |
| 3663 | return Sliver.select_by_user(self.request.user) |
| 3664 | |
| 3665 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3666 | |
| 3667 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3668 | |
| 3669 | |
| 3670 | |
| 3671 | class NodeList(generics.ListCreateAPIView): |
| 3672 | queryset = Node.objects.select_related().all() |
| 3673 | serializer_class = NodeSerializer |
| 3674 | id_serializer_class = NodeIdSerializer |
| 3675 | filter_backends = (filters.DjangoFilterBackend,) |
| 3676 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
| 3677 | |
| 3678 | def get_serializer_class(self): |
| 3679 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3680 | if (no_hyperlinks): |
| 3681 | return self.id_serializer_class |
| 3682 | else: |
| 3683 | return self.serializer_class |
| 3684 | |
| 3685 | def get_queryset(self): |
| 3686 | return Node.select_by_user(self.request.user) |
| 3687 | |
| 3688 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3689 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3690 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3691 | response = {"error": "validation", |
| 3692 | "specific_error": "not serializer.is_valid()",
|
| 3693 | "reasons": serializer.errors}
|
| 3694 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3695 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3696 | obj.caller = request.user |
| 3697 | if obj.can_update(request.user): |
| 3698 | return super(NodeList, self).create(request, *args, **kwargs) |
| 3699 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3700 | raise Exception("failed obj.can_update") |
| 3701 | |
| 3702 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 3703 | if (ret.status_code%100 != 200): |
| 3704 | raise Exception(ret.data) |
| 3705 | |
| 3706 | return ret |
| 3707 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3708 | |
| 3709 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3710 | queryset = Node.objects.select_related().all() |
| 3711 | serializer_class = NodeSerializer |
| 3712 | id_serializer_class = NodeIdSerializer |
| 3713 | |
| 3714 | def get_serializer_class(self): |
| 3715 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3716 | if (no_hyperlinks): |
| 3717 | return self.id_serializer_class |
| 3718 | else: |
| 3719 | return self.serializer_class |
| 3720 | |
| 3721 | def get_queryset(self): |
| 3722 | return Node.select_by_user(self.request.user) |
| 3723 | |
| 3724 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3725 | |
| 3726 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3727 | |
| 3728 | |
| 3729 | |
| 3730 | class DashboardViewList(generics.ListCreateAPIView): |
| 3731 | queryset = DashboardView.objects.select_related().all() |
| 3732 | serializer_class = DashboardViewSerializer |
| 3733 | id_serializer_class = DashboardViewIdSerializer |
| 3734 | filter_backends = (filters.DjangoFilterBackend,) |
| 3735 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',) |
| 3736 | |
| 3737 | def get_serializer_class(self): |
| 3738 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3739 | if (no_hyperlinks): |
| 3740 | return self.id_serializer_class |
| 3741 | else: |
| 3742 | return self.serializer_class |
| 3743 | |
| 3744 | def get_queryset(self): |
| 3745 | return DashboardView.select_by_user(self.request.user) |
| 3746 | |
| 3747 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3748 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3749 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3750 | response = {"error": "validation", |
| 3751 | "specific_error": "not serializer.is_valid()",
|
| 3752 | "reasons": serializer.errors}
|
| 3753 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3754 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3755 | obj.caller = request.user |
| 3756 | if obj.can_update(request.user): |
| 3757 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 3758 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3759 | raise Exception("failed obj.can_update") |
| 3760 | |
| 3761 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 3762 | if (ret.status_code%100 != 200): |
| 3763 | raise Exception(ret.data) |
| 3764 | |
| 3765 | return ret |
| 3766 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3767 | |
| 3768 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3769 | queryset = DashboardView.objects.select_related().all() |
| 3770 | serializer_class = DashboardViewSerializer |
| 3771 | id_serializer_class = DashboardViewIdSerializer |
| 3772 | |
| 3773 | def get_serializer_class(self): |
| 3774 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3775 | if (no_hyperlinks): |
| 3776 | return self.id_serializer_class |
| 3777 | else: |
| 3778 | return self.serializer_class |
| 3779 | |
| 3780 | def get_queryset(self): |
| 3781 | return DashboardView.select_by_user(self.request.user) |
| 3782 | |
| 3783 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3784 | |
| 3785 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3786 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3787 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3788 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 3789 | class ControllerImagesList(generics.ListCreateAPIView): |
| 3790 | queryset = ControllerImages.objects.select_related().all() |
| 3791 | serializer_class = ControllerImagesSerializer |
| 3792 | id_serializer_class = ControllerImagesIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3793 | filter_backends = (filters.DjangoFilterBackend,) |
| 3794 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
| 3795 | |
| 3796 | def get_serializer_class(self): |
| 3797 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3798 | if (no_hyperlinks): |
| 3799 | return self.id_serializer_class |
| 3800 | else: |
| 3801 | return self.serializer_class |
| 3802 | |
| 3803 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 3804 | return ControllerImages.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3805 | |
| 3806 | def create(self, request, *args, **kwargs): |
| 3807 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3808 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3809 | response = {"error": "validation", |
| 3810 | "specific_error": "not serializer.is_valid()",
|
| 3811 | "reasons": serializer.errors}
|
| 3812 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3813 | obj = serializer.object |
| 3814 | obj.caller = request.user |
| 3815 | if obj.can_update(request.user): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 3816 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3817 | else: |
| 3818 | raise Exception("failed obj.can_update") |
| 3819 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 3820 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3821 | if (ret.status_code%100 != 200): |
| 3822 | raise Exception(ret.data) |
| 3823 | |
| 3824 | return ret |
| 3825 | |
| 3826 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 3827 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3828 | queryset = ControllerImages.objects.select_related().all() |
| 3829 | serializer_class = ControllerImagesSerializer |
| 3830 | id_serializer_class = ControllerImagesIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3831 | |
| 3832 | def get_serializer_class(self): |
| 3833 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3834 | if (no_hyperlinks): |
| 3835 | return self.id_serializer_class |
| 3836 | else: |
| 3837 | return self.serializer_class |
| 3838 | |
| 3839 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 3840 | return ControllerImages.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3841 | |
| 3842 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3843 | |
| 3844 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3845 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3846 | |
| 3847 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3848 | class ReservedResourceList(generics.ListCreateAPIView): |
| 3849 | queryset = ReservedResource.objects.select_related().all() |
| 3850 | serializer_class = ReservedResourceSerializer |
| 3851 | id_serializer_class = ReservedResourceIdSerializer |
| 3852 | filter_backends = (filters.DjangoFilterBackend,) |
| 3853 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 3854 | |
| 3855 | def get_serializer_class(self): |
| 3856 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3857 | if (no_hyperlinks): |
| 3858 | return self.id_serializer_class |
| 3859 | else: |
| 3860 | return self.serializer_class |
| 3861 | |
| 3862 | def get_queryset(self): |
| 3863 | return ReservedResource.select_by_user(self.request.user) |
| 3864 | |
| 3865 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3866 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3867 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3868 | response = {"error": "validation", |
| 3869 | "specific_error": "not serializer.is_valid()",
|
| 3870 | "reasons": serializer.errors}
|
| 3871 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3872 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3873 | obj.caller = request.user |
| 3874 | if obj.can_update(request.user): |
| 3875 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 3876 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3877 | raise Exception("failed obj.can_update") |
| 3878 | |
| 3879 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 3880 | if (ret.status_code%100 != 200): |
| 3881 | raise Exception(ret.data) |
| 3882 | |
| 3883 | return ret |
| 3884 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3885 | |
| 3886 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3887 | queryset = ReservedResource.objects.select_related().all() |
| 3888 | serializer_class = ReservedResourceSerializer |
| 3889 | id_serializer_class = ReservedResourceIdSerializer |
| 3890 | |
| 3891 | def get_serializer_class(self): |
| 3892 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3893 | if (no_hyperlinks): |
| 3894 | return self.id_serializer_class |
| 3895 | else: |
| 3896 | return self.serializer_class |
| 3897 | |
| 3898 | def get_queryset(self): |
| 3899 | return ReservedResource.select_by_user(self.request.user) |
| 3900 | |
| 3901 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3902 | |
| 3903 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3904 | |
| 3905 | |
| 3906 | |
| 3907 | class NetworkSliceList(generics.ListCreateAPIView): |
| 3908 | queryset = NetworkSlice.objects.select_related().all() |
| 3909 | serializer_class = NetworkSliceSerializer |
| 3910 | id_serializer_class = NetworkSliceIdSerializer |
| 3911 | filter_backends = (filters.DjangoFilterBackend,) |
| 3912 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 3913 | |
| 3914 | def get_serializer_class(self): |
| 3915 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3916 | if (no_hyperlinks): |
| 3917 | return self.id_serializer_class |
| 3918 | else: |
| 3919 | return self.serializer_class |
| 3920 | |
| 3921 | def get_queryset(self): |
| 3922 | return NetworkSlice.select_by_user(self.request.user) |
| 3923 | |
| 3924 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3925 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3926 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3927 | response = {"error": "validation", |
| 3928 | "specific_error": "not serializer.is_valid()",
|
| 3929 | "reasons": serializer.errors}
|
| 3930 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3931 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3932 | obj.caller = request.user |
| 3933 | if obj.can_update(request.user): |
| 3934 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 3935 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3936 | raise Exception("failed obj.can_update") |
| 3937 | |
| 3938 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 3939 | if (ret.status_code%100 != 200): |
| 3940 | raise Exception(ret.data) |
| 3941 | |
| 3942 | return ret |
| 3943 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3944 | |
| 3945 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3946 | queryset = NetworkSlice.objects.select_related().all() |
| 3947 | serializer_class = NetworkSliceSerializer |
| 3948 | id_serializer_class = NetworkSliceIdSerializer |
| 3949 | |
| 3950 | def get_serializer_class(self): |
| 3951 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3952 | if (no_hyperlinks): |
| 3953 | return self.id_serializer_class |
| 3954 | else: |
| 3955 | return self.serializer_class |
| 3956 | |
| 3957 | def get_queryset(self): |
| 3958 | return NetworkSlice.select_by_user(self.request.user) |
| 3959 | |
| 3960 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3961 | |
| 3962 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3963 | |
| 3964 | |
| 3965 | |
| 3966 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 3967 | queryset = UserDashboardView.objects.select_related().all() |
| 3968 | serializer_class = UserDashboardViewSerializer |
| 3969 | id_serializer_class = UserDashboardViewIdSerializer |
| 3970 | filter_backends = (filters.DjangoFilterBackend,) |
| 3971 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 3972 | |
| 3973 | def get_serializer_class(self): |
| 3974 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3975 | if (no_hyperlinks): |
| 3976 | return self.id_serializer_class |
| 3977 | else: |
| 3978 | return self.serializer_class |
| 3979 | |
| 3980 | def get_queryset(self): |
| 3981 | return UserDashboardView.select_by_user(self.request.user) |
| 3982 | |
| 3983 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3984 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3985 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3986 | response = {"error": "validation", |
| 3987 | "specific_error": "not serializer.is_valid()",
|
| 3988 | "reasons": serializer.errors}
|
| 3989 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3990 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3991 | obj.caller = request.user |
| 3992 | if obj.can_update(request.user): |
| 3993 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 3994 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3995 | raise Exception("failed obj.can_update") |
| 3996 | |
| 3997 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 3998 | if (ret.status_code%100 != 200): |
| 3999 | raise Exception(ret.data) |
| 4000 | |
| 4001 | return ret |
| 4002 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4003 | |
| 4004 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4005 | queryset = UserDashboardView.objects.select_related().all() |
| 4006 | serializer_class = UserDashboardViewSerializer |
| 4007 | id_serializer_class = UserDashboardViewIdSerializer |
| 4008 | |
| 4009 | def get_serializer_class(self): |
| 4010 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4011 | if (no_hyperlinks): |
| 4012 | return self.id_serializer_class |
| 4013 | else: |
| 4014 | return self.serializer_class |
| 4015 | |
| 4016 | def get_queryset(self): |
| 4017 | return UserDashboardView.select_by_user(self.request.user) |
| 4018 | |
| 4019 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4020 | |
| 4021 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4022 | |
| 4023 | |
| 4024 | |
| 4025 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 4026 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4027 | serializer_class = PlanetStackPrivilegeSerializer |
| 4028 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4029 | filter_backends = (filters.DjangoFilterBackend,) |
| 4030 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 4031 | |
| 4032 | def get_serializer_class(self): |
| 4033 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4034 | if (no_hyperlinks): |
| 4035 | return self.id_serializer_class |
| 4036 | else: |
| 4037 | return self.serializer_class |
| 4038 | |
| 4039 | def get_queryset(self): |
| 4040 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4041 | |
| 4042 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4043 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4044 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4045 | response = {"error": "validation", |
| 4046 | "specific_error": "not serializer.is_valid()",
|
| 4047 | "reasons": serializer.errors}
|
| 4048 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4049 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4050 | obj.caller = request.user |
| 4051 | if obj.can_update(request.user): |
| 4052 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4053 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4054 | raise Exception("failed obj.can_update") |
| 4055 | |
| 4056 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4057 | if (ret.status_code%100 != 200): |
| 4058 | raise Exception(ret.data) |
| 4059 | |
| 4060 | return ret |
| 4061 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4062 | |
| 4063 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4064 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4065 | serializer_class = PlanetStackPrivilegeSerializer |
| 4066 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4067 | |
| 4068 | def get_serializer_class(self): |
| 4069 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4070 | if (no_hyperlinks): |
| 4071 | return self.id_serializer_class |
| 4072 | else: |
| 4073 | return self.serializer_class |
| 4074 | |
| 4075 | def get_queryset(self): |
| 4076 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4077 | |
| 4078 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4079 | |
| 4080 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4081 | |
| 4082 | |
| 4083 | |
| 4084 | class UserList(generics.ListCreateAPIView): |
| 4085 | queryset = User.objects.select_related().all() |
| 4086 | serializer_class = UserSerializer |
| 4087 | id_serializer_class = UserIdSerializer |
| 4088 | filter_backends = (filters.DjangoFilterBackend,) |
| 4089 | 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',) |
| 4090 | |
| 4091 | def get_serializer_class(self): |
| 4092 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4093 | if (no_hyperlinks): |
| 4094 | return self.id_serializer_class |
| 4095 | else: |
| 4096 | return self.serializer_class |
| 4097 | |
| 4098 | def get_queryset(self): |
| 4099 | return User.select_by_user(self.request.user) |
| 4100 | |
| 4101 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4102 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4103 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4104 | response = {"error": "validation", |
| 4105 | "specific_error": "not serializer.is_valid()",
|
| 4106 | "reasons": serializer.errors}
|
| 4107 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4108 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4109 | obj.caller = request.user |
| 4110 | if obj.can_update(request.user): |
| 4111 | return super(UserList, self).create(request, *args, **kwargs) |
| 4112 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4113 | raise Exception("failed obj.can_update") |
| 4114 | |
| 4115 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 4116 | if (ret.status_code%100 != 200): |
| 4117 | raise Exception(ret.data) |
| 4118 | |
| 4119 | return ret |
| 4120 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4121 | |
| 4122 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4123 | queryset = User.objects.select_related().all() |
| 4124 | serializer_class = UserSerializer |
| 4125 | id_serializer_class = UserIdSerializer |
| 4126 | |
| 4127 | def get_serializer_class(self): |
| 4128 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4129 | if (no_hyperlinks): |
| 4130 | return self.id_serializer_class |
| 4131 | else: |
| 4132 | return self.serializer_class |
| 4133 | |
| 4134 | def get_queryset(self): |
| 4135 | return User.select_by_user(self.request.user) |
| 4136 | |
| 4137 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4138 | |
| 4139 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4140 | |
| 4141 | |
| 4142 | |
| 4143 | class DeploymentList(generics.ListCreateAPIView): |
| 4144 | queryset = Deployment.objects.select_related().all() |
| 4145 | serializer_class = DeploymentSerializer |
| 4146 | id_serializer_class = DeploymentIdSerializer |
| 4147 | filter_backends = (filters.DjangoFilterBackend,) |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4148 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','sites','sites','flavors','flavors',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4149 | |
| 4150 | def get_serializer_class(self): |
| 4151 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4152 | if (no_hyperlinks): |
| 4153 | return self.id_serializer_class |
| 4154 | else: |
| 4155 | return self.serializer_class |
| 4156 | |
| 4157 | def get_queryset(self): |
| 4158 | return Deployment.select_by_user(self.request.user) |
| 4159 | |
| 4160 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4161 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4162 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4163 | response = {"error": "validation", |
| 4164 | "specific_error": "not serializer.is_valid()",
|
| 4165 | "reasons": serializer.errors}
|
| 4166 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4167 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4168 | obj.caller = request.user |
| 4169 | if obj.can_update(request.user): |
| 4170 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 4171 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4172 | raise Exception("failed obj.can_update") |
| 4173 | |
| 4174 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 4175 | if (ret.status_code%100 != 200): |
| 4176 | raise Exception(ret.data) |
| 4177 | |
| 4178 | return ret |
| 4179 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4180 | |
| 4181 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4182 | queryset = Deployment.objects.select_related().all() |
| 4183 | serializer_class = DeploymentSerializer |
| 4184 | id_serializer_class = DeploymentIdSerializer |
| 4185 | |
| 4186 | def get_serializer_class(self): |
| 4187 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4188 | if (no_hyperlinks): |
| 4189 | return self.id_serializer_class |
| 4190 | else: |
| 4191 | return self.serializer_class |
| 4192 | |
| 4193 | def get_queryset(self): |
| 4194 | return Deployment.select_by_user(self.request.user) |
| 4195 | |
| 4196 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4197 | |
| 4198 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4199 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4200 | class ControllerList(generics.ListCreateAPIView): |
| 4201 | queryset = Controller.objects.select_related().all() |
| 4202 | serializer_class = ControllerSerializer |
| 4203 | id_serializer_class = ControllerIdSerializer |
| 4204 | filter_backends = (filters.DjangoFilterBackend,) |
| 4205 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site_deployment','admin_user','admin_password','admin_tenant','auth_url','backend_type') |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4206 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4207 | def get_serializer_class(self): |
| 4208 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4209 | if (no_hyperlinks): |
| 4210 | return self.id_serializer_class |
| 4211 | else: |
| 4212 | return self.serializer_class |
| 4213 | |
| 4214 | def get_queryset(self): |
| 4215 | return Controller.select_by_user(self.request.user) |
| 4216 | |
| 4217 | def create(self, request, *args, **kwargs): |
| 4218 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4219 | if not (serializer.is_valid()): |
| 4220 | response = {"error": "validation", |
| 4221 | "specific_error": "not serializer.is_valid()", |
| 4222 | "reasons": serializer.errors} |
| 4223 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4224 | obj = serializer.object |
| 4225 | obj.caller = request.user |
| 4226 | if obj.can_update(request.user): |
| 4227 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4228 | else: |
| 4229 | raise Exception("failed obj.can_update") |
| 4230 | |
| 4231 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 4232 | if (ret.status_code%100 != 200): |
| 4233 | raise Exception(ret.data) |
| 4234 | |
| 4235 | return ret |
| 4236 | |
| 4237 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4238 | queryset = Controller.objects.select_related().all() |
| 4239 | serializer_class = ControllerSerializer |
| 4240 | id_serializer_class = ControllerIdSerializer |
| 4241 | |
| 4242 | def get_serializer_class(self): |
| 4243 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4244 | if (no_hyperlinks): |
| 4245 | return self.id_serializer_class |
| 4246 | else: |
| 4247 | return self.serializer_class |
| 4248 | |
| 4249 | def get_queryset(self): |
| 4250 | return Controller.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4251 | |
| 4252 | class ReservationList(generics.ListCreateAPIView): |
| 4253 | queryset = Reservation.objects.select_related().all() |
| 4254 | serializer_class = ReservationSerializer |
| 4255 | id_serializer_class = ReservationIdSerializer |
| 4256 | filter_backends = (filters.DjangoFilterBackend,) |
| 4257 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 4258 | |
| 4259 | def get_serializer_class(self): |
| 4260 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4261 | if (no_hyperlinks): |
| 4262 | return self.id_serializer_class |
| 4263 | else: |
| 4264 | return self.serializer_class |
| 4265 | |
| 4266 | def get_queryset(self): |
| 4267 | return Reservation.select_by_user(self.request.user) |
| 4268 | |
| 4269 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4270 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4271 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4272 | response = {"error": "validation", |
| 4273 | "specific_error": "not serializer.is_valid()",
|
| 4274 | "reasons": serializer.errors}
|
| 4275 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4276 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4277 | obj.caller = request.user |
| 4278 | if obj.can_update(request.user): |
| 4279 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 4280 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4281 | raise Exception("failed obj.can_update") |
| 4282 | |
| 4283 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 4284 | if (ret.status_code%100 != 200): |
| 4285 | raise Exception(ret.data) |
| 4286 | |
| 4287 | return ret |
| 4288 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4289 | |
| 4290 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4291 | queryset = Reservation.objects.select_related().all() |
| 4292 | serializer_class = ReservationSerializer |
| 4293 | id_serializer_class = ReservationIdSerializer |
| 4294 | |
| 4295 | def get_serializer_class(self): |
| 4296 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4297 | if (no_hyperlinks): |
| 4298 | return self.id_serializer_class |
| 4299 | else: |
| 4300 | return self.serializer_class |
| 4301 | |
| 4302 | def get_queryset(self): |
| 4303 | return Reservation.select_by_user(self.request.user) |
| 4304 | |
| 4305 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4306 | |
| 4307 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4308 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4309 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4310 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4311 | class ControllerSlicesList(generics.ListCreateAPIView): |
| 4312 | queryset = ControllerSlices.objects.select_related().all() |
| 4313 | serializer_class = ControllerSlicesSerializer |
| 4314 | id_serializer_class = ControllerSlicesIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4315 | filter_backends = (filters.DjangoFilterBackend,) |
| 4316 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
| 4317 | |
| 4318 | def get_serializer_class(self): |
| 4319 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4320 | if (no_hyperlinks): |
| 4321 | return self.id_serializer_class |
| 4322 | else: |
| 4323 | return self.serializer_class |
| 4324 | |
| 4325 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4326 | return ControllerSlices.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4327 | |
| 4328 | def create(self, request, *args, **kwargs): |
| 4329 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4330 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4331 | response = {"error": "validation", |
| 4332 | "specific_error": "not serializer.is_valid()",
|
| 4333 | "reasons": serializer.errors}
|
| 4334 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4335 | obj = serializer.object |
| 4336 | obj.caller = request.user |
| 4337 | if obj.can_update(request.user): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4338 | return super(ControllerSlicesList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4339 | else: |
| 4340 | raise Exception("failed obj.can_update") |
| 4341 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4342 | ret = super(ControllerSlicesList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4343 | if (ret.status_code%100 != 200): |
| 4344 | raise Exception(ret.data) |
| 4345 | |
| 4346 | return ret |
| 4347 | |
| 4348 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4349 | class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4350 | queryset = ControllerSlices.objects.select_related().all() |
| 4351 | serializer_class = ControllerSlicesSerializer |
| 4352 | id_serializer_class = ControllerSlicesIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4353 | |
| 4354 | def get_serializer_class(self): |
| 4355 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4356 | if (no_hyperlinks): |
| 4357 | return self.id_serializer_class |
| 4358 | else: |
| 4359 | return self.serializer_class |
| 4360 | |
| 4361 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4362 | return ControllerSlices.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4363 | |
| 4364 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4365 | |
| 4366 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4367 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4368 | |
| 4369 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4370 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 4371 | queryset = SitePrivilege.objects.select_related().all() |
| 4372 | serializer_class = SitePrivilegeSerializer |
| 4373 | id_serializer_class = SitePrivilegeIdSerializer |
| 4374 | filter_backends = (filters.DjangoFilterBackend,) |
| 4375 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 4376 | |
| 4377 | def get_serializer_class(self): |
| 4378 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4379 | if (no_hyperlinks): |
| 4380 | return self.id_serializer_class |
| 4381 | else: |
| 4382 | return self.serializer_class |
| 4383 | |
| 4384 | def get_queryset(self): |
| 4385 | return SitePrivilege.select_by_user(self.request.user) |
| 4386 | |
| 4387 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4388 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4389 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4390 | response = {"error": "validation", |
| 4391 | "specific_error": "not serializer.is_valid()",
|
| 4392 | "reasons": serializer.errors}
|
| 4393 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4394 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4395 | obj.caller = request.user |
| 4396 | if obj.can_update(request.user): |
| 4397 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4398 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4399 | raise Exception("failed obj.can_update") |
| 4400 | |
| 4401 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4402 | if (ret.status_code%100 != 200): |
| 4403 | raise Exception(ret.data) |
| 4404 | |
| 4405 | return ret |
| 4406 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4407 | |
| 4408 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4409 | queryset = SitePrivilege.objects.select_related().all() |
| 4410 | serializer_class = SitePrivilegeSerializer |
| 4411 | id_serializer_class = SitePrivilegeIdSerializer |
| 4412 | |
| 4413 | def get_serializer_class(self): |
| 4414 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4415 | if (no_hyperlinks): |
| 4416 | return self.id_serializer_class |
| 4417 | else: |
| 4418 | return self.serializer_class |
| 4419 | |
| 4420 | def get_queryset(self): |
| 4421 | return SitePrivilege.select_by_user(self.request.user) |
| 4422 | |
| 4423 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4424 | |
| 4425 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4426 | |
| 4427 | |
| 4428 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4429 | class PlanetStackList(generics.ListCreateAPIView): |
| 4430 | queryset = PlanetStack.objects.select_related().all() |
| 4431 | serializer_class = PlanetStackSerializer |
| 4432 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4433 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4434 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4435 | |
| 4436 | def get_serializer_class(self): |
| 4437 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4438 | if (no_hyperlinks): |
| 4439 | return self.id_serializer_class |
| 4440 | else: |
| 4441 | return self.serializer_class |
| 4442 | |
| 4443 | def get_queryset(self): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4444 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4445 | |
| 4446 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4447 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4448 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4449 | response = {"error": "validation", |
| 4450 | "specific_error": "not serializer.is_valid()",
|
| 4451 | "reasons": serializer.errors}
|
| 4452 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4453 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4454 | obj.caller = request.user |
| 4455 | if obj.can_update(request.user): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4456 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4457 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4458 | raise Exception("failed obj.can_update") |
| 4459 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4460 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4461 | if (ret.status_code%100 != 200): |
| 4462 | raise Exception(ret.data) |
| 4463 | |
| 4464 | return ret |
| 4465 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4466 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4467 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4468 | queryset = PlanetStack.objects.select_related().all() |
| 4469 | serializer_class = PlanetStackSerializer |
| 4470 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4471 | |
| 4472 | def get_serializer_class(self): |
| 4473 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4474 | if (no_hyperlinks): |
| 4475 | return self.id_serializer_class |
| 4476 | else: |
| 4477 | return self.serializer_class |
| 4478 | |
| 4479 | def get_queryset(self): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4480 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4481 | |
| 4482 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4483 | |
| 4484 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4485 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4486 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4487 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4488 | class ControllerUsersList(generics.ListCreateAPIView): |
| 4489 | queryset = ControllerUsers.objects.select_related().all() |
| 4490 | serializer_class = ControllerUsersSerializer |
| 4491 | id_serializer_class = ControllerUsersIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4492 | filter_backends = (filters.DjangoFilterBackend,) |
| 4493 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
| 4494 | |
| 4495 | def get_serializer_class(self): |
| 4496 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4497 | if (no_hyperlinks): |
| 4498 | return self.id_serializer_class |
| 4499 | else: |
| 4500 | return self.serializer_class |
| 4501 | |
| 4502 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4503 | return ControllerUsers.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4504 | |
| 4505 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4506 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4507 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4508 | response = {"error": "validation", |
| 4509 | "specific_error": "not serializer.is_valid()",
|
| 4510 | "reasons": serializer.errors}
|
| 4511 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4512 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4513 | obj.caller = request.user |
| 4514 | if obj.can_update(request.user): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4515 | return super(ControllerUsersList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4516 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4517 | raise Exception("failed obj.can_update") |
| 4518 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4519 | ret = super(ControllerUsersList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4520 | if (ret.status_code%100 != 200): |
| 4521 | raise Exception(ret.data) |
| 4522 | |
| 4523 | return ret |
| 4524 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4525 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4526 | class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4527 | queryset = ControllerUsers.objects.select_related().all() |
| 4528 | serializer_class = ControllerUsersSerializer |
| 4529 | id_serializer_class = ControllerUsersIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4530 | |
| 4531 | def get_serializer_class(self): |
| 4532 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4533 | if (no_hyperlinks): |
| 4534 | return self.id_serializer_class |
| 4535 | else: |
| 4536 | return self.serializer_class |
| 4537 | |
| 4538 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4539 | return ControllerUsers.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4540 | |
| 4541 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4542 | |
| 4543 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4544 | |
| 4545 | |
| 4546 | |
| 4547 | class AccountList(generics.ListCreateAPIView): |
| 4548 | queryset = Account.objects.select_related().all() |
| 4549 | serializer_class = AccountSerializer |
| 4550 | id_serializer_class = AccountIdSerializer |
| 4551 | filter_backends = (filters.DjangoFilterBackend,) |
| 4552 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 4553 | |
| 4554 | def get_serializer_class(self): |
| 4555 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4556 | if (no_hyperlinks): |
| 4557 | return self.id_serializer_class |
| 4558 | else: |
| 4559 | return self.serializer_class |
| 4560 | |
| 4561 | def get_queryset(self): |
| 4562 | return Account.select_by_user(self.request.user) |
| 4563 | |
| 4564 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4565 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4566 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4567 | response = {"error": "validation", |
| 4568 | "specific_error": "not serializer.is_valid()",
|
| 4569 | "reasons": serializer.errors}
|
| 4570 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4571 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4572 | obj.caller = request.user |
| 4573 | if obj.can_update(request.user): |
| 4574 | return super(AccountList, self).create(request, *args, **kwargs) |
| 4575 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4576 | raise Exception("failed obj.can_update") |
| 4577 | |
| 4578 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 4579 | if (ret.status_code%100 != 200): |
| 4580 | raise Exception(ret.data) |
| 4581 | |
| 4582 | return ret |
| 4583 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4584 | |
| 4585 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4586 | queryset = Account.objects.select_related().all() |
| 4587 | serializer_class = AccountSerializer |
| 4588 | id_serializer_class = AccountIdSerializer |
| 4589 | |
| 4590 | def get_serializer_class(self): |
| 4591 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4592 | if (no_hyperlinks): |
| 4593 | return self.id_serializer_class |
| 4594 | else: |
| 4595 | return self.serializer_class |
| 4596 | |
| 4597 | def get_queryset(self): |
| 4598 | return Account.select_by_user(self.request.user) |
| 4599 | |
| 4600 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4601 | |
| 4602 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4603 | |
| 4604 | |
| 4605 | |
| 4606 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 4607 | queryset = NetworkParameterType.objects.select_related().all() |
| 4608 | serializer_class = NetworkParameterTypeSerializer |
| 4609 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 4610 | filter_backends = (filters.DjangoFilterBackend,) |
| 4611 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 4612 | |
| 4613 | def get_serializer_class(self): |
| 4614 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4615 | if (no_hyperlinks): |
| 4616 | return self.id_serializer_class |
| 4617 | else: |
| 4618 | return self.serializer_class |
| 4619 | |
| 4620 | def get_queryset(self): |
| 4621 | return NetworkParameterType.select_by_user(self.request.user) |
| 4622 | |
| 4623 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4624 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4625 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4626 | response = {"error": "validation", |
| 4627 | "specific_error": "not serializer.is_valid()",
|
| 4628 | "reasons": serializer.errors}
|
| 4629 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4630 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4631 | obj.caller = request.user |
| 4632 | if obj.can_update(request.user): |
| 4633 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 4634 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4635 | raise Exception("failed obj.can_update") |
| 4636 | |
| 4637 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 4638 | if (ret.status_code%100 != 200): |
| 4639 | raise Exception(ret.data) |
| 4640 | |
| 4641 | return ret |
| 4642 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4643 | |
| 4644 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4645 | queryset = NetworkParameterType.objects.select_related().all() |
| 4646 | serializer_class = NetworkParameterTypeSerializer |
| 4647 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 4648 | |
| 4649 | def get_serializer_class(self): |
| 4650 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4651 | if (no_hyperlinks): |
| 4652 | return self.id_serializer_class |
| 4653 | else: |
| 4654 | return self.serializer_class |
| 4655 | |
| 4656 | def get_queryset(self): |
| 4657 | return NetworkParameterType.select_by_user(self.request.user) |
| 4658 | |
| 4659 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4660 | |
| 4661 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4662 | |
| 4663 | |
| 4664 | |
| 4665 | class SiteCredentialList(generics.ListCreateAPIView): |
| 4666 | queryset = SiteCredential.objects.select_related().all() |
| 4667 | serializer_class = SiteCredentialSerializer |
| 4668 | id_serializer_class = SiteCredentialIdSerializer |
| 4669 | filter_backends = (filters.DjangoFilterBackend,) |
| 4670 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 4671 | |
| 4672 | def get_serializer_class(self): |
| 4673 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4674 | if (no_hyperlinks): |
| 4675 | return self.id_serializer_class |
| 4676 | else: |
| 4677 | return self.serializer_class |
| 4678 | |
| 4679 | def get_queryset(self): |
| 4680 | return SiteCredential.select_by_user(self.request.user) |
| 4681 | |
| 4682 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4683 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4684 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4685 | response = {"error": "validation", |
| 4686 | "specific_error": "not serializer.is_valid()",
|
| 4687 | "reasons": serializer.errors}
|
| 4688 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4689 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4690 | obj.caller = request.user |
| 4691 | if obj.can_update(request.user): |
| 4692 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 4693 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4694 | raise Exception("failed obj.can_update") |
| 4695 | |
| 4696 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 4697 | if (ret.status_code%100 != 200): |
| 4698 | raise Exception(ret.data) |
| 4699 | |
| 4700 | return ret |
| 4701 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4702 | |
| 4703 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4704 | queryset = SiteCredential.objects.select_related().all() |
| 4705 | serializer_class = SiteCredentialSerializer |
| 4706 | id_serializer_class = SiteCredentialIdSerializer |
| 4707 | |
| 4708 | def get_serializer_class(self): |
| 4709 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4710 | if (no_hyperlinks): |
| 4711 | return self.id_serializer_class |
| 4712 | else: |
| 4713 | return self.serializer_class |
| 4714 | |
| 4715 | def get_queryset(self): |
| 4716 | return SiteCredential.select_by_user(self.request.user) |
| 4717 | |
| 4718 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4719 | |
| 4720 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4721 | |
| 4722 | |
| 4723 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4724 | class ControllerPrivilegeList(generics.ListCreateAPIView): |
| 4725 | queryset = ControllerPrivilege.objects.select_related().all() |
| 4726 | serializer_class = ControllerPrivilegeSerializer |
| 4727 | id_serializer_class = ControllerPrivilegeIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4728 | filter_backends = (filters.DjangoFilterBackend,) |
| 4729 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 4730 | |
| 4731 | def get_serializer_class(self): |
| 4732 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4733 | if (no_hyperlinks): |
| 4734 | return self.id_serializer_class |
| 4735 | else: |
| 4736 | return self.serializer_class |
| 4737 | |
| 4738 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4739 | return ControllerPrivilege.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4740 | |
| 4741 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4742 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4743 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4744 | response = {"error": "validation", |
| 4745 | "specific_error": "not serializer.is_valid()",
|
| 4746 | "reasons": serializer.errors}
|
| 4747 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4748 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4749 | obj.caller = request.user |
| 4750 | if obj.can_update(request.user): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4751 | return super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4752 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4753 | raise Exception("failed obj.can_update") |
| 4754 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4755 | ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4756 | if (ret.status_code%100 != 200): |
| 4757 | raise Exception(ret.data) |
| 4758 | |
| 4759 | return ret |
| 4760 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4761 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4762 | class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4763 | queryset = ControllerPrivilege.objects.select_related().all() |
| 4764 | serializer_class = ControllerPrivilegeSerializer |
| 4765 | id_serializer_class = ControllerPrivilegeIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4766 | |
| 4767 | def get_serializer_class(self): |
| 4768 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4769 | if (no_hyperlinks): |
| 4770 | return self.id_serializer_class |
| 4771 | else: |
| 4772 | return self.serializer_class |
| 4773 | |
| 4774 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4775 | return ControllerPrivilege.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4776 | |
| 4777 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4778 | |
| 4779 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4780 | |
| 4781 | |
| 4782 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4783 | class ControllerRoleList(generics.ListCreateAPIView): |
| 4784 | queryset = ControllerRole.objects.select_related().all() |
| 4785 | serializer_class = ControllerRoleSerializer |
| 4786 | id_serializer_class = ControllerRoleIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4787 | filter_backends = (filters.DjangoFilterBackend,) |
| 4788 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 4789 | |
| 4790 | def get_serializer_class(self): |
| 4791 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4792 | if (no_hyperlinks): |
| 4793 | return self.id_serializer_class |
| 4794 | else: |
| 4795 | return self.serializer_class |
| 4796 | |
| 4797 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4798 | return ControllerRole.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4799 | |
| 4800 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4801 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4802 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4803 | response = {"error": "validation", |
| 4804 | "specific_error": "not serializer.is_valid()",
|
| 4805 | "reasons": serializer.errors}
|
| 4806 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4807 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4808 | obj.caller = request.user |
| 4809 | if obj.can_update(request.user): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4810 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4811 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4812 | raise Exception("failed obj.can_update") |
| 4813 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4814 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4815 | if (ret.status_code%100 != 200): |
| 4816 | raise Exception(ret.data) |
| 4817 | |
| 4818 | return ret |
| 4819 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4820 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4821 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4822 | queryset = ControllerRole.objects.select_related().all() |
| 4823 | serializer_class = ControllerRoleSerializer |
| 4824 | id_serializer_class = ControllerRoleIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4825 | |
| 4826 | def get_serializer_class(self): |
| 4827 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4828 | if (no_hyperlinks): |
| 4829 | return self.id_serializer_class |
| 4830 | else: |
| 4831 | return self.serializer_class |
| 4832 | |
| 4833 | def get_queryset(self): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4834 | return ControllerRole.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4835 | |
| 4836 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4837 | |
| 4838 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4839 | |
| 4840 | |
| 4841 | |
| 4842 | class UserCredentialList(generics.ListCreateAPIView): |
| 4843 | queryset = UserCredential.objects.select_related().all() |
| 4844 | serializer_class = UserCredentialSerializer |
| 4845 | id_serializer_class = UserCredentialIdSerializer |
| 4846 | filter_backends = (filters.DjangoFilterBackend,) |
| 4847 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 4848 | |
| 4849 | def get_serializer_class(self): |
| 4850 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4851 | if (no_hyperlinks): |
| 4852 | return self.id_serializer_class |
| 4853 | else: |
| 4854 | return self.serializer_class |
| 4855 | |
| 4856 | def get_queryset(self): |
| 4857 | return UserCredential.select_by_user(self.request.user) |
| 4858 | |
| 4859 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4860 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4861 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4862 | response = {"error": "validation", |
| 4863 | "specific_error": "not serializer.is_valid()",
|
| 4864 | "reasons": serializer.errors}
|
| 4865 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4866 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4867 | obj.caller = request.user |
| 4868 | if obj.can_update(request.user): |
| 4869 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 4870 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4871 | raise Exception("failed obj.can_update") |
| 4872 | |
| 4873 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 4874 | if (ret.status_code%100 != 200): |
| 4875 | raise Exception(ret.data) |
| 4876 | |
| 4877 | return ret |
| 4878 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4879 | |
| 4880 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4881 | queryset = UserCredential.objects.select_related().all() |
| 4882 | serializer_class = UserCredentialSerializer |
| 4883 | id_serializer_class = UserCredentialIdSerializer |
| 4884 | |
| 4885 | def get_serializer_class(self): |
| 4886 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4887 | if (no_hyperlinks): |
| 4888 | return self.id_serializer_class |
| 4889 | else: |
| 4890 | return self.serializer_class |
| 4891 | |
| 4892 | def get_queryset(self): |
| 4893 | return UserCredential.select_by_user(self.request.user) |
| 4894 | |
| 4895 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4896 | |
| 4897 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4898 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4899 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4900 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4901 | class SiteDeploymentsList(generics.ListCreateAPIView): |
| 4902 | queryset = SiteDeployments.objects.select_related().all() |
| 4903 | serializer_class = SiteDeploymentsSerializer |
| 4904 | id_serializer_class = SiteDeploymentsIdSerializer |
| 4905 | filter_backends = (filters.DjangoFilterBackend,) |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4906 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment') |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4907 | |
| 4908 | def get_serializer_class(self): |
| 4909 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4910 | if (no_hyperlinks): |
| 4911 | return self.id_serializer_class |
| 4912 | else: |
| 4913 | return self.serializer_class |
| 4914 | |
| 4915 | def get_queryset(self): |
| 4916 | return SiteDeployments.select_by_user(self.request.user) |
| 4917 | |
| 4918 | def create(self, request, *args, **kwargs): |
| 4919 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4920 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4921 | response = {"error": "validation", |
| 4922 | "specific_error": "not serializer.is_valid()",
|
| 4923 | "reasons": serializer.errors}
|
| 4924 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4925 | obj = serializer.object |
| 4926 | obj.caller = request.user |
| 4927 | if obj.can_update(request.user): |
| 4928 | return super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 4929 | else: |
| 4930 | raise Exception("failed obj.can_update") |
| 4931 | |
| 4932 | ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 4933 | if (ret.status_code%100 != 200): |
| 4934 | raise Exception(ret.data) |
| 4935 | |
| 4936 | return ret |
| 4937 | |
| 4938 | |
| 4939 | class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4940 | queryset = SiteDeployments.objects.select_related().all() |
| 4941 | serializer_class = SiteDeploymentsSerializer |
| 4942 | id_serializer_class = SiteDeploymentsIdSerializer |
| 4943 | |
| 4944 | def get_serializer_class(self): |
| 4945 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4946 | if (no_hyperlinks): |
| 4947 | return self.id_serializer_class |
| 4948 | else: |
| 4949 | return self.serializer_class |
| 4950 | |
| 4951 | def get_queryset(self): |
| 4952 | return SiteDeployments.select_by_user(self.request.user) |
| 4953 | |
| 4954 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4955 | |
| 4956 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4957 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 4958 | class SliceTagList(generics.ListCreateAPIView): |
| 4959 | queryset = SliceTag.objects.select_related().all() |
| 4960 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 4961 | id_serializer_class = SliceTagIdSerializer |
| 4962 | filter_backends = (filters.DjangoFilterBackend,) |
| 4963 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 4964 | |
| 4965 | def get_serializer_class(self): |
| 4966 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4967 | if (no_hyperlinks): |
| 4968 | return self.id_serializer_class |
| 4969 | else: |
| 4970 | return self.serializer_class |
| 4971 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 4972 | def get_queryset(self): |
| 4973 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 4974 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 4975 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4976 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4977 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4978 | response = {"error": "validation", |
| 4979 | "specific_error": "not serializer.is_valid()",
|
| 4980 | "reasons": serializer.errors}
|
| 4981 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4982 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 4983 | obj.caller = request.user |
| 4984 | if obj.can_update(request.user): |
| 4985 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 4986 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4987 | raise Exception("failed obj.can_update") |
| 4988 | |
| 4989 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 4990 | if (ret.status_code%100 != 200): |
| 4991 | raise Exception(ret.data) |
| 4992 | |
| 4993 | return ret |
| 4994 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 4995 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4996 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 4997 | queryset = SliceTag.objects.select_related().all() |
| 4998 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 4999 | id_serializer_class = SliceTagIdSerializer |
| 5000 | |
| 5001 | def get_serializer_class(self): |
| 5002 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5003 | if (no_hyperlinks): |
| 5004 | return self.id_serializer_class |
| 5005 | else: |
| 5006 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5007 | |
| 5008 | def get_queryset(self): |
| 5009 | return SliceTag.select_by_user(self.request.user) |
| 5010 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5011 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5012 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5013 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5014 | |
| 5015 | |
| 5016 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5017 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 5018 | queryset = NetworkTemplate.objects.select_related().all() |
| 5019 | serializer_class = NetworkTemplateSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5020 | id_serializer_class = NetworkTemplateIdSerializer |
| 5021 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 5022 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5023 | |
| 5024 | def get_serializer_class(self): |
| 5025 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5026 | if (no_hyperlinks): |
| 5027 | return self.id_serializer_class |
| 5028 | else: |
| 5029 | return self.serializer_class |
| 5030 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5031 | def get_queryset(self): |
| 5032 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5033 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5034 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5035 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5036 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5037 | response = {"error": "validation", |
| 5038 | "specific_error": "not serializer.is_valid()",
|
| 5039 | "reasons": serializer.errors}
|
| 5040 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5041 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5042 | obj.caller = request.user |
| 5043 | if obj.can_update(request.user): |
| 5044 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 5045 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5046 | raise Exception("failed obj.can_update") |
| 5047 | |
| 5048 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 5049 | if (ret.status_code%100 != 200): |
| 5050 | raise Exception(ret.data) |
| 5051 | |
| 5052 | return ret |
| 5053 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5054 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5055 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5056 | queryset = NetworkTemplate.objects.select_related().all() |
| 5057 | serializer_class = NetworkTemplateSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5058 | id_serializer_class = NetworkTemplateIdSerializer |
| 5059 | |
| 5060 | def get_serializer_class(self): |
| 5061 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5062 | if (no_hyperlinks): |
| 5063 | return self.id_serializer_class |
| 5064 | else: |
| 5065 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5066 | |
| 5067 | def get_queryset(self): |
| 5068 | return NetworkTemplate.select_by_user(self.request.user) |
| 5069 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5070 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5071 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5072 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5073 | |
| 5074 | |
| 5075 | |
| 5076 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5077 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5078 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5079 | id_serializer_class = RouterIdSerializer |
| 5080 | filter_backends = (filters.DjangoFilterBackend,) |
| 5081 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',) |
| 5082 | |
| 5083 | def get_serializer_class(self): |
| 5084 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5085 | if (no_hyperlinks): |
| 5086 | return self.id_serializer_class |
| 5087 | else: |
| 5088 | return self.serializer_class |
| 5089 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5090 | def get_queryset(self): |
| 5091 | return Router.select_by_user(self.request.user) |
| 5092 | |
| 5093 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5094 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5095 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5096 | response = {"error": "validation", |
| 5097 | "specific_error": "not serializer.is_valid()",
|
| 5098 | "reasons": serializer.errors}
|
| 5099 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5100 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5101 | obj.caller = request.user |
| 5102 | if obj.can_update(request.user): |
| 5103 | return super(RouterList, self).create(request, *args, **kwargs) |
| 5104 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5105 | raise Exception("failed obj.can_update") |
| 5106 | |
| 5107 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 5108 | if (ret.status_code%100 != 200): |
| 5109 | raise Exception(ret.data) |
| 5110 | |
| 5111 | return ret |
| 5112 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5113 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5114 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5115 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5116 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5117 | id_serializer_class = RouterIdSerializer |
| 5118 | |
| 5119 | def get_serializer_class(self): |
| 5120 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5121 | if (no_hyperlinks): |
| 5122 | return self.id_serializer_class |
| 5123 | else: |
| 5124 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5125 | |
| 5126 | def get_queryset(self): |
| 5127 | return Router.select_by_user(self.request.user) |
| 5128 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5129 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5130 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5131 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5132 | |
| 5133 | |
| 5134 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5135 | class ServiceResourceList(generics.ListCreateAPIView): |
| 5136 | queryset = ServiceResource.objects.select_related().all() |
| 5137 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5138 | id_serializer_class = ServiceResourceIdSerializer |
| 5139 | filter_backends = (filters.DjangoFilterBackend,) |
| 5140 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 5141 | |
| 5142 | def get_serializer_class(self): |
| 5143 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5144 | if (no_hyperlinks): |
| 5145 | return self.id_serializer_class |
| 5146 | else: |
| 5147 | return self.serializer_class |
| 5148 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5149 | def get_queryset(self): |
| 5150 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5151 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5152 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5153 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5154 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5155 | response = {"error": "validation", |
| 5156 | "specific_error": "not serializer.is_valid()",
|
| 5157 | "reasons": serializer.errors}
|
| 5158 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5159 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5160 | obj.caller = request.user |
| 5161 | if obj.can_update(request.user): |
| 5162 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5163 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5164 | raise Exception("failed obj.can_update") |
| 5165 | |
| 5166 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5167 | if (ret.status_code%100 != 200): |
| 5168 | raise Exception(ret.data) |
| 5169 | |
| 5170 | return ret |
| 5171 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5172 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5173 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5174 | queryset = ServiceResource.objects.select_related().all() |
| 5175 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5176 | id_serializer_class = ServiceResourceIdSerializer |
| 5177 | |
| 5178 | def get_serializer_class(self): |
| 5179 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5180 | if (no_hyperlinks): |
| 5181 | return self.id_serializer_class |
| 5182 | else: |
| 5183 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5184 | |
| 5185 | def get_queryset(self): |
| 5186 | return ServiceResource.select_by_user(self.request.user) |
| 5187 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5188 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5189 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5190 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5191 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5192 | |
| 5193 | |