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