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