Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1 | from rest_framework.decorators import api_view |
| 2 | from rest_framework.response import Response |
| 3 | from rest_framework.reverse import reverse |
| 4 | from rest_framework import serializers |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5 | from rest_framework import generics |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 7 | from core.models import * |
| 8 | from django.forms import widgets |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 9 | from rest_framework import filters |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 10 | from django.conf.urls import patterns, url |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 11 | |
| 12 | """ |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 13 | Schema of the generator object: |
| 14 | all: Set of all Model objects |
| 15 | all_if(regex): Set of Model objects that match regex |
| 16 | |
| 17 | Model object: |
| 18 | plural: English plural of object name |
| 19 | camel: CamelCase version of object name |
| 20 | refs: list of references to other Model objects |
| 21 | props: list of properties minus refs |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 22 | |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 23 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 24 | """ |
| 25 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 26 | def get_REST_patterns(): |
| 27 | return patterns('', |
| 28 | url(r'^plstackapi/$', api_root), |
| 29 | |
| 30 | url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 31 | url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
| 32 | |
| 33 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 34 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
| 35 | |
| 36 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 37 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
| 38 | |
| 39 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 40 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
| 41 | |
| 42 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 43 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
| 44 | |
| 45 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 46 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
| 47 | |
| 48 | url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 49 | url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
| 50 | |
| 51 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 52 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
| 53 | |
| 54 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 55 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
| 56 | |
| 57 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 58 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
| 59 | |
| 60 | url(r'plstackapi/networkdeployments/$', NetworkDeploymentsList.as_view(), name='networkdeployments-list'), |
| 61 | url(r'plstackapi/networkdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDeploymentsDetail.as_view(), name ='networkdeployments-detail'), |
| 62 | |
| 63 | url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 64 | url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
| 65 | |
| 66 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 67 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 68 | |
| 69 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 70 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 71 | |
| 72 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 73 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 74 | |
| 75 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 76 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 77 | |
| 78 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 79 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 80 | |
| 81 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 82 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 83 | |
| 84 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 85 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 86 | |
| 87 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 88 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 89 | |
| 90 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 91 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 92 | |
| 93 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 94 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 95 | |
| 96 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 97 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 98 | |
| 99 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 100 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 101 | |
| 102 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 103 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 104 | |
| 105 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 106 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 107 | |
| 108 | url(r'plstackapi/imagedeployments/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 109 | url(r'plstackapi/imagedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'), |
| 110 | |
| 111 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 112 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 113 | |
| 114 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 115 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 116 | |
| 117 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 118 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 119 | |
| 120 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 121 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 122 | |
| 123 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 124 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 125 | |
| 126 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 127 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
| 128 | |
| 129 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 130 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 131 | |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 132 | url(r'plstackapi/slice_deployments/$', SliceDeploymentList.as_view(), name='slicedeployments-list'), |
| 133 | url(r'plstackapi/slice_deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDeploymentDetail.as_view(), name ='slicedeployments-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 134 | |
| 135 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 136 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 137 | |
| 138 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 139 | url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'), |
| 140 | |
| 141 | url(r'plstackapi/user_deployments/$', UserDeploymentsList.as_view(), name='userdeployments-list'), |
| 142 | url(r'plstackapi/user_deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentsDetail.as_view(), name ='userdeployments-detail'), |
| 143 | |
| 144 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 145 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 146 | |
| 147 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 148 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 149 | |
| 150 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 151 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 152 | |
| 153 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 154 | url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'), |
| 155 | |
| 156 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 157 | url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'), |
| 158 | |
| 159 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 160 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 161 | |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 162 | url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployments-list'), |
| 163 | url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployments-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 164 | |
| 165 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 166 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 167 | |
| 168 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 169 | url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'), |
| 170 | |
| 171 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 172 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 173 | |
| 174 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 175 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 176 | |
| 177 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 178 | |
| 179 | @api_view(['GET']) |
| 180 | def api_root(request, format=None): |
| 181 | return Response({ |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 182 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
| 183 | 'images': reverse('image-list', request=request, format=format), |
| 184 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 185 | 'sites': reverse('site-list', request=request, format=format), |
| 186 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 187 | 'tags': reverse('tag-list', request=request, format=format), |
| 188 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 189 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 190 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
| 191 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
| 192 | 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format), |
| 193 | 'flavors': reverse('flavor-list', request=request, format=format), |
| 194 | 'projects': reverse('project-list', request=request, format=format), |
| 195 | 'slices': reverse('slice-list', request=request, format=format), |
| 196 | 'networks': reverse('network-list', request=request, format=format), |
| 197 | 'services': reverse('service-list', request=request, format=format), |
| 198 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
| 199 | 'payments': reverse('payment-list', request=request, format=format), |
| 200 | 'charges': reverse('charge-list', request=request, format=format), |
| 201 | 'roles': reverse('role-list', request=request, format=format), |
| 202 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
| 203 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 204 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 205 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 206 | 'nodes': reverse('node-list', request=request, format=format), |
| 207 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
| 208 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
| 209 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
| 210 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 211 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
| 212 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 213 | 'users': reverse('user-list', request=request, format=format), |
| 214 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 215 | 'reservations': reverse('reservation-list', request=request, format=format), |
| 216 | 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format), |
| 217 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
| 218 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
| 219 | 'userdeploymentses': reverse('userdeployments-list', request=request, format=format), |
| 220 | 'accounts': reverse('account-list', request=request, format=format), |
| 221 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 222 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
| 223 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 224 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
| 225 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
| 226 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
| 227 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
| 228 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
| 229 | 'routers': reverse('router-list', request=request, format=format), |
| 230 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
| 231 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 232 | }) |
| 233 | |
| 234 | # Based on serializers.py |
| 235 | |
| 236 | |
| 237 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 238 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 239 | id = serializers.Field() |
| 240 | |
| 241 | class Meta: |
| 242 | model = ServiceAttribute |
| 243 | fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 244 | |
| 245 | class ServiceAttributeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 246 | id = serializers.Field() |
| 247 | |
| 248 | class Meta: |
| 249 | model = ServiceAttribute |
| 250 | fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 251 | |
| 252 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 253 | |
| 254 | |
| 255 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 256 | id = serializers.Field() |
| 257 | |
| 258 | class Meta: |
| 259 | model = Image |
| 260 | fields = ('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] | 261 | |
| 262 | class ImageIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 263 | id = serializers.Field() |
| 264 | |
| 265 | class Meta: |
| 266 | model = Image |
| 267 | fields = ('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] | 268 | |
| 269 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 270 | |
| 271 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 272 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 273 | id = serializers.Field() |
| 274 | |
| 275 | class Meta: |
| 276 | model = NetworkParameter |
| 277 | fields = ('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] | 278 | |
| 279 | class NetworkParameterIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 280 | id = serializers.Field() |
| 281 | |
| 282 | class Meta: |
| 283 | model = NetworkParameter |
| 284 | fields = ('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] | 285 | |
| 286 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 287 | |
| 288 | |
| 289 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 290 | id = serializers.Field() |
| 291 | |
| 292 | class Meta: |
| 293 | model = Site |
| 294 | fields = ('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] | 295 | |
| 296 | class SiteIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 297 | id = serializers.Field() |
| 298 | |
| 299 | class Meta: |
| 300 | model = Site |
| 301 | fields = ('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] | 302 | |
| 303 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 304 | |
| 305 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 306 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 307 | id = serializers.Field() |
| 308 | |
| 309 | class Meta: |
| 310 | model = SliceRole |
| 311 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 312 | |
| 313 | class SliceRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 314 | id = serializers.Field() |
| 315 | |
| 316 | class Meta: |
| 317 | model = SliceRole |
| 318 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 319 | |
| 320 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 321 | |
| 322 | |
| 323 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 324 | id = serializers.Field() |
| 325 | |
| 326 | class Meta: |
| 327 | model = Tag |
| 328 | 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] | 329 | |
| 330 | class TagIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 331 | id = serializers.Field() |
| 332 | |
| 333 | class Meta: |
| 334 | model = Tag |
| 335 | 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] | 336 | |
| 337 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 338 | |
| 339 | |
| 340 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 341 | id = serializers.Field() |
| 342 | |
| 343 | class Meta: |
| 344 | model = Invoice |
| 345 | fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 346 | |
| 347 | class InvoiceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 348 | id = serializers.Field() |
| 349 | |
| 350 | class Meta: |
| 351 | model = Invoice |
| 352 | fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 353 | |
| 354 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 355 | |
| 356 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 357 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 358 | id = serializers.Field() |
| 359 | |
| 360 | class Meta: |
| 361 | model = SlicePrivilege |
| 362 | fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 363 | |
| 364 | class SlicePrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 365 | id = serializers.Field() |
| 366 | |
| 367 | class Meta: |
| 368 | model = SlicePrivilege |
| 369 | fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 370 | |
| 371 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 372 | |
| 373 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 374 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 375 | id = serializers.Field() |
| 376 | |
| 377 | class Meta: |
| 378 | model = PlanetStackRole |
| 379 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 380 | |
| 381 | class PlanetStackRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 382 | id = serializers.Field() |
| 383 | |
| 384 | class Meta: |
| 385 | model = PlanetStackRole |
| 386 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 387 | |
| 388 | |
| 389 | |
| 390 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 391 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 392 | id = serializers.Field() |
| 393 | |
| 394 | class Meta: |
| 395 | model = NetworkSliver |
| 396 | fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 397 | |
| 398 | class NetworkSliverIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 399 | id = serializers.Field() |
| 400 | |
| 401 | class Meta: |
| 402 | model = NetworkSliver |
| 403 | fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 404 | |
| 405 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 406 | |
| 407 | |
| 408 | class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 409 | id = serializers.Field() |
| 410 | |
| 411 | class Meta: |
| 412 | model = NetworkDeployments |
| 413 | fields = ('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] | 414 | |
| 415 | class NetworkDeploymentsIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 416 | id = serializers.Field() |
| 417 | |
| 418 | class Meta: |
| 419 | model = NetworkDeployments |
| 420 | fields = ('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] | 421 | |
| 422 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 423 | |
| 424 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 425 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 426 | id = serializers.Field() |
| 427 | |
| 428 | class Meta: |
| 429 | model = Flavor |
| 430 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 431 | |
| 432 | class FlavorIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 433 | id = serializers.Field() |
| 434 | |
| 435 | class Meta: |
| 436 | model = Flavor |
| 437 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 443 | id = serializers.Field() |
| 444 | |
| 445 | class Meta: |
| 446 | model = Project |
| 447 | fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 448 | |
| 449 | class ProjectIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 450 | id = serializers.Field() |
| 451 | |
| 452 | class Meta: |
| 453 | model = Project |
| 454 | fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 455 | |
| 456 | |
| 457 | |
| 458 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 459 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 460 | id = serializers.Field() |
| 461 | |
| 462 | |
| 463 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 464 | |
| 465 | |
| 466 | |
| 467 | availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 468 | |
| 469 | |
| 470 | |
| 471 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 472 | |
| 473 | |
| 474 | |
| 475 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 476 | |
| 477 | |
| 478 | class Meta: |
| 479 | model = Slice |
| 480 | 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',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 481 | |
| 482 | class SliceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 483 | id = serializers.Field() |
| 484 | |
| 485 | |
| 486 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 487 | |
| 488 | |
| 489 | |
| 490 | availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 491 | |
| 492 | |
| 493 | |
| 494 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 495 | |
| 496 | |
| 497 | |
| 498 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 499 | |
| 500 | |
| 501 | class Meta: |
| 502 | model = Slice |
| 503 | 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',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 504 | |
| 505 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 506 | |
| 507 | |
| 508 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 509 | id = serializers.Field() |
| 510 | |
| 511 | |
| 512 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 513 | |
| 514 | |
| 515 | |
| 516 | availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 517 | |
| 518 | |
| 519 | |
| 520 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 521 | |
| 522 | |
| 523 | |
| 524 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 525 | |
| 526 | |
| 527 | class Meta: |
| 528 | model = Network |
| 529 | fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 530 | |
| 531 | class NetworkIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 532 | id = serializers.Field() |
| 533 | |
| 534 | |
| 535 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 536 | |
| 537 | |
| 538 | |
| 539 | availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 540 | |
| 541 | |
| 542 | |
| 543 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 544 | |
| 545 | |
| 546 | |
| 547 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 548 | |
| 549 | |
| 550 | class Meta: |
| 551 | model = Network |
| 552 | fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 553 | |
| 554 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 555 | |
| 556 | |
| 557 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 558 | id = serializers.Field() |
| 559 | |
| 560 | class Meta: |
| 561 | model = Service |
| 562 | fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 563 | |
| 564 | class ServiceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 565 | id = serializers.Field() |
| 566 | |
| 567 | class Meta: |
| 568 | model = Service |
| 569 | fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 570 | |
| 571 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 572 | |
| 573 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 574 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 575 | id = serializers.Field() |
| 576 | |
| 577 | class Meta: |
| 578 | model = ServiceClass |
| 579 | fields = ('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] | 580 | |
| 581 | class ServiceClassIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 582 | id = serializers.Field() |
| 583 | |
| 584 | class Meta: |
| 585 | model = ServiceClass |
| 586 | fields = ('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] | 587 | |
| 588 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 589 | |
| 590 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 591 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 592 | id = serializers.Field() |
| 593 | |
| 594 | class Meta: |
| 595 | model = Payment |
| 596 | fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 597 | |
| 598 | class PaymentIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 599 | id = serializers.Field() |
| 600 | |
| 601 | class Meta: |
| 602 | model = Payment |
| 603 | fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 604 | |
| 605 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 606 | |
| 607 | |
| 608 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 609 | id = serializers.Field() |
| 610 | |
| 611 | class Meta: |
| 612 | model = Charge |
| 613 | fields = ('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] | 614 | |
| 615 | class ChargeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 616 | id = serializers.Field() |
| 617 | |
| 618 | class Meta: |
| 619 | model = Charge |
| 620 | fields = ('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] | 621 | |
| 622 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 623 | |
| 624 | |
| 625 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 626 | id = serializers.Field() |
| 627 | |
| 628 | class Meta: |
| 629 | model = Role |
| 630 | fields = ('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] | 631 | |
| 632 | class RoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 633 | id = serializers.Field() |
| 634 | |
| 635 | class Meta: |
| 636 | model = Role |
| 637 | fields = ('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] | 638 | |
| 639 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 640 | |
| 641 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 642 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 643 | id = serializers.Field() |
| 644 | |
| 645 | class Meta: |
| 646 | model = UsableObject |
| 647 | fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 648 | |
| 649 | class UsableObjectIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 650 | id = serializers.Field() |
| 651 | |
| 652 | class Meta: |
| 653 | model = UsableObject |
| 654 | fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 655 | |
| 656 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 657 | |
| 658 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 659 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 660 | id = serializers.Field() |
| 661 | |
| 662 | class Meta: |
| 663 | model = SiteRole |
| 664 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 665 | |
| 666 | class SiteRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 667 | id = serializers.Field() |
| 668 | |
| 669 | class Meta: |
| 670 | model = SiteRole |
| 671 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 672 | |
| 673 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 674 | |
| 675 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 676 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 677 | id = serializers.Field() |
| 678 | |
| 679 | class Meta: |
| 680 | model = SliceCredential |
| 681 | fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 682 | |
| 683 | class SliceCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 684 | id = serializers.Field() |
| 685 | |
| 686 | class Meta: |
| 687 | model = SliceCredential |
| 688 | fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 689 | |
| 690 | |
| 691 | |
| 692 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 693 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 694 | id = serializers.Field() |
| 695 | |
| 696 | |
| 697 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 698 | |
| 699 | |
| 700 | |
| 701 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 702 | |
| 703 | |
| 704 | class Meta: |
| 705 | model = Sliver |
| 706 | fields = ('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] | 707 | |
| 708 | class SliverIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 709 | id = serializers.Field() |
| 710 | |
| 711 | |
| 712 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 713 | |
| 714 | |
| 715 | |
| 716 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 717 | |
| 718 | |
| 719 | class Meta: |
| 720 | model = Sliver |
| 721 | fields = ('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] | 722 | |
| 723 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 724 | |
| 725 | |
| 726 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 727 | id = serializers.Field() |
| 728 | |
| 729 | class Meta: |
| 730 | model = Node |
| 731 | fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 732 | |
| 733 | class NodeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 734 | id = serializers.Field() |
| 735 | |
| 736 | class Meta: |
| 737 | model = Node |
| 738 | fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 739 | |
| 740 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 741 | |
| 742 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 743 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 744 | id = serializers.Field() |
| 745 | |
| 746 | class Meta: |
| 747 | model = DashboardView |
| 748 | fields = ('id','created','updated','enacted','backend_status','deleted','name','url',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 749 | |
| 750 | class DashboardViewIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 751 | id = serializers.Field() |
| 752 | |
| 753 | class Meta: |
| 754 | model = DashboardView |
| 755 | fields = ('id','created','updated','enacted','backend_status','deleted','name','url',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 756 | |
| 757 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 758 | |
| 759 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 760 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 761 | id = serializers.Field() |
| 762 | |
| 763 | class Meta: |
| 764 | model = ImageDeployments |
| 765 | fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 766 | |
| 767 | class ImageDeploymentsIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 768 | id = serializers.Field() |
| 769 | |
| 770 | class Meta: |
| 771 | model = ImageDeployments |
| 772 | fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 773 | |
| 774 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 775 | |
| 776 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 777 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 778 | id = serializers.Field() |
| 779 | |
| 780 | class Meta: |
| 781 | model = ReservedResource |
| 782 | fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 783 | |
| 784 | class ReservedResourceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 785 | id = serializers.Field() |
| 786 | |
| 787 | class Meta: |
| 788 | model = ReservedResource |
| 789 | fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 790 | |
| 791 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 792 | |
| 793 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 794 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 795 | id = serializers.Field() |
| 796 | |
| 797 | class Meta: |
| 798 | model = NetworkSlice |
| 799 | fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 800 | |
| 801 | class NetworkSliceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 802 | id = serializers.Field() |
| 803 | |
| 804 | class Meta: |
| 805 | model = NetworkSlice |
| 806 | fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 807 | |
| 808 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 809 | |
| 810 | |
| 811 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 812 | id = serializers.Field() |
| 813 | |
| 814 | class Meta: |
| 815 | model = UserDashboardView |
| 816 | fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 817 | |
| 818 | class UserDashboardViewIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 819 | id = serializers.Field() |
| 820 | |
| 821 | class Meta: |
| 822 | model = UserDashboardView |
| 823 | fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 824 | |
| 825 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 826 | |
| 827 | |
| 828 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 829 | id = serializers.Field() |
| 830 | |
| 831 | class Meta: |
| 832 | model = PlanetStackPrivilege |
| 833 | fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 834 | |
| 835 | class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 836 | id = serializers.Field() |
| 837 | |
| 838 | class Meta: |
| 839 | model = PlanetStackPrivilege |
| 840 | fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 841 | |
| 842 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 843 | |
| 844 | |
| 845 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 846 | id = serializers.Field() |
| 847 | |
| 848 | class Meta: |
| 849 | model = User |
| 850 | 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',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 851 | |
| 852 | class UserIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 853 | id = serializers.Field() |
| 854 | |
| 855 | class Meta: |
| 856 | model = User |
| 857 | 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',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 858 | |
| 859 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 860 | |
| 861 | |
| 862 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 863 | id = serializers.Field() |
| 864 | |
| 865 | |
| 866 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 867 | |
| 868 | |
| 869 | |
| 870 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 871 | |
| 872 | |
| 873 | |
| 874 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 875 | |
| 876 | |
| 877 | |
| 878 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 879 | |
| 880 | |
| 881 | class Meta: |
| 882 | model = Deployment |
| 883 | 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',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 884 | |
| 885 | class DeploymentIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 886 | id = serializers.Field() |
| 887 | |
| 888 | |
| 889 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 890 | |
| 891 | |
| 892 | |
| 893 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 894 | |
| 895 | |
| 896 | |
| 897 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 898 | |
| 899 | |
| 900 | |
| 901 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 902 | |
| 903 | |
| 904 | class Meta: |
| 905 | model = Deployment |
| 906 | 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',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 907 | |
| 908 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 909 | |
| 910 | |
| 911 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 912 | id = serializers.Field() |
| 913 | |
| 914 | class Meta: |
| 915 | model = Reservation |
| 916 | fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 917 | |
| 918 | class ReservationIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 919 | id = serializers.Field() |
| 920 | |
| 921 | class Meta: |
| 922 | model = Reservation |
| 923 | fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 924 | |
| 925 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 926 | |
| 927 | |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 928 | class SliceDeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 929 | id = serializers.Field() |
| 930 | |
| 931 | class Meta: |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 932 | model = SliceDeployment |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 933 | fields = ('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] | 934 | |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 935 | class SliceDeploymentIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 936 | id = serializers.Field() |
| 937 | |
| 938 | class Meta: |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 939 | model = SliceDeployment |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 940 | fields = ('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] | 941 | |
| 942 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 943 | |
| 944 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 945 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 946 | id = serializers.Field() |
| 947 | |
| 948 | class Meta: |
| 949 | model = SitePrivilege |
| 950 | fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 951 | |
| 952 | class SitePrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 953 | id = serializers.Field() |
| 954 | |
| 955 | class Meta: |
| 956 | model = SitePrivilege |
| 957 | fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 958 | |
| 959 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 960 | |
| 961 | |
| 962 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 963 | id = serializers.Field() |
| 964 | |
| 965 | class Meta: |
| 966 | model = PlanetStack |
| 967 | fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 968 | |
| 969 | class PlanetStackIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 970 | id = serializers.Field() |
| 971 | |
| 972 | class Meta: |
| 973 | model = PlanetStack |
| 974 | fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 975 | |
| 976 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 977 | |
| 978 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 979 | class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 980 | id = serializers.Field() |
| 981 | |
| 982 | class Meta: |
| 983 | model = UserDeployments |
| 984 | fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 985 | |
| 986 | class UserDeploymentsIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 987 | id = serializers.Field() |
| 988 | |
| 989 | class Meta: |
| 990 | model = UserDeployments |
| 991 | fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 992 | |
| 993 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 994 | |
| 995 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 996 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 997 | id = serializers.Field() |
| 998 | |
| 999 | class Meta: |
| 1000 | model = Account |
| 1001 | fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1002 | |
| 1003 | class AccountIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1004 | id = serializers.Field() |
| 1005 | |
| 1006 | class Meta: |
| 1007 | model = Account |
| 1008 | fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1009 | |
| 1010 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1011 | |
| 1012 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1013 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1014 | id = serializers.Field() |
| 1015 | |
| 1016 | class Meta: |
| 1017 | model = NetworkParameterType |
| 1018 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1019 | |
| 1020 | class NetworkParameterTypeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1021 | id = serializers.Field() |
| 1022 | |
| 1023 | class Meta: |
| 1024 | model = NetworkParameterType |
| 1025 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1026 | |
| 1027 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1028 | |
| 1029 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1030 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1031 | id = serializers.Field() |
| 1032 | |
| 1033 | class Meta: |
| 1034 | model = SiteCredential |
| 1035 | fields = ('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] | 1036 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1037 | class SiteCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1038 | id = serializers.Field() |
| 1039 | |
| 1040 | class Meta: |
| 1041 | model = SiteCredential |
| 1042 | fields = ('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] | 1043 | |
| 1044 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1045 | |
| 1046 | |
| 1047 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1048 | id = serializers.Field() |
| 1049 | |
| 1050 | class Meta: |
| 1051 | model = DeploymentPrivilege |
| 1052 | fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1053 | |
| 1054 | class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1055 | id = serializers.Field() |
| 1056 | |
| 1057 | class Meta: |
| 1058 | model = DeploymentPrivilege |
| 1059 | fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1060 | |
| 1061 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1062 | |
| 1063 | |
| 1064 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1065 | id = serializers.Field() |
| 1066 | |
| 1067 | class Meta: |
| 1068 | model = DeploymentRole |
| 1069 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1070 | |
| 1071 | class DeploymentRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1072 | id = serializers.Field() |
| 1073 | |
| 1074 | class Meta: |
| 1075 | model = DeploymentRole |
| 1076 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1077 | |
| 1078 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1079 | |
| 1080 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1081 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1082 | id = serializers.Field() |
| 1083 | |
| 1084 | class Meta: |
| 1085 | model = UserCredential |
| 1086 | fields = ('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] | 1087 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1088 | class UserCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1089 | id = serializers.Field() |
| 1090 | |
| 1091 | class Meta: |
| 1092 | model = UserCredential |
| 1093 | fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1094 | |
| 1095 | |
| 1096 | |
| 1097 | |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 1098 | class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1099 | id = serializers.Field() |
| 1100 | |
| 1101 | class Meta: |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 1102 | model = SiteDeployment |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1103 | fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1104 | |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 1105 | class SiteDeploymentIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1106 | id = serializers.Field() |
| 1107 | |
| 1108 | class Meta: |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 1109 | model = SiteDeployment |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1110 | fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1111 | |
| 1112 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1113 | |
| 1114 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1115 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1116 | id = serializers.Field() |
| 1117 | |
| 1118 | class Meta: |
| 1119 | model = SliceTag |
| 1120 | fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1121 | |
| 1122 | class SliceTagIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1123 | id = serializers.Field() |
| 1124 | |
| 1125 | class Meta: |
| 1126 | model = SliceTag |
| 1127 | fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1128 | |
| 1129 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1130 | |
| 1131 | |
| 1132 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1133 | id = serializers.Field() |
| 1134 | |
| 1135 | class Meta: |
| 1136 | model = NetworkTemplate |
| 1137 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1138 | |
| 1139 | class NetworkTemplateIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1140 | id = serializers.Field() |
| 1141 | |
| 1142 | class Meta: |
| 1143 | model = NetworkTemplate |
| 1144 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1145 | |
| 1146 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1147 | |
| 1148 | |
| 1149 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1150 | id = serializers.Field() |
| 1151 | |
| 1152 | class Meta: |
| 1153 | model = Router |
| 1154 | fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1155 | |
| 1156 | class RouterIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1157 | id = serializers.Field() |
| 1158 | |
| 1159 | class Meta: |
| 1160 | model = Router |
| 1161 | fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1162 | |
| 1163 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1164 | |
| 1165 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1166 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1167 | id = serializers.Field() |
| 1168 | |
| 1169 | class Meta: |
| 1170 | model = ServiceResource |
| 1171 | fields = ('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] | 1172 | |
| 1173 | class ServiceResourceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1174 | id = serializers.Field() |
| 1175 | |
| 1176 | class Meta: |
| 1177 | model = ServiceResource |
| 1178 | fields = ('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] | 1179 | |
| 1180 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1181 | |
| 1182 | |
| 1183 | serializerLookUp = { |
| 1184 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1185 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1186 | |
| 1187 | Image: ImageSerializer, |
| 1188 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1189 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1190 | |
| 1191 | Site: SiteSerializer, |
| 1192 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1193 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1194 | |
| 1195 | Tag: TagSerializer, |
| 1196 | |
| 1197 | Invoice: InvoiceSerializer, |
| 1198 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1199 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1200 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1201 | PlanetStackRole: PlanetStackRoleSerializer, |
| 1202 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1203 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1204 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1205 | NetworkDeployments: NetworkDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1206 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1207 | Flavor: FlavorSerializer, |
| 1208 | |
| 1209 | Project: ProjectSerializer, |
| 1210 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1211 | Slice: SliceSerializer, |
| 1212 | |
| 1213 | Network: NetworkSerializer, |
| 1214 | |
| 1215 | Service: ServiceSerializer, |
| 1216 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1217 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1218 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1219 | Payment: PaymentSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1220 | |
| 1221 | Charge: ChargeSerializer, |
| 1222 | |
| 1223 | Role: RoleSerializer, |
| 1224 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1225 | UsableObject: UsableObjectSerializer, |
| 1226 | |
| 1227 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1228 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1229 | SliceCredential: SliceCredentialSerializer, |
| 1230 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1231 | Sliver: SliverSerializer, |
| 1232 | |
| 1233 | Node: NodeSerializer, |
| 1234 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1235 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1236 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1237 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1238 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1239 | ReservedResource: ReservedResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1240 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1241 | NetworkSlice: NetworkSliceSerializer, |
| 1242 | |
| 1243 | UserDashboardView: UserDashboardViewSerializer, |
| 1244 | |
| 1245 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1246 | |
| 1247 | User: UserSerializer, |
| 1248 | |
| 1249 | Deployment: DeploymentSerializer, |
| 1250 | |
| 1251 | Reservation: ReservationSerializer, |
| 1252 | |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 1253 | SliceDeployment: SliceDeploymentSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1254 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1255 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1256 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1257 | PlanetStack: PlanetStackSerializer, |
| 1258 | |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 1259 | UserDeployment: UserDeploymentSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1260 | |
| 1261 | Account: AccountSerializer, |
| 1262 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1263 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1264 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1265 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1266 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1267 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1268 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1269 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1270 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1271 | UserCredential: UserCredentialSerializer, |
| 1272 | |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 1273 | SiteDeployment: SiteDeploymentSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1274 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1275 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1276 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1277 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1278 | |
| 1279 | Router: RouterSerializer, |
| 1280 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1281 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1282 | |
| 1283 | None: None, |
| 1284 | } |
| 1285 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1286 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 1287 | |
| 1288 | # To handle fine-grained field permissions, we have to check can_update |
| 1289 | # the object has been updated but before it has been saved. |
| 1290 | |
| 1291 | def update(self, request, *args, **kwargs):
|
| 1292 | partial = kwargs.pop('partial', False)
|
| 1293 | self.object = self.get_object_or_none()
|
| 1294 |
|
| 1295 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 1296 | files=request.FILES, partial=partial)
|
| 1297 |
|
| 1298 | if not serializer.is_valid():
|
| 1299 | print "UpdateModelMixin: not serializer.is_valid"
|
| 1300 | print serializer.errors
|
| 1301 | return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
| 1302 |
|
| 1303 | try:
|
| 1304 | self.pre_save(serializer.object)
|
| 1305 | except ValidationError as err:
|
| 1306 | # full_clean on model instance may be called in pre_save,
|
| 1307 | # so we have to handle eventual errors.
|
| 1308 | return Response(err.message_dict, status=status.HTTP_400_BAD_REQUEST)
|
| 1309 |
|
| 1310 | if serializer.object is not None:
|
| 1311 | if not serializer.object.can_update(request.user):
|
| 1312 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 1313 |
|
| 1314 | if self.object is None:
|
| 1315 | self.object = serializer.save(force_insert=True)
|
| 1316 | self.post_save(self.object, created=True)
|
| 1317 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 1318 |
|
| 1319 | self.object = serializer.save(force_update=True)
|
| 1320 | self.post_save(self.object, created=False)
|
| 1321 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 1322 | |
| 1323 | def destroy(self, request, *args, **kwargs): |
| 1324 | obj = self.get_object() |
| 1325 | if obj.can_update(request.user): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1326 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1327 | else: |
| 1328 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1329 | |
| 1330 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1331 | # Based on core/views/*.py |
| 1332 | |
| 1333 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1334 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 1335 | queryset = ServiceAttribute.objects.select_related().all() |
| 1336 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1337 | id_serializer_class = ServiceAttributeIdSerializer |
| 1338 | filter_backends = (filters.DjangoFilterBackend,) |
| 1339 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 1340 | |
| 1341 | def get_serializer_class(self): |
| 1342 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1343 | if (no_hyperlinks): |
| 1344 | return self.id_serializer_class |
| 1345 | else: |
| 1346 | return self.serializer_class |
| 1347 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1348 | def get_queryset(self): |
| 1349 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1350 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1351 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1352 | obj = ServiceAttribute(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1353 | obj.caller = request.user |
| 1354 | if obj.can_update(request.user): |
| 1355 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 1356 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1357 | raise Exception("failed obj.can_update") |
| 1358 | |
| 1359 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 1360 | if (ret.status_code%100 != 200): |
| 1361 | raise Exception(ret.data) |
| 1362 | |
| 1363 | return ret |
| 1364 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1365 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1366 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1367 | queryset = ServiceAttribute.objects.select_related().all() |
| 1368 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1369 | id_serializer_class = ServiceAttributeIdSerializer |
| 1370 | |
| 1371 | def get_serializer_class(self): |
| 1372 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1373 | if (no_hyperlinks): |
| 1374 | return self.id_serializer_class |
| 1375 | else: |
| 1376 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1377 | |
| 1378 | def get_queryset(self): |
| 1379 | return ServiceAttribute.select_by_user(self.request.user) |
| 1380 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1381 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1382 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1383 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1384 | |
| 1385 | |
| 1386 | |
| 1387 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1388 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1389 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1390 | id_serializer_class = ImageIdSerializer |
| 1391 | filter_backends = (filters.DjangoFilterBackend,) |
| 1392 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
| 1393 | |
| 1394 | def get_serializer_class(self): |
| 1395 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1396 | if (no_hyperlinks): |
| 1397 | return self.id_serializer_class |
| 1398 | else: |
| 1399 | return self.serializer_class |
| 1400 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1401 | def get_queryset(self): |
| 1402 | return Image.select_by_user(self.request.user) |
| 1403 | |
| 1404 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1405 | obj = Image(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1406 | obj.caller = request.user |
| 1407 | if obj.can_update(request.user): |
| 1408 | return super(ImageList, self).create(request, *args, **kwargs) |
| 1409 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1410 | raise Exception("failed obj.can_update") |
| 1411 | |
| 1412 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 1413 | if (ret.status_code%100 != 200): |
| 1414 | raise Exception(ret.data) |
| 1415 | |
| 1416 | return ret |
| 1417 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1418 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1419 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1420 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1421 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1422 | id_serializer_class = ImageIdSerializer |
| 1423 | |
| 1424 | def get_serializer_class(self): |
| 1425 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1426 | if (no_hyperlinks): |
| 1427 | return self.id_serializer_class |
| 1428 | else: |
| 1429 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1430 | |
| 1431 | def get_queryset(self): |
| 1432 | return Image.select_by_user(self.request.user) |
| 1433 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1434 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1435 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1436 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1437 | |
| 1438 | |
| 1439 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1440 | class NetworkParameterList(generics.ListCreateAPIView): |
| 1441 | queryset = NetworkParameter.objects.select_related().all() |
| 1442 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1443 | id_serializer_class = NetworkParameterIdSerializer |
| 1444 | filter_backends = (filters.DjangoFilterBackend,) |
| 1445 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 1446 | |
| 1447 | def get_serializer_class(self): |
| 1448 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1449 | if (no_hyperlinks): |
| 1450 | return self.id_serializer_class |
| 1451 | else: |
| 1452 | return self.serializer_class |
| 1453 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1454 | def get_queryset(self): |
| 1455 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1456 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1457 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1458 | obj = NetworkParameter(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1459 | obj.caller = request.user |
| 1460 | if obj.can_update(request.user): |
| 1461 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 1462 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1463 | raise Exception("failed obj.can_update") |
| 1464 | |
| 1465 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 1466 | if (ret.status_code%100 != 200): |
| 1467 | raise Exception(ret.data) |
| 1468 | |
| 1469 | return ret |
| 1470 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1471 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1472 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1473 | queryset = NetworkParameter.objects.select_related().all() |
| 1474 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1475 | id_serializer_class = NetworkParameterIdSerializer |
| 1476 | |
| 1477 | def get_serializer_class(self): |
| 1478 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1479 | if (no_hyperlinks): |
| 1480 | return self.id_serializer_class |
| 1481 | else: |
| 1482 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1483 | |
| 1484 | def get_queryset(self): |
| 1485 | return NetworkParameter.select_by_user(self.request.user) |
| 1486 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1487 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1488 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1489 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1490 | |
| 1491 | |
| 1492 | |
| 1493 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1494 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1495 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1496 | id_serializer_class = SiteIdSerializer |
| 1497 | filter_backends = (filters.DjangoFilterBackend,) |
| 1498 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
| 1499 | |
| 1500 | def get_serializer_class(self): |
| 1501 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1502 | if (no_hyperlinks): |
| 1503 | return self.id_serializer_class |
| 1504 | else: |
| 1505 | return self.serializer_class |
| 1506 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1507 | def get_queryset(self): |
| 1508 | return Site.select_by_user(self.request.user) |
| 1509 | |
| 1510 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1511 | obj = Site(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1512 | obj.caller = request.user |
| 1513 | if obj.can_update(request.user): |
| 1514 | return super(SiteList, self).create(request, *args, **kwargs) |
| 1515 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1516 | raise Exception("failed obj.can_update") |
| 1517 | |
| 1518 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 1519 | if (ret.status_code%100 != 200): |
| 1520 | raise Exception(ret.data) |
| 1521 | |
| 1522 | return ret |
| 1523 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1524 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1525 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1526 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1527 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1528 | id_serializer_class = SiteIdSerializer |
| 1529 | |
| 1530 | def get_serializer_class(self): |
| 1531 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1532 | if (no_hyperlinks): |
| 1533 | return self.id_serializer_class |
| 1534 | else: |
| 1535 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1536 | |
| 1537 | def get_queryset(self): |
| 1538 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1539 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1540 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1541 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1542 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1543 | |
| 1544 | |
| 1545 | |
| 1546 | class SliceRoleList(generics.ListCreateAPIView): |
| 1547 | queryset = SliceRole.objects.select_related().all() |
| 1548 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1549 | id_serializer_class = SliceRoleIdSerializer |
| 1550 | filter_backends = (filters.DjangoFilterBackend,) |
| 1551 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 1552 | |
| 1553 | def get_serializer_class(self): |
| 1554 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1555 | if (no_hyperlinks): |
| 1556 | return self.id_serializer_class |
| 1557 | else: |
| 1558 | return self.serializer_class |
| 1559 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1560 | def get_queryset(self): |
| 1561 | return SliceRole.select_by_user(self.request.user) |
| 1562 | |
| 1563 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1564 | obj = SliceRole(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1565 | obj.caller = request.user |
| 1566 | if obj.can_update(request.user): |
| 1567 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 1568 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1569 | raise Exception("failed obj.can_update") |
| 1570 | |
| 1571 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 1572 | if (ret.status_code%100 != 200): |
| 1573 | raise Exception(ret.data) |
| 1574 | |
| 1575 | return ret |
| 1576 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1577 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1578 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1579 | queryset = SliceRole.objects.select_related().all() |
| 1580 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1581 | id_serializer_class = SliceRoleIdSerializer |
| 1582 | |
| 1583 | def get_serializer_class(self): |
| 1584 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1585 | if (no_hyperlinks): |
| 1586 | return self.id_serializer_class |
| 1587 | else: |
| 1588 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1589 | |
| 1590 | def get_queryset(self): |
| 1591 | return SliceRole.select_by_user(self.request.user) |
| 1592 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1593 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1594 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1595 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1596 | |
| 1597 | |
| 1598 | |
| 1599 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1600 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1601 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1602 | id_serializer_class = TagIdSerializer |
| 1603 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1604 | 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] | 1605 | |
| 1606 | def get_serializer_class(self): |
| 1607 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1608 | if (no_hyperlinks): |
| 1609 | return self.id_serializer_class |
| 1610 | else: |
| 1611 | return self.serializer_class |
| 1612 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1613 | def get_queryset(self): |
| 1614 | return Tag.select_by_user(self.request.user) |
| 1615 | |
| 1616 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1617 | obj = Tag(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1618 | obj.caller = request.user |
| 1619 | if obj.can_update(request.user): |
| 1620 | return super(TagList, self).create(request, *args, **kwargs) |
| 1621 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1622 | raise Exception("failed obj.can_update") |
| 1623 | |
| 1624 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 1625 | if (ret.status_code%100 != 200): |
| 1626 | raise Exception(ret.data) |
| 1627 | |
| 1628 | return ret |
| 1629 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1630 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1631 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1632 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1633 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1634 | id_serializer_class = TagIdSerializer |
| 1635 | |
| 1636 | def get_serializer_class(self): |
| 1637 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1638 | if (no_hyperlinks): |
| 1639 | return self.id_serializer_class |
| 1640 | else: |
| 1641 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1642 | |
| 1643 | def get_queryset(self): |
| 1644 | return Tag.select_by_user(self.request.user) |
| 1645 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1646 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1647 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1648 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1649 | |
| 1650 | |
| 1651 | |
| 1652 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1653 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1654 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1655 | id_serializer_class = InvoiceIdSerializer |
| 1656 | filter_backends = (filters.DjangoFilterBackend,) |
| 1657 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 1658 | |
| 1659 | def get_serializer_class(self): |
| 1660 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1661 | if (no_hyperlinks): |
| 1662 | return self.id_serializer_class |
| 1663 | else: |
| 1664 | return self.serializer_class |
| 1665 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1666 | def get_queryset(self): |
| 1667 | return Invoice.select_by_user(self.request.user) |
| 1668 | |
| 1669 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1670 | obj = Invoice(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1671 | obj.caller = request.user |
| 1672 | if obj.can_update(request.user): |
| 1673 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 1674 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1675 | raise Exception("failed obj.can_update") |
| 1676 | |
| 1677 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 1678 | if (ret.status_code%100 != 200): |
| 1679 | raise Exception(ret.data) |
| 1680 | |
| 1681 | return ret |
| 1682 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1683 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1684 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1685 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1686 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1687 | id_serializer_class = InvoiceIdSerializer |
| 1688 | |
| 1689 | def get_serializer_class(self): |
| 1690 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1691 | if (no_hyperlinks): |
| 1692 | return self.id_serializer_class |
| 1693 | else: |
| 1694 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1695 | |
| 1696 | def get_queryset(self): |
| 1697 | return Invoice.select_by_user(self.request.user) |
| 1698 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1699 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1700 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1701 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1702 | |
| 1703 | |
| 1704 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1705 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 1706 | queryset = SlicePrivilege.objects.select_related().all() |
| 1707 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1708 | id_serializer_class = SlicePrivilegeIdSerializer |
| 1709 | filter_backends = (filters.DjangoFilterBackend,) |
| 1710 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 1711 | |
| 1712 | def get_serializer_class(self): |
| 1713 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1714 | if (no_hyperlinks): |
| 1715 | return self.id_serializer_class |
| 1716 | else: |
| 1717 | return self.serializer_class |
| 1718 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1719 | def get_queryset(self): |
| 1720 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1721 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1722 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1723 | obj = SlicePrivilege(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1724 | obj.caller = request.user |
| 1725 | if obj.can_update(request.user): |
| 1726 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 1727 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1728 | raise Exception("failed obj.can_update") |
| 1729 | |
| 1730 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 1731 | if (ret.status_code%100 != 200): |
| 1732 | raise Exception(ret.data) |
| 1733 | |
| 1734 | return ret |
| 1735 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1736 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1737 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1738 | queryset = SlicePrivilege.objects.select_related().all() |
| 1739 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1740 | id_serializer_class = SlicePrivilegeIdSerializer |
| 1741 | |
| 1742 | def get_serializer_class(self): |
| 1743 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1744 | if (no_hyperlinks): |
| 1745 | return self.id_serializer_class |
| 1746 | else: |
| 1747 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1748 | |
| 1749 | def get_queryset(self): |
| 1750 | return SlicePrivilege.select_by_user(self.request.user) |
| 1751 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1752 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1753 | |
| 1754 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1755 | |
| 1756 | |
| 1757 | |
| 1758 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 1759 | queryset = PlanetStackRole.objects.select_related().all() |
| 1760 | serializer_class = PlanetStackRoleSerializer |
| 1761 | id_serializer_class = PlanetStackRoleIdSerializer |
| 1762 | filter_backends = (filters.DjangoFilterBackend,) |
| 1763 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 1764 | |
| 1765 | def get_serializer_class(self): |
| 1766 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1767 | if (no_hyperlinks): |
| 1768 | return self.id_serializer_class |
| 1769 | else: |
| 1770 | return self.serializer_class |
| 1771 | |
| 1772 | def get_queryset(self): |
| 1773 | return PlanetStackRole.select_by_user(self.request.user) |
| 1774 | |
| 1775 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1776 | obj = PlanetStackRole(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1777 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1778 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1779 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1780 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1781 | raise Exception("failed obj.can_update") |
| 1782 | |
| 1783 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 1784 | if (ret.status_code%100 != 200): |
| 1785 | raise Exception(ret.data) |
| 1786 | |
| 1787 | return ret |
| 1788 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1789 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1790 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 1791 | queryset = PlanetStackRole.objects.select_related().all() |
| 1792 | serializer_class = PlanetStackRoleSerializer |
| 1793 | id_serializer_class = PlanetStackRoleIdSerializer |
| 1794 | |
| 1795 | def get_serializer_class(self): |
| 1796 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1797 | if (no_hyperlinks): |
| 1798 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1799 | else: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1800 | return self.serializer_class |
| 1801 | |
| 1802 | def get_queryset(self): |
| 1803 | return PlanetStackRole.select_by_user(self.request.user) |
| 1804 | |
| 1805 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1806 | |
| 1807 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1808 | |
| 1809 | |
| 1810 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1811 | class NetworkSliverList(generics.ListCreateAPIView): |
| 1812 | queryset = NetworkSliver.objects.select_related().all() |
| 1813 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1814 | id_serializer_class = NetworkSliverIdSerializer |
| 1815 | filter_backends = (filters.DjangoFilterBackend,) |
| 1816 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 1817 | |
| 1818 | def get_serializer_class(self): |
| 1819 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1820 | if (no_hyperlinks): |
| 1821 | return self.id_serializer_class |
| 1822 | else: |
| 1823 | return self.serializer_class |
| 1824 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1825 | def get_queryset(self): |
| 1826 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1827 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1828 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1829 | obj = NetworkSliver(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1830 | obj.caller = request.user |
| 1831 | if obj.can_update(request.user): |
| 1832 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 1833 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1834 | raise Exception("failed obj.can_update") |
| 1835 | |
| 1836 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 1837 | if (ret.status_code%100 != 200): |
| 1838 | raise Exception(ret.data) |
| 1839 | |
| 1840 | return ret |
| 1841 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1842 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1843 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1844 | queryset = NetworkSliver.objects.select_related().all() |
| 1845 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1846 | id_serializer_class = NetworkSliverIdSerializer |
| 1847 | |
| 1848 | def get_serializer_class(self): |
| 1849 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1850 | if (no_hyperlinks): |
| 1851 | return self.id_serializer_class |
| 1852 | else: |
| 1853 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1854 | |
| 1855 | def get_queryset(self): |
| 1856 | return NetworkSliver.select_by_user(self.request.user) |
| 1857 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1858 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1859 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1860 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1861 | |
| 1862 | |
| 1863 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1864 | class NetworkDeploymentsList(generics.ListCreateAPIView): |
| 1865 | queryset = NetworkDeployments.objects.select_related().all() |
| 1866 | serializer_class = NetworkDeploymentsSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1867 | id_serializer_class = NetworkDeploymentsIdSerializer |
| 1868 | filter_backends = (filters.DjangoFilterBackend,) |
| 1869 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
| 1870 | |
| 1871 | def get_serializer_class(self): |
| 1872 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1873 | if (no_hyperlinks): |
| 1874 | return self.id_serializer_class |
| 1875 | else: |
| 1876 | return self.serializer_class |
| 1877 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1878 | def get_queryset(self): |
| 1879 | return NetworkDeployments.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1880 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1881 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1882 | obj = NetworkDeployments(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1883 | obj.caller = request.user |
| 1884 | if obj.can_update(request.user): |
| 1885 | return super(NetworkDeploymentsList, self).create(request, *args, **kwargs) |
| 1886 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1887 | raise Exception("failed obj.can_update") |
| 1888 | |
| 1889 | ret = super(NetworkDeploymentsList, self).create(request, *args, **kwargs) |
| 1890 | if (ret.status_code%100 != 200): |
| 1891 | raise Exception(ret.data) |
| 1892 | |
| 1893 | return ret |
| 1894 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1895 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1896 | class NetworkDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1897 | queryset = NetworkDeployments.objects.select_related().all() |
| 1898 | serializer_class = NetworkDeploymentsSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1899 | id_serializer_class = NetworkDeploymentsIdSerializer |
| 1900 | |
| 1901 | def get_serializer_class(self): |
| 1902 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1903 | if (no_hyperlinks): |
| 1904 | return self.id_serializer_class |
| 1905 | else: |
| 1906 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1907 | |
| 1908 | def get_queryset(self): |
| 1909 | return NetworkDeployments.select_by_user(self.request.user) |
| 1910 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1911 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1912 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1913 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1914 | |
| 1915 | |
| 1916 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1917 | class FlavorList(generics.ListCreateAPIView): |
| 1918 | queryset = Flavor.objects.select_related().all() |
| 1919 | serializer_class = FlavorSerializer |
| 1920 | id_serializer_class = FlavorIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1921 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1922 | 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] | 1923 | |
| 1924 | def get_serializer_class(self): |
| 1925 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1926 | if (no_hyperlinks): |
| 1927 | return self.id_serializer_class |
| 1928 | else: |
| 1929 | return self.serializer_class |
| 1930 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1931 | def get_queryset(self): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1932 | return Flavor.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1933 | |
| 1934 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1935 | obj = Flavor(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1936 | obj.caller = request.user |
| 1937 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1938 | return super(FlavorList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1939 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1940 | raise Exception("failed obj.can_update") |
| 1941 | |
| 1942 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 1943 | if (ret.status_code%100 != 200): |
| 1944 | raise Exception(ret.data) |
| 1945 | |
| 1946 | return ret |
| 1947 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1948 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1949 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 1950 | queryset = Flavor.objects.select_related().all() |
| 1951 | serializer_class = FlavorSerializer |
| 1952 | id_serializer_class = FlavorIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1953 | |
| 1954 | def get_serializer_class(self): |
| 1955 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1956 | if (no_hyperlinks): |
| 1957 | return self.id_serializer_class |
| 1958 | else: |
| 1959 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1960 | |
| 1961 | def get_queryset(self): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1962 | return Flavor.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1963 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1964 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1965 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1966 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1967 | |
| 1968 | |
| 1969 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1970 | class ProjectList(generics.ListCreateAPIView): |
| 1971 | queryset = Project.objects.select_related().all() |
| 1972 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1973 | id_serializer_class = ProjectIdSerializer |
| 1974 | filter_backends = (filters.DjangoFilterBackend,) |
| 1975 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 1976 | |
| 1977 | def get_serializer_class(self): |
| 1978 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1979 | if (no_hyperlinks): |
| 1980 | return self.id_serializer_class |
| 1981 | else: |
| 1982 | return self.serializer_class |
| 1983 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1984 | def get_queryset(self): |
| 1985 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1986 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1987 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1988 | obj = Project(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1989 | obj.caller = request.user |
| 1990 | if obj.can_update(request.user): |
| 1991 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 1992 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1993 | raise Exception("failed obj.can_update") |
| 1994 | |
| 1995 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 1996 | if (ret.status_code%100 != 200): |
| 1997 | raise Exception(ret.data) |
| 1998 | |
| 1999 | return ret |
| 2000 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2001 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2002 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2003 | queryset = Project.objects.select_related().all() |
| 2004 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2005 | id_serializer_class = ProjectIdSerializer |
| 2006 | |
| 2007 | def get_serializer_class(self): |
| 2008 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2009 | if (no_hyperlinks): |
| 2010 | return self.id_serializer_class |
| 2011 | else: |
| 2012 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2013 | |
| 2014 | def get_queryset(self): |
| 2015 | return Project.select_by_user(self.request.user) |
| 2016 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2017 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2018 | |
| 2019 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2020 | |
| 2021 | |
| 2022 | |
| 2023 | class SliceList(generics.ListCreateAPIView): |
| 2024 | queryset = Slice.objects.select_related().all() |
| 2025 | serializer_class = SliceSerializer |
| 2026 | id_serializer_class = SliceIdSerializer |
| 2027 | filter_backends = (filters.DjangoFilterBackend,) |
| 2028 | 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',) |
| 2029 | |
| 2030 | def get_serializer_class(self): |
| 2031 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2032 | if (no_hyperlinks): |
| 2033 | return self.id_serializer_class |
| 2034 | else: |
| 2035 | return self.serializer_class |
| 2036 | |
| 2037 | def get_queryset(self): |
| 2038 | return Slice.select_by_user(self.request.user) |
| 2039 | |
| 2040 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2041 | obj = Slice(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2042 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2043 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2044 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2045 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2046 | raise Exception("failed obj.can_update") |
| 2047 | |
| 2048 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 2049 | if (ret.status_code%100 != 200): |
| 2050 | raise Exception(ret.data) |
| 2051 | |
| 2052 | return ret |
| 2053 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2054 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2055 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2056 | queryset = Slice.objects.select_related().all() |
| 2057 | serializer_class = SliceSerializer |
| 2058 | id_serializer_class = SliceIdSerializer |
| 2059 | |
| 2060 | def get_serializer_class(self): |
| 2061 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2062 | if (no_hyperlinks): |
| 2063 | return self.id_serializer_class |
| 2064 | else: |
| 2065 | return self.serializer_class |
| 2066 | |
| 2067 | def get_queryset(self): |
| 2068 | return Slice.select_by_user(self.request.user) |
| 2069 | |
| 2070 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2071 | |
| 2072 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2073 | |
| 2074 | |
| 2075 | |
| 2076 | class NetworkList(generics.ListCreateAPIView): |
| 2077 | queryset = Network.objects.select_related().all() |
| 2078 | serializer_class = NetworkSerializer |
| 2079 | id_serializer_class = NetworkIdSerializer |
| 2080 | filter_backends = (filters.DjangoFilterBackend,) |
| 2081 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
| 2082 | |
| 2083 | def get_serializer_class(self): |
| 2084 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2085 | if (no_hyperlinks): |
| 2086 | return self.id_serializer_class |
| 2087 | else: |
| 2088 | return self.serializer_class |
| 2089 | |
| 2090 | def get_queryset(self): |
| 2091 | return Network.select_by_user(self.request.user) |
| 2092 | |
| 2093 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2094 | obj = Network(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2095 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2096 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2097 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2098 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2099 | raise Exception("failed obj.can_update") |
| 2100 | |
| 2101 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 2102 | if (ret.status_code%100 != 200): |
| 2103 | raise Exception(ret.data) |
| 2104 | |
| 2105 | return ret |
| 2106 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2107 | |
| 2108 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2109 | queryset = Network.objects.select_related().all() |
| 2110 | serializer_class = NetworkSerializer |
| 2111 | id_serializer_class = NetworkIdSerializer |
| 2112 | |
| 2113 | def get_serializer_class(self): |
| 2114 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2115 | if (no_hyperlinks): |
| 2116 | return self.id_serializer_class |
| 2117 | else: |
| 2118 | return self.serializer_class |
| 2119 | |
| 2120 | def get_queryset(self): |
| 2121 | return Network.select_by_user(self.request.user) |
| 2122 | |
| 2123 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2124 | |
| 2125 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2126 | |
| 2127 | |
| 2128 | |
| 2129 | class ServiceList(generics.ListCreateAPIView): |
| 2130 | queryset = Service.objects.select_related().all() |
| 2131 | serializer_class = ServiceSerializer |
| 2132 | id_serializer_class = ServiceIdSerializer |
| 2133 | filter_backends = (filters.DjangoFilterBackend,) |
| 2134 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 2135 | |
| 2136 | def get_serializer_class(self): |
| 2137 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2138 | if (no_hyperlinks): |
| 2139 | return self.id_serializer_class |
| 2140 | else: |
| 2141 | return self.serializer_class |
| 2142 | |
| 2143 | def get_queryset(self): |
| 2144 | return Service.select_by_user(self.request.user) |
| 2145 | |
| 2146 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2147 | obj = Service(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2148 | obj.caller = request.user |
| 2149 | if obj.can_update(request.user): |
| 2150 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 2151 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2152 | raise Exception("failed obj.can_update") |
| 2153 | |
| 2154 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 2155 | if (ret.status_code%100 != 200): |
| 2156 | raise Exception(ret.data) |
| 2157 | |
| 2158 | return ret |
| 2159 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2160 | |
| 2161 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2162 | queryset = Service.objects.select_related().all() |
| 2163 | serializer_class = ServiceSerializer |
| 2164 | id_serializer_class = ServiceIdSerializer |
| 2165 | |
| 2166 | def get_serializer_class(self): |
| 2167 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2168 | if (no_hyperlinks): |
| 2169 | return self.id_serializer_class |
| 2170 | else: |
| 2171 | return self.serializer_class |
| 2172 | |
| 2173 | def get_queryset(self): |
| 2174 | return Service.select_by_user(self.request.user) |
| 2175 | |
| 2176 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2177 | |
| 2178 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2179 | |
| 2180 | |
| 2181 | |
| 2182 | class ServiceClassList(generics.ListCreateAPIView): |
| 2183 | queryset = ServiceClass.objects.select_related().all() |
| 2184 | serializer_class = ServiceClassSerializer |
| 2185 | id_serializer_class = ServiceClassIdSerializer |
| 2186 | filter_backends = (filters.DjangoFilterBackend,) |
| 2187 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 2188 | |
| 2189 | def get_serializer_class(self): |
| 2190 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2191 | if (no_hyperlinks): |
| 2192 | return self.id_serializer_class |
| 2193 | else: |
| 2194 | return self.serializer_class |
| 2195 | |
| 2196 | def get_queryset(self): |
| 2197 | return ServiceClass.select_by_user(self.request.user) |
| 2198 | |
| 2199 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2200 | obj = ServiceClass(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2201 | obj.caller = request.user |
| 2202 | if obj.can_update(request.user): |
| 2203 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 2204 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2205 | raise Exception("failed obj.can_update") |
| 2206 | |
| 2207 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 2208 | if (ret.status_code%100 != 200): |
| 2209 | raise Exception(ret.data) |
| 2210 | |
| 2211 | return ret |
| 2212 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2213 | |
| 2214 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2215 | queryset = ServiceClass.objects.select_related().all() |
| 2216 | serializer_class = ServiceClassSerializer |
| 2217 | id_serializer_class = ServiceClassIdSerializer |
| 2218 | |
| 2219 | def get_serializer_class(self): |
| 2220 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2221 | if (no_hyperlinks): |
| 2222 | return self.id_serializer_class |
| 2223 | else: |
| 2224 | return self.serializer_class |
| 2225 | |
| 2226 | def get_queryset(self): |
| 2227 | return ServiceClass.select_by_user(self.request.user) |
| 2228 | |
| 2229 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2230 | |
| 2231 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2232 | |
| 2233 | |
| 2234 | |
| 2235 | class PaymentList(generics.ListCreateAPIView): |
| 2236 | queryset = Payment.objects.select_related().all() |
| 2237 | serializer_class = PaymentSerializer |
| 2238 | id_serializer_class = PaymentIdSerializer |
| 2239 | filter_backends = (filters.DjangoFilterBackend,) |
| 2240 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 2241 | |
| 2242 | def get_serializer_class(self): |
| 2243 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2244 | if (no_hyperlinks): |
| 2245 | return self.id_serializer_class |
| 2246 | else: |
| 2247 | return self.serializer_class |
| 2248 | |
| 2249 | def get_queryset(self): |
| 2250 | return Payment.select_by_user(self.request.user) |
| 2251 | |
| 2252 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2253 | obj = Payment(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2254 | obj.caller = request.user |
| 2255 | if obj.can_update(request.user): |
| 2256 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 2257 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2258 | raise Exception("failed obj.can_update") |
| 2259 | |
| 2260 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 2261 | if (ret.status_code%100 != 200): |
| 2262 | raise Exception(ret.data) |
| 2263 | |
| 2264 | return ret |
| 2265 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2266 | |
| 2267 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2268 | queryset = Payment.objects.select_related().all() |
| 2269 | serializer_class = PaymentSerializer |
| 2270 | id_serializer_class = PaymentIdSerializer |
| 2271 | |
| 2272 | def get_serializer_class(self): |
| 2273 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2274 | if (no_hyperlinks): |
| 2275 | return self.id_serializer_class |
| 2276 | else: |
| 2277 | return self.serializer_class |
| 2278 | |
| 2279 | def get_queryset(self): |
| 2280 | return Payment.select_by_user(self.request.user) |
| 2281 | |
| 2282 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2283 | |
| 2284 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2285 | |
| 2286 | |
| 2287 | |
| 2288 | class ChargeList(generics.ListCreateAPIView): |
| 2289 | queryset = Charge.objects.select_related().all() |
| 2290 | serializer_class = ChargeSerializer |
| 2291 | id_serializer_class = ChargeIdSerializer |
| 2292 | filter_backends = (filters.DjangoFilterBackend,) |
| 2293 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 2294 | |
| 2295 | def get_serializer_class(self): |
| 2296 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2297 | if (no_hyperlinks): |
| 2298 | return self.id_serializer_class |
| 2299 | else: |
| 2300 | return self.serializer_class |
| 2301 | |
| 2302 | def get_queryset(self): |
| 2303 | return Charge.select_by_user(self.request.user) |
| 2304 | |
| 2305 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2306 | obj = Charge(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2307 | obj.caller = request.user |
| 2308 | if obj.can_update(request.user): |
| 2309 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 2310 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2311 | raise Exception("failed obj.can_update") |
| 2312 | |
| 2313 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 2314 | if (ret.status_code%100 != 200): |
| 2315 | raise Exception(ret.data) |
| 2316 | |
| 2317 | return ret |
| 2318 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2319 | |
| 2320 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2321 | queryset = Charge.objects.select_related().all() |
| 2322 | serializer_class = ChargeSerializer |
| 2323 | id_serializer_class = ChargeIdSerializer |
| 2324 | |
| 2325 | def get_serializer_class(self): |
| 2326 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2327 | if (no_hyperlinks): |
| 2328 | return self.id_serializer_class |
| 2329 | else: |
| 2330 | return self.serializer_class |
| 2331 | |
| 2332 | def get_queryset(self): |
| 2333 | return Charge.select_by_user(self.request.user) |
| 2334 | |
| 2335 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2336 | |
| 2337 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2338 | |
| 2339 | |
| 2340 | |
| 2341 | class RoleList(generics.ListCreateAPIView): |
| 2342 | queryset = Role.objects.select_related().all() |
| 2343 | serializer_class = RoleSerializer |
| 2344 | id_serializer_class = RoleIdSerializer |
| 2345 | filter_backends = (filters.DjangoFilterBackend,) |
| 2346 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 2347 | |
| 2348 | def get_serializer_class(self): |
| 2349 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2350 | if (no_hyperlinks): |
| 2351 | return self.id_serializer_class |
| 2352 | else: |
| 2353 | return self.serializer_class |
| 2354 | |
| 2355 | def get_queryset(self): |
| 2356 | return Role.select_by_user(self.request.user) |
| 2357 | |
| 2358 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2359 | obj = Role(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2360 | obj.caller = request.user |
| 2361 | if obj.can_update(request.user): |
| 2362 | return super(RoleList, self).create(request, *args, **kwargs) |
| 2363 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2364 | raise Exception("failed obj.can_update") |
| 2365 | |
| 2366 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 2367 | if (ret.status_code%100 != 200): |
| 2368 | raise Exception(ret.data) |
| 2369 | |
| 2370 | return ret |
| 2371 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2372 | |
| 2373 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2374 | queryset = Role.objects.select_related().all() |
| 2375 | serializer_class = RoleSerializer |
| 2376 | id_serializer_class = RoleIdSerializer |
| 2377 | |
| 2378 | def get_serializer_class(self): |
| 2379 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2380 | if (no_hyperlinks): |
| 2381 | return self.id_serializer_class |
| 2382 | else: |
| 2383 | return self.serializer_class |
| 2384 | |
| 2385 | def get_queryset(self): |
| 2386 | return Role.select_by_user(self.request.user) |
| 2387 | |
| 2388 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2389 | |
| 2390 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2391 | |
| 2392 | |
| 2393 | |
| 2394 | class UsableObjectList(generics.ListCreateAPIView): |
| 2395 | queryset = UsableObject.objects.select_related().all() |
| 2396 | serializer_class = UsableObjectSerializer |
| 2397 | id_serializer_class = UsableObjectIdSerializer |
| 2398 | filter_backends = (filters.DjangoFilterBackend,) |
| 2399 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 2400 | |
| 2401 | def get_serializer_class(self): |
| 2402 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2403 | if (no_hyperlinks): |
| 2404 | return self.id_serializer_class |
| 2405 | else: |
| 2406 | return self.serializer_class |
| 2407 | |
| 2408 | def get_queryset(self): |
| 2409 | return UsableObject.select_by_user(self.request.user) |
| 2410 | |
| 2411 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2412 | obj = UsableObject(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2413 | obj.caller = request.user |
| 2414 | if obj.can_update(request.user): |
| 2415 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 2416 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2417 | raise Exception("failed obj.can_update") |
| 2418 | |
| 2419 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 2420 | if (ret.status_code%100 != 200): |
| 2421 | raise Exception(ret.data) |
| 2422 | |
| 2423 | return ret |
| 2424 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2425 | |
| 2426 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2427 | queryset = UsableObject.objects.select_related().all() |
| 2428 | serializer_class = UsableObjectSerializer |
| 2429 | id_serializer_class = UsableObjectIdSerializer |
| 2430 | |
| 2431 | def get_serializer_class(self): |
| 2432 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2433 | if (no_hyperlinks): |
| 2434 | return self.id_serializer_class |
| 2435 | else: |
| 2436 | return self.serializer_class |
| 2437 | |
| 2438 | def get_queryset(self): |
| 2439 | return UsableObject.select_by_user(self.request.user) |
| 2440 | |
| 2441 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2442 | |
| 2443 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2444 | |
| 2445 | |
| 2446 | |
| 2447 | class SiteRoleList(generics.ListCreateAPIView): |
| 2448 | queryset = SiteRole.objects.select_related().all() |
| 2449 | serializer_class = SiteRoleSerializer |
| 2450 | id_serializer_class = SiteRoleIdSerializer |
| 2451 | filter_backends = (filters.DjangoFilterBackend,) |
| 2452 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2453 | |
| 2454 | def get_serializer_class(self): |
| 2455 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2456 | if (no_hyperlinks): |
| 2457 | return self.id_serializer_class |
| 2458 | else: |
| 2459 | return self.serializer_class |
| 2460 | |
| 2461 | def get_queryset(self): |
| 2462 | return SiteRole.select_by_user(self.request.user) |
| 2463 | |
| 2464 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2465 | obj = SiteRole(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2466 | obj.caller = request.user |
| 2467 | if obj.can_update(request.user): |
| 2468 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 2469 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2470 | raise Exception("failed obj.can_update") |
| 2471 | |
| 2472 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 2473 | if (ret.status_code%100 != 200): |
| 2474 | raise Exception(ret.data) |
| 2475 | |
| 2476 | return ret |
| 2477 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2478 | |
| 2479 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2480 | queryset = SiteRole.objects.select_related().all() |
| 2481 | serializer_class = SiteRoleSerializer |
| 2482 | id_serializer_class = SiteRoleIdSerializer |
| 2483 | |
| 2484 | def get_serializer_class(self): |
| 2485 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2486 | if (no_hyperlinks): |
| 2487 | return self.id_serializer_class |
| 2488 | else: |
| 2489 | return self.serializer_class |
| 2490 | |
| 2491 | def get_queryset(self): |
| 2492 | return SiteRole.select_by_user(self.request.user) |
| 2493 | |
| 2494 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2495 | |
| 2496 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2497 | |
| 2498 | |
| 2499 | |
| 2500 | class SliceCredentialList(generics.ListCreateAPIView): |
| 2501 | queryset = SliceCredential.objects.select_related().all() |
| 2502 | serializer_class = SliceCredentialSerializer |
| 2503 | id_serializer_class = SliceCredentialIdSerializer |
| 2504 | filter_backends = (filters.DjangoFilterBackend,) |
| 2505 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 2506 | |
| 2507 | def get_serializer_class(self): |
| 2508 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2509 | if (no_hyperlinks): |
| 2510 | return self.id_serializer_class |
| 2511 | else: |
| 2512 | return self.serializer_class |
| 2513 | |
| 2514 | def get_queryset(self): |
| 2515 | return SliceCredential.select_by_user(self.request.user) |
| 2516 | |
| 2517 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2518 | obj = SliceCredential(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2519 | obj.caller = request.user |
| 2520 | if obj.can_update(request.user): |
| 2521 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 2522 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2523 | raise Exception("failed obj.can_update") |
| 2524 | |
| 2525 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 2526 | if (ret.status_code%100 != 200): |
| 2527 | raise Exception(ret.data) |
| 2528 | |
| 2529 | return ret |
| 2530 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2531 | |
| 2532 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2533 | queryset = SliceCredential.objects.select_related().all() |
| 2534 | serializer_class = SliceCredentialSerializer |
| 2535 | id_serializer_class = SliceCredentialIdSerializer |
| 2536 | |
| 2537 | def get_serializer_class(self): |
| 2538 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2539 | if (no_hyperlinks): |
| 2540 | return self.id_serializer_class |
| 2541 | else: |
| 2542 | return self.serializer_class |
| 2543 | |
| 2544 | def get_queryset(self): |
| 2545 | return SliceCredential.select_by_user(self.request.user) |
| 2546 | |
| 2547 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2548 | |
| 2549 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2550 | |
| 2551 | |
| 2552 | |
| 2553 | class SliverList(generics.ListCreateAPIView): |
| 2554 | queryset = Sliver.objects.select_related().all() |
| 2555 | serializer_class = SliverSerializer |
| 2556 | id_serializer_class = SliverIdSerializer |
| 2557 | filter_backends = (filters.DjangoFilterBackend,) |
| 2558 | 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',) |
| 2559 | |
| 2560 | def get_serializer_class(self): |
| 2561 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2562 | if (no_hyperlinks): |
| 2563 | return self.id_serializer_class |
| 2564 | else: |
| 2565 | return self.serializer_class |
| 2566 | |
| 2567 | def get_queryset(self): |
| 2568 | return Sliver.select_by_user(self.request.user) |
| 2569 | |
| 2570 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2571 | obj = Sliver(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2572 | obj.caller = request.user |
| 2573 | if obj.can_update(request.user): |
| 2574 | return super(SliverList, self).create(request, *args, **kwargs) |
| 2575 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2576 | raise Exception("failed obj.can_update") |
| 2577 | |
| 2578 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 2579 | if (ret.status_code%100 != 200): |
| 2580 | raise Exception(ret.data) |
| 2581 | |
| 2582 | return ret |
| 2583 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2584 | |
| 2585 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2586 | queryset = Sliver.objects.select_related().all() |
| 2587 | serializer_class = SliverSerializer |
| 2588 | id_serializer_class = SliverIdSerializer |
| 2589 | |
| 2590 | def get_serializer_class(self): |
| 2591 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2592 | if (no_hyperlinks): |
| 2593 | return self.id_serializer_class |
| 2594 | else: |
| 2595 | return self.serializer_class |
| 2596 | |
| 2597 | def get_queryset(self): |
| 2598 | return Sliver.select_by_user(self.request.user) |
| 2599 | |
| 2600 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2601 | |
| 2602 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2603 | |
| 2604 | |
| 2605 | |
| 2606 | class NodeList(generics.ListCreateAPIView): |
| 2607 | queryset = Node.objects.select_related().all() |
| 2608 | serializer_class = NodeSerializer |
| 2609 | id_serializer_class = NodeIdSerializer |
| 2610 | filter_backends = (filters.DjangoFilterBackend,) |
| 2611 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
| 2612 | |
| 2613 | def get_serializer_class(self): |
| 2614 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2615 | if (no_hyperlinks): |
| 2616 | return self.id_serializer_class |
| 2617 | else: |
| 2618 | return self.serializer_class |
| 2619 | |
| 2620 | def get_queryset(self): |
| 2621 | return Node.select_by_user(self.request.user) |
| 2622 | |
| 2623 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2624 | obj = Node(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2625 | obj.caller = request.user |
| 2626 | if obj.can_update(request.user): |
| 2627 | return super(NodeList, self).create(request, *args, **kwargs) |
| 2628 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2629 | raise Exception("failed obj.can_update") |
| 2630 | |
| 2631 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 2632 | if (ret.status_code%100 != 200): |
| 2633 | raise Exception(ret.data) |
| 2634 | |
| 2635 | return ret |
| 2636 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2637 | |
| 2638 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2639 | queryset = Node.objects.select_related().all() |
| 2640 | serializer_class = NodeSerializer |
| 2641 | id_serializer_class = NodeIdSerializer |
| 2642 | |
| 2643 | def get_serializer_class(self): |
| 2644 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2645 | if (no_hyperlinks): |
| 2646 | return self.id_serializer_class |
| 2647 | else: |
| 2648 | return self.serializer_class |
| 2649 | |
| 2650 | def get_queryset(self): |
| 2651 | return Node.select_by_user(self.request.user) |
| 2652 | |
| 2653 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2654 | |
| 2655 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2656 | |
| 2657 | |
| 2658 | |
| 2659 | class DashboardViewList(generics.ListCreateAPIView): |
| 2660 | queryset = DashboardView.objects.select_related().all() |
| 2661 | serializer_class = DashboardViewSerializer |
| 2662 | id_serializer_class = DashboardViewIdSerializer |
| 2663 | filter_backends = (filters.DjangoFilterBackend,) |
| 2664 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',) |
| 2665 | |
| 2666 | def get_serializer_class(self): |
| 2667 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2668 | if (no_hyperlinks): |
| 2669 | return self.id_serializer_class |
| 2670 | else: |
| 2671 | return self.serializer_class |
| 2672 | |
| 2673 | def get_queryset(self): |
| 2674 | return DashboardView.select_by_user(self.request.user) |
| 2675 | |
| 2676 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2677 | obj = DashboardView(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2678 | obj.caller = request.user |
| 2679 | if obj.can_update(request.user): |
| 2680 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 2681 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2682 | raise Exception("failed obj.can_update") |
| 2683 | |
| 2684 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 2685 | if (ret.status_code%100 != 200): |
| 2686 | raise Exception(ret.data) |
| 2687 | |
| 2688 | return ret |
| 2689 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2690 | |
| 2691 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2692 | queryset = DashboardView.objects.select_related().all() |
| 2693 | serializer_class = DashboardViewSerializer |
| 2694 | id_serializer_class = DashboardViewIdSerializer |
| 2695 | |
| 2696 | def get_serializer_class(self): |
| 2697 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2698 | if (no_hyperlinks): |
| 2699 | return self.id_serializer_class |
| 2700 | else: |
| 2701 | return self.serializer_class |
| 2702 | |
| 2703 | def get_queryset(self): |
| 2704 | return DashboardView.select_by_user(self.request.user) |
| 2705 | |
| 2706 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2707 | |
| 2708 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2709 | |
| 2710 | |
| 2711 | |
| 2712 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 2713 | queryset = ImageDeployments.objects.select_related().all() |
| 2714 | serializer_class = ImageDeploymentsSerializer |
| 2715 | id_serializer_class = ImageDeploymentsIdSerializer |
| 2716 | filter_backends = (filters.DjangoFilterBackend,) |
| 2717 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
| 2718 | |
| 2719 | def get_serializer_class(self): |
| 2720 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2721 | if (no_hyperlinks): |
| 2722 | return self.id_serializer_class |
| 2723 | else: |
| 2724 | return self.serializer_class |
| 2725 | |
| 2726 | def get_queryset(self): |
| 2727 | return ImageDeployments.select_by_user(self.request.user) |
| 2728 | |
| 2729 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2730 | obj = ImageDeployments(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2731 | obj.caller = request.user |
| 2732 | if obj.can_update(request.user): |
| 2733 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
| 2734 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2735 | raise Exception("failed obj.can_update") |
| 2736 | |
| 2737 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
| 2738 | if (ret.status_code%100 != 200): |
| 2739 | raise Exception(ret.data) |
| 2740 | |
| 2741 | return ret |
| 2742 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2743 | |
| 2744 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2745 | queryset = ImageDeployments.objects.select_related().all() |
| 2746 | serializer_class = ImageDeploymentsSerializer |
| 2747 | id_serializer_class = ImageDeploymentsIdSerializer |
| 2748 | |
| 2749 | def get_serializer_class(self): |
| 2750 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2751 | if (no_hyperlinks): |
| 2752 | return self.id_serializer_class |
| 2753 | else: |
| 2754 | return self.serializer_class |
| 2755 | |
| 2756 | def get_queryset(self): |
| 2757 | return ImageDeployments.select_by_user(self.request.user) |
| 2758 | |
| 2759 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2760 | |
| 2761 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2762 | |
| 2763 | |
| 2764 | |
| 2765 | class ReservedResourceList(generics.ListCreateAPIView): |
| 2766 | queryset = ReservedResource.objects.select_related().all() |
| 2767 | serializer_class = ReservedResourceSerializer |
| 2768 | id_serializer_class = ReservedResourceIdSerializer |
| 2769 | filter_backends = (filters.DjangoFilterBackend,) |
| 2770 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 2771 | |
| 2772 | def get_serializer_class(self): |
| 2773 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2774 | if (no_hyperlinks): |
| 2775 | return self.id_serializer_class |
| 2776 | else: |
| 2777 | return self.serializer_class |
| 2778 | |
| 2779 | def get_queryset(self): |
| 2780 | return ReservedResource.select_by_user(self.request.user) |
| 2781 | |
| 2782 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2783 | obj = ReservedResource(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2784 | obj.caller = request.user |
| 2785 | if obj.can_update(request.user): |
| 2786 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 2787 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2788 | raise Exception("failed obj.can_update") |
| 2789 | |
| 2790 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 2791 | if (ret.status_code%100 != 200): |
| 2792 | raise Exception(ret.data) |
| 2793 | |
| 2794 | return ret |
| 2795 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2796 | |
| 2797 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2798 | queryset = ReservedResource.objects.select_related().all() |
| 2799 | serializer_class = ReservedResourceSerializer |
| 2800 | id_serializer_class = ReservedResourceIdSerializer |
| 2801 | |
| 2802 | def get_serializer_class(self): |
| 2803 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2804 | if (no_hyperlinks): |
| 2805 | return self.id_serializer_class |
| 2806 | else: |
| 2807 | return self.serializer_class |
| 2808 | |
| 2809 | def get_queryset(self): |
| 2810 | return ReservedResource.select_by_user(self.request.user) |
| 2811 | |
| 2812 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2813 | |
| 2814 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2815 | |
| 2816 | |
| 2817 | |
| 2818 | class NetworkSliceList(generics.ListCreateAPIView): |
| 2819 | queryset = NetworkSlice.objects.select_related().all() |
| 2820 | serializer_class = NetworkSliceSerializer |
| 2821 | id_serializer_class = NetworkSliceIdSerializer |
| 2822 | filter_backends = (filters.DjangoFilterBackend,) |
| 2823 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 2824 | |
| 2825 | def get_serializer_class(self): |
| 2826 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2827 | if (no_hyperlinks): |
| 2828 | return self.id_serializer_class |
| 2829 | else: |
| 2830 | return self.serializer_class |
| 2831 | |
| 2832 | def get_queryset(self): |
| 2833 | return NetworkSlice.select_by_user(self.request.user) |
| 2834 | |
| 2835 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2836 | obj = NetworkSlice(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2837 | obj.caller = request.user |
| 2838 | if obj.can_update(request.user): |
| 2839 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 2840 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2841 | raise Exception("failed obj.can_update") |
| 2842 | |
| 2843 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 2844 | if (ret.status_code%100 != 200): |
| 2845 | raise Exception(ret.data) |
| 2846 | |
| 2847 | return ret |
| 2848 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2849 | |
| 2850 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2851 | queryset = NetworkSlice.objects.select_related().all() |
| 2852 | serializer_class = NetworkSliceSerializer |
| 2853 | id_serializer_class = NetworkSliceIdSerializer |
| 2854 | |
| 2855 | def get_serializer_class(self): |
| 2856 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2857 | if (no_hyperlinks): |
| 2858 | return self.id_serializer_class |
| 2859 | else: |
| 2860 | return self.serializer_class |
| 2861 | |
| 2862 | def get_queryset(self): |
| 2863 | return NetworkSlice.select_by_user(self.request.user) |
| 2864 | |
| 2865 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2866 | |
| 2867 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2868 | |
| 2869 | |
| 2870 | |
| 2871 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 2872 | queryset = UserDashboardView.objects.select_related().all() |
| 2873 | serializer_class = UserDashboardViewSerializer |
| 2874 | id_serializer_class = UserDashboardViewIdSerializer |
| 2875 | filter_backends = (filters.DjangoFilterBackend,) |
| 2876 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 2877 | |
| 2878 | def get_serializer_class(self): |
| 2879 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2880 | if (no_hyperlinks): |
| 2881 | return self.id_serializer_class |
| 2882 | else: |
| 2883 | return self.serializer_class |
| 2884 | |
| 2885 | def get_queryset(self): |
| 2886 | return UserDashboardView.select_by_user(self.request.user) |
| 2887 | |
| 2888 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2889 | obj = UserDashboardView(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2890 | obj.caller = request.user |
| 2891 | if obj.can_update(request.user): |
| 2892 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 2893 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2894 | raise Exception("failed obj.can_update") |
| 2895 | |
| 2896 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 2897 | if (ret.status_code%100 != 200): |
| 2898 | raise Exception(ret.data) |
| 2899 | |
| 2900 | return ret |
| 2901 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2902 | |
| 2903 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2904 | queryset = UserDashboardView.objects.select_related().all() |
| 2905 | serializer_class = UserDashboardViewSerializer |
| 2906 | id_serializer_class = UserDashboardViewIdSerializer |
| 2907 | |
| 2908 | def get_serializer_class(self): |
| 2909 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2910 | if (no_hyperlinks): |
| 2911 | return self.id_serializer_class |
| 2912 | else: |
| 2913 | return self.serializer_class |
| 2914 | |
| 2915 | def get_queryset(self): |
| 2916 | return UserDashboardView.select_by_user(self.request.user) |
| 2917 | |
| 2918 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2919 | |
| 2920 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2921 | |
| 2922 | |
| 2923 | |
| 2924 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 2925 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 2926 | serializer_class = PlanetStackPrivilegeSerializer |
| 2927 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 2928 | filter_backends = (filters.DjangoFilterBackend,) |
| 2929 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 2930 | |
| 2931 | def get_serializer_class(self): |
| 2932 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2933 | if (no_hyperlinks): |
| 2934 | return self.id_serializer_class |
| 2935 | else: |
| 2936 | return self.serializer_class |
| 2937 | |
| 2938 | def get_queryset(self): |
| 2939 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 2940 | |
| 2941 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2942 | obj = PlanetStackPrivilege(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2943 | obj.caller = request.user |
| 2944 | if obj.can_update(request.user): |
| 2945 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 2946 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2947 | raise Exception("failed obj.can_update") |
| 2948 | |
| 2949 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 2950 | if (ret.status_code%100 != 200): |
| 2951 | raise Exception(ret.data) |
| 2952 | |
| 2953 | return ret |
| 2954 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2955 | |
| 2956 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2957 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 2958 | serializer_class = PlanetStackPrivilegeSerializer |
| 2959 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 2960 | |
| 2961 | def get_serializer_class(self): |
| 2962 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2963 | if (no_hyperlinks): |
| 2964 | return self.id_serializer_class |
| 2965 | else: |
| 2966 | return self.serializer_class |
| 2967 | |
| 2968 | def get_queryset(self): |
| 2969 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 2970 | |
| 2971 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2972 | |
| 2973 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2974 | |
| 2975 | |
| 2976 | |
| 2977 | class UserList(generics.ListCreateAPIView): |
| 2978 | queryset = User.objects.select_related().all() |
| 2979 | serializer_class = UserSerializer |
| 2980 | id_serializer_class = UserIdSerializer |
| 2981 | filter_backends = (filters.DjangoFilterBackend,) |
| 2982 | 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',) |
| 2983 | |
| 2984 | def get_serializer_class(self): |
| 2985 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2986 | if (no_hyperlinks): |
| 2987 | return self.id_serializer_class |
| 2988 | else: |
| 2989 | return self.serializer_class |
| 2990 | |
| 2991 | def get_queryset(self): |
| 2992 | return User.select_by_user(self.request.user) |
| 2993 | |
| 2994 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2995 | obj = User(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2996 | obj.caller = request.user |
| 2997 | if obj.can_update(request.user): |
| 2998 | return super(UserList, self).create(request, *args, **kwargs) |
| 2999 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3000 | raise Exception("failed obj.can_update") |
| 3001 | |
| 3002 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 3003 | if (ret.status_code%100 != 200): |
| 3004 | raise Exception(ret.data) |
| 3005 | |
| 3006 | return ret |
| 3007 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3008 | |
| 3009 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3010 | queryset = User.objects.select_related().all() |
| 3011 | serializer_class = UserSerializer |
| 3012 | id_serializer_class = UserIdSerializer |
| 3013 | |
| 3014 | def get_serializer_class(self): |
| 3015 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3016 | if (no_hyperlinks): |
| 3017 | return self.id_serializer_class |
| 3018 | else: |
| 3019 | return self.serializer_class |
| 3020 | |
| 3021 | def get_queryset(self): |
| 3022 | return User.select_by_user(self.request.user) |
| 3023 | |
| 3024 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3025 | |
| 3026 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3027 | |
| 3028 | |
| 3029 | |
| 3030 | class DeploymentList(generics.ListCreateAPIView): |
| 3031 | queryset = Deployment.objects.select_related().all() |
| 3032 | serializer_class = DeploymentSerializer |
| 3033 | id_serializer_class = DeploymentIdSerializer |
| 3034 | filter_backends = (filters.DjangoFilterBackend,) |
| 3035 | 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',) |
| 3036 | |
| 3037 | def get_serializer_class(self): |
| 3038 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3039 | if (no_hyperlinks): |
| 3040 | return self.id_serializer_class |
| 3041 | else: |
| 3042 | return self.serializer_class |
| 3043 | |
| 3044 | def get_queryset(self): |
| 3045 | return Deployment.select_by_user(self.request.user) |
| 3046 | |
| 3047 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3048 | obj = Deployment(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3049 | obj.caller = request.user |
| 3050 | if obj.can_update(request.user): |
| 3051 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 3052 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3053 | raise Exception("failed obj.can_update") |
| 3054 | |
| 3055 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 3056 | if (ret.status_code%100 != 200): |
| 3057 | raise Exception(ret.data) |
| 3058 | |
| 3059 | return ret |
| 3060 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3061 | |
| 3062 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3063 | queryset = Deployment.objects.select_related().all() |
| 3064 | serializer_class = DeploymentSerializer |
| 3065 | id_serializer_class = DeploymentIdSerializer |
| 3066 | |
| 3067 | def get_serializer_class(self): |
| 3068 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3069 | if (no_hyperlinks): |
| 3070 | return self.id_serializer_class |
| 3071 | else: |
| 3072 | return self.serializer_class |
| 3073 | |
| 3074 | def get_queryset(self): |
| 3075 | return Deployment.select_by_user(self.request.user) |
| 3076 | |
| 3077 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3078 | |
| 3079 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3080 | |
| 3081 | |
| 3082 | |
| 3083 | class ReservationList(generics.ListCreateAPIView): |
| 3084 | queryset = Reservation.objects.select_related().all() |
| 3085 | serializer_class = ReservationSerializer |
| 3086 | id_serializer_class = ReservationIdSerializer |
| 3087 | filter_backends = (filters.DjangoFilterBackend,) |
| 3088 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 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 Reservation.select_by_user(self.request.user) |
| 3099 | |
| 3100 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3101 | obj = Reservation(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3102 | obj.caller = request.user |
| 3103 | if obj.can_update(request.user): |
| 3104 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 3105 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3106 | raise Exception("failed obj.can_update") |
| 3107 | |
| 3108 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 3109 | if (ret.status_code%100 != 200): |
| 3110 | raise Exception(ret.data) |
| 3111 | |
| 3112 | return ret |
| 3113 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3114 | |
| 3115 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3116 | queryset = Reservation.objects.select_related().all() |
| 3117 | serializer_class = ReservationSerializer |
| 3118 | id_serializer_class = ReservationIdSerializer |
| 3119 | |
| 3120 | def get_serializer_class(self): |
| 3121 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3122 | if (no_hyperlinks): |
| 3123 | return self.id_serializer_class |
| 3124 | else: |
| 3125 | return self.serializer_class |
| 3126 | |
| 3127 | def get_queryset(self): |
| 3128 | return Reservation.select_by_user(self.request.user) |
| 3129 | |
| 3130 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3131 | |
| 3132 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3133 | |
| 3134 | |
| 3135 | |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 3136 | class SliceDeploymentList(generics.ListCreateAPIView): |
| 3137 | queryset = SliceDeployment.objects.select_related().all() |
| 3138 | serializer_class = SliceDeploymentSerializer |
| 3139 | id_serializer_class = SliceDeploymentIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3140 | filter_backends = (filters.DjangoFilterBackend,) |
| 3141 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
| 3142 | |
| 3143 | def get_serializer_class(self): |
| 3144 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3145 | if (no_hyperlinks): |
| 3146 | return self.id_serializer_class |
| 3147 | else: |
| 3148 | return self.serializer_class |
| 3149 | |
| 3150 | def get_queryset(self): |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 3151 | return SliceDeployment.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3152 | |
| 3153 | def create(self, request, *args, **kwargs): |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 3154 | obj = SliceDeployment(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3155 | obj.caller = request.user |
| 3156 | if obj.can_update(request.user): |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 3157 | return super(SliceDeploymentList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3158 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3159 | raise Exception("failed obj.can_update") |
| 3160 | |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 3161 | ret = super(SliceDeploymentList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3162 | if (ret.status_code%100 != 200): |
| 3163 | raise Exception(ret.data) |
| 3164 | |
| 3165 | return ret |
| 3166 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3167 | |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 3168 | class SliceDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3169 | queryset = SliceDeployment.objects.select_related().all() |
| 3170 | serializer_class = SliceDeploymentSerializer |
| 3171 | id_serializer_class = SliceDeploymentIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3172 | |
| 3173 | def get_serializer_class(self): |
| 3174 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3175 | if (no_hyperlinks): |
| 3176 | return self.id_serializer_class |
| 3177 | else: |
| 3178 | return self.serializer_class |
| 3179 | |
| 3180 | def get_queryset(self): |
Sapan Bhatia | 7a8b7e9 | 2014-11-11 21:43:31 -0500 | [diff] [blame^] | 3181 | return SliceDeployment.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3182 | |
| 3183 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3184 | |
| 3185 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3186 | |
| 3187 | |
| 3188 | |
| 3189 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 3190 | queryset = SitePrivilege.objects.select_related().all() |
| 3191 | serializer_class = SitePrivilegeSerializer |
| 3192 | id_serializer_class = SitePrivilegeIdSerializer |
| 3193 | filter_backends = (filters.DjangoFilterBackend,) |
| 3194 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 3195 | |
| 3196 | def get_serializer_class(self): |
| 3197 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3198 | if (no_hyperlinks): |
| 3199 | return self.id_serializer_class |
| 3200 | else: |
| 3201 | return self.serializer_class |
| 3202 | |
| 3203 | def get_queryset(self): |
| 3204 | return SitePrivilege.select_by_user(self.request.user) |
| 3205 | |
| 3206 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3207 | obj = SitePrivilege(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3208 | obj.caller = request.user |
| 3209 | if obj.can_update(request.user): |
| 3210 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 3211 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3212 | raise Exception("failed obj.can_update") |
| 3213 | |
| 3214 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 3215 | if (ret.status_code%100 != 200): |
| 3216 | raise Exception(ret.data) |
| 3217 | |
| 3218 | return ret |
| 3219 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3220 | |
| 3221 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3222 | queryset = SitePrivilege.objects.select_related().all() |
| 3223 | serializer_class = SitePrivilegeSerializer |
| 3224 | id_serializer_class = SitePrivilegeIdSerializer |
| 3225 | |
| 3226 | def get_serializer_class(self): |
| 3227 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3228 | if (no_hyperlinks): |
| 3229 | return self.id_serializer_class |
| 3230 | else: |
| 3231 | return self.serializer_class |
| 3232 | |
| 3233 | def get_queryset(self): |
| 3234 | return SitePrivilege.select_by_user(self.request.user) |
| 3235 | |
| 3236 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3237 | |
| 3238 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3239 | |
| 3240 | |
| 3241 | |
| 3242 | class PlanetStackList(generics.ListCreateAPIView): |
| 3243 | queryset = PlanetStack.objects.select_related().all() |
| 3244 | serializer_class = PlanetStackSerializer |
| 3245 | id_serializer_class = PlanetStackIdSerializer |
| 3246 | filter_backends = (filters.DjangoFilterBackend,) |
| 3247 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
| 3248 | |
| 3249 | def get_serializer_class(self): |
| 3250 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3251 | if (no_hyperlinks): |
| 3252 | return self.id_serializer_class |
| 3253 | else: |
| 3254 | return self.serializer_class |
| 3255 | |
| 3256 | def get_queryset(self): |
| 3257 | return PlanetStack.select_by_user(self.request.user) |
| 3258 | |
| 3259 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3260 | obj = PlanetStack(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3261 | obj.caller = request.user |
| 3262 | if obj.can_update(request.user): |
| 3263 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
| 3264 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3265 | raise Exception("failed obj.can_update") |
| 3266 | |
| 3267 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
| 3268 | if (ret.status_code%100 != 200): |
| 3269 | raise Exception(ret.data) |
| 3270 | |
| 3271 | return ret |
| 3272 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3273 | |
| 3274 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3275 | queryset = PlanetStack.objects.select_related().all() |
| 3276 | serializer_class = PlanetStackSerializer |
| 3277 | id_serializer_class = PlanetStackIdSerializer |
| 3278 | |
| 3279 | def get_serializer_class(self): |
| 3280 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3281 | if (no_hyperlinks): |
| 3282 | return self.id_serializer_class |
| 3283 | else: |
| 3284 | return self.serializer_class |
| 3285 | |
| 3286 | def get_queryset(self): |
| 3287 | return PlanetStack.select_by_user(self.request.user) |
| 3288 | |
| 3289 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3290 | |
| 3291 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3292 | |
| 3293 | |
| 3294 | |
| 3295 | class UserDeploymentsList(generics.ListCreateAPIView): |
| 3296 | queryset = UserDeployments.objects.select_related().all() |
| 3297 | serializer_class = UserDeploymentsSerializer |
| 3298 | id_serializer_class = UserDeploymentsIdSerializer |
| 3299 | filter_backends = (filters.DjangoFilterBackend,) |
| 3300 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
| 3301 | |
| 3302 | def get_serializer_class(self): |
| 3303 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3304 | if (no_hyperlinks): |
| 3305 | return self.id_serializer_class |
| 3306 | else: |
| 3307 | return self.serializer_class |
| 3308 | |
| 3309 | def get_queryset(self): |
| 3310 | return UserDeployments.select_by_user(self.request.user) |
| 3311 | |
| 3312 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3313 | obj = UserDeployments(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3314 | obj.caller = request.user |
| 3315 | if obj.can_update(request.user): |
| 3316 | return super(UserDeploymentsList, self).create(request, *args, **kwargs) |
| 3317 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3318 | raise Exception("failed obj.can_update") |
| 3319 | |
| 3320 | ret = super(UserDeploymentsList, self).create(request, *args, **kwargs) |
| 3321 | if (ret.status_code%100 != 200): |
| 3322 | raise Exception(ret.data) |
| 3323 | |
| 3324 | return ret |
| 3325 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3326 | |
| 3327 | class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3328 | queryset = UserDeployments.objects.select_related().all() |
| 3329 | serializer_class = UserDeploymentsSerializer |
| 3330 | id_serializer_class = UserDeploymentsIdSerializer |
| 3331 | |
| 3332 | def get_serializer_class(self): |
| 3333 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3334 | if (no_hyperlinks): |
| 3335 | return self.id_serializer_class |
| 3336 | else: |
| 3337 | return self.serializer_class |
| 3338 | |
| 3339 | def get_queryset(self): |
| 3340 | return UserDeployments.select_by_user(self.request.user) |
| 3341 | |
| 3342 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3343 | |
| 3344 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3345 | |
| 3346 | |
| 3347 | |
| 3348 | class AccountList(generics.ListCreateAPIView): |
| 3349 | queryset = Account.objects.select_related().all() |
| 3350 | serializer_class = AccountSerializer |
| 3351 | id_serializer_class = AccountIdSerializer |
| 3352 | filter_backends = (filters.DjangoFilterBackend,) |
| 3353 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 3354 | |
| 3355 | def get_serializer_class(self): |
| 3356 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3357 | if (no_hyperlinks): |
| 3358 | return self.id_serializer_class |
| 3359 | else: |
| 3360 | return self.serializer_class |
| 3361 | |
| 3362 | def get_queryset(self): |
| 3363 | return Account.select_by_user(self.request.user) |
| 3364 | |
| 3365 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3366 | obj = Account(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3367 | obj.caller = request.user |
| 3368 | if obj.can_update(request.user): |
| 3369 | return super(AccountList, self).create(request, *args, **kwargs) |
| 3370 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3371 | raise Exception("failed obj.can_update") |
| 3372 | |
| 3373 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 3374 | if (ret.status_code%100 != 200): |
| 3375 | raise Exception(ret.data) |
| 3376 | |
| 3377 | return ret |
| 3378 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3379 | |
| 3380 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3381 | queryset = Account.objects.select_related().all() |
| 3382 | serializer_class = AccountSerializer |
| 3383 | id_serializer_class = AccountIdSerializer |
| 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 Account.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 NetworkParameterTypeList(generics.ListCreateAPIView): |
| 3402 | queryset = NetworkParameterType.objects.select_related().all() |
| 3403 | serializer_class = NetworkParameterTypeSerializer |
| 3404 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 3405 | filter_backends = (filters.DjangoFilterBackend,) |
| 3406 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 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 NetworkParameterType.select_by_user(self.request.user) |
| 3417 | |
| 3418 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3419 | obj = NetworkParameterType(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3420 | obj.caller = request.user |
| 3421 | if obj.can_update(request.user): |
| 3422 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 3423 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3424 | raise Exception("failed obj.can_update") |
| 3425 | |
| 3426 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 3427 | if (ret.status_code%100 != 200): |
| 3428 | raise Exception(ret.data) |
| 3429 | |
| 3430 | return ret |
| 3431 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3432 | |
| 3433 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3434 | queryset = NetworkParameterType.objects.select_related().all() |
| 3435 | serializer_class = NetworkParameterTypeSerializer |
| 3436 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 3437 | |
| 3438 | def get_serializer_class(self): |
| 3439 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3440 | if (no_hyperlinks): |
| 3441 | return self.id_serializer_class |
| 3442 | else: |
| 3443 | return self.serializer_class |
| 3444 | |
| 3445 | def get_queryset(self): |
| 3446 | return NetworkParameterType.select_by_user(self.request.user) |
| 3447 | |
| 3448 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3449 | |
| 3450 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3451 | |
| 3452 | |
| 3453 | |
| 3454 | class SiteCredentialList(generics.ListCreateAPIView): |
| 3455 | queryset = SiteCredential.objects.select_related().all() |
| 3456 | serializer_class = SiteCredentialSerializer |
| 3457 | id_serializer_class = SiteCredentialIdSerializer |
| 3458 | filter_backends = (filters.DjangoFilterBackend,) |
| 3459 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 3460 | |
| 3461 | def get_serializer_class(self): |
| 3462 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3463 | if (no_hyperlinks): |
| 3464 | return self.id_serializer_class |
| 3465 | else: |
| 3466 | return self.serializer_class |
| 3467 | |
| 3468 | def get_queryset(self): |
| 3469 | return SiteCredential.select_by_user(self.request.user) |
| 3470 | |
| 3471 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3472 | obj = SiteCredential(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3473 | obj.caller = request.user |
| 3474 | if obj.can_update(request.user): |
| 3475 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 3476 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3477 | raise Exception("failed obj.can_update") |
| 3478 | |
| 3479 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 3480 | if (ret.status_code%100 != 200): |
| 3481 | raise Exception(ret.data) |
| 3482 | |
| 3483 | return ret |
| 3484 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3485 | |
| 3486 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3487 | queryset = SiteCredential.objects.select_related().all() |
| 3488 | serializer_class = SiteCredentialSerializer |
| 3489 | id_serializer_class = SiteCredentialIdSerializer |
| 3490 | |
| 3491 | def get_serializer_class(self): |
| 3492 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3493 | if (no_hyperlinks): |
| 3494 | return self.id_serializer_class |
| 3495 | else: |
| 3496 | return self.serializer_class |
| 3497 | |
| 3498 | def get_queryset(self): |
| 3499 | return SiteCredential.select_by_user(self.request.user) |
| 3500 | |
| 3501 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3502 | |
| 3503 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3504 | |
| 3505 | |
| 3506 | |
| 3507 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 3508 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 3509 | serializer_class = DeploymentPrivilegeSerializer |
| 3510 | id_serializer_class = DeploymentPrivilegeIdSerializer |
| 3511 | filter_backends = (filters.DjangoFilterBackend,) |
| 3512 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 3513 | |
| 3514 | def get_serializer_class(self): |
| 3515 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3516 | if (no_hyperlinks): |
| 3517 | return self.id_serializer_class |
| 3518 | else: |
| 3519 | return self.serializer_class |
| 3520 | |
| 3521 | def get_queryset(self): |
| 3522 | return DeploymentPrivilege.select_by_user(self.request.user) |
| 3523 | |
| 3524 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3525 | obj = DeploymentPrivilege(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3526 | obj.caller = request.user |
| 3527 | if obj.can_update(request.user): |
| 3528 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
| 3529 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3530 | raise Exception("failed obj.can_update") |
| 3531 | |
| 3532 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
| 3533 | if (ret.status_code%100 != 200): |
| 3534 | raise Exception(ret.data) |
| 3535 | |
| 3536 | return ret |
| 3537 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3538 | |
| 3539 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3540 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 3541 | serializer_class = DeploymentPrivilegeSerializer |
| 3542 | id_serializer_class = DeploymentPrivilegeIdSerializer |
| 3543 | |
| 3544 | def get_serializer_class(self): |
| 3545 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3546 | if (no_hyperlinks): |
| 3547 | return self.id_serializer_class |
| 3548 | else: |
| 3549 | return self.serializer_class |
| 3550 | |
| 3551 | def get_queryset(self): |
| 3552 | return DeploymentPrivilege.select_by_user(self.request.user) |
| 3553 | |
| 3554 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3555 | |
| 3556 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3557 | |
| 3558 | |
| 3559 | |
| 3560 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 3561 | queryset = DeploymentRole.objects.select_related().all() |
| 3562 | serializer_class = DeploymentRoleSerializer |
| 3563 | id_serializer_class = DeploymentRoleIdSerializer |
| 3564 | filter_backends = (filters.DjangoFilterBackend,) |
| 3565 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3566 | |
| 3567 | def get_serializer_class(self): |
| 3568 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3569 | if (no_hyperlinks): |
| 3570 | return self.id_serializer_class |
| 3571 | else: |
| 3572 | return self.serializer_class |
| 3573 | |
| 3574 | def get_queryset(self): |
| 3575 | return DeploymentRole.select_by_user(self.request.user) |
| 3576 | |
| 3577 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3578 | obj = DeploymentRole(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3579 | obj.caller = request.user |
| 3580 | if obj.can_update(request.user): |
| 3581 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
| 3582 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3583 | raise Exception("failed obj.can_update") |
| 3584 | |
| 3585 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
| 3586 | if (ret.status_code%100 != 200): |
| 3587 | raise Exception(ret.data) |
| 3588 | |
| 3589 | return ret |
| 3590 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3591 | |
| 3592 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3593 | queryset = DeploymentRole.objects.select_related().all() |
| 3594 | serializer_class = DeploymentRoleSerializer |
| 3595 | id_serializer_class = DeploymentRoleIdSerializer |
| 3596 | |
| 3597 | def get_serializer_class(self): |
| 3598 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3599 | if (no_hyperlinks): |
| 3600 | return self.id_serializer_class |
| 3601 | else: |
| 3602 | return self.serializer_class |
| 3603 | |
| 3604 | def get_queryset(self): |
| 3605 | return DeploymentRole.select_by_user(self.request.user) |
| 3606 | |
| 3607 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3608 | |
| 3609 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3610 | |
| 3611 | |
| 3612 | |
| 3613 | class UserCredentialList(generics.ListCreateAPIView): |
| 3614 | queryset = UserCredential.objects.select_related().all() |
| 3615 | serializer_class = UserCredentialSerializer |
| 3616 | id_serializer_class = UserCredentialIdSerializer |
| 3617 | filter_backends = (filters.DjangoFilterBackend,) |
| 3618 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 3619 | |
| 3620 | def get_serializer_class(self): |
| 3621 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3622 | if (no_hyperlinks): |
| 3623 | return self.id_serializer_class |
| 3624 | else: |
| 3625 | return self.serializer_class |
| 3626 | |
| 3627 | def get_queryset(self): |
| 3628 | return UserCredential.select_by_user(self.request.user) |
| 3629 | |
| 3630 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3631 | obj = UserCredential(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3632 | obj.caller = request.user |
| 3633 | if obj.can_update(request.user): |
| 3634 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 3635 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3636 | raise Exception("failed obj.can_update") |
| 3637 | |
| 3638 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 3639 | if (ret.status_code%100 != 200): |
| 3640 | raise Exception(ret.data) |
| 3641 | |
| 3642 | return ret |
| 3643 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3644 | |
| 3645 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3646 | queryset = UserCredential.objects.select_related().all() |
| 3647 | serializer_class = UserCredentialSerializer |
| 3648 | id_serializer_class = UserCredentialIdSerializer |
| 3649 | |
| 3650 | def get_serializer_class(self): |
| 3651 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3652 | if (no_hyperlinks): |
| 3653 | return self.id_serializer_class |
| 3654 | else: |
| 3655 | return self.serializer_class |
| 3656 | |
| 3657 | def get_queryset(self): |
| 3658 | return UserCredential.select_by_user(self.request.user) |
| 3659 | |
| 3660 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3661 | |
| 3662 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3663 | |
| 3664 | |
| 3665 | |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 3666 | class SiteDeploymentList(generics.ListCreateAPIView): |
| 3667 | queryset = SiteDeployment.objects.select_related().all() |
| 3668 | serializer_class = SiteDeploymentSerializer |
| 3669 | id_serializer_class = SiteDeploymentIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3670 | filter_backends = (filters.DjangoFilterBackend,) |
| 3671 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
| 3672 | |
| 3673 | def get_serializer_class(self): |
| 3674 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3675 | if (no_hyperlinks): |
| 3676 | return self.id_serializer_class |
| 3677 | else: |
| 3678 | return self.serializer_class |
| 3679 | |
| 3680 | def get_queryset(self): |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 3681 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3682 | |
| 3683 | def create(self, request, *args, **kwargs): |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 3684 | obj = SiteDeployment(**request.DATA) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3685 | obj.caller = request.user |
| 3686 | if obj.can_update(request.user): |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 3687 | return super(SiteDeploymentList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3688 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3689 | raise Exception("failed obj.can_update") |
| 3690 | |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 3691 | ret = super(SiteDeploymentList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3692 | if (ret.status_code%100 != 200): |
| 3693 | raise Exception(ret.data) |
| 3694 | |
| 3695 | return ret |
| 3696 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3697 | |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 3698 | class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3699 | queryset = SiteDeployment.objects.select_related().all() |
| 3700 | serializer_class = SiteDeploymentSerializer |
| 3701 | id_serializer_class = SiteDeploymentIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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): |
Sapan Bhatia | 6d21da3 | 2014-11-11 21:41:12 -0500 | [diff] [blame] | 3711 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3712 | |
| 3713 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3714 | |
| 3715 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3716 | |
| 3717 | |
| 3718 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3719 | class SliceTagList(generics.ListCreateAPIView): |
| 3720 | queryset = SliceTag.objects.select_related().all() |
| 3721 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3722 | id_serializer_class = SliceTagIdSerializer |
| 3723 | filter_backends = (filters.DjangoFilterBackend,) |
| 3724 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 3725 | |
| 3726 | def get_serializer_class(self): |
| 3727 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3728 | if (no_hyperlinks): |
| 3729 | return self.id_serializer_class |
| 3730 | else: |
| 3731 | return self.serializer_class |
| 3732 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3733 | def get_queryset(self): |
| 3734 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3735 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3736 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3737 | obj = SliceTag(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3738 | obj.caller = request.user |
| 3739 | if obj.can_update(request.user): |
| 3740 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 3741 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3742 | raise Exception("failed obj.can_update") |
| 3743 | |
| 3744 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 3745 | if (ret.status_code%100 != 200): |
| 3746 | raise Exception(ret.data) |
| 3747 | |
| 3748 | return ret |
| 3749 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3750 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3751 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3752 | queryset = SliceTag.objects.select_related().all() |
| 3753 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3754 | id_serializer_class = SliceTagIdSerializer |
| 3755 | |
| 3756 | def get_serializer_class(self): |
| 3757 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3758 | if (no_hyperlinks): |
| 3759 | return self.id_serializer_class |
| 3760 | else: |
| 3761 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3762 | |
| 3763 | def get_queryset(self): |
| 3764 | return SliceTag.select_by_user(self.request.user) |
| 3765 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3766 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3767 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3768 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3769 | |
| 3770 | |
| 3771 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3772 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 3773 | queryset = NetworkTemplate.objects.select_related().all() |
| 3774 | serializer_class = NetworkTemplateSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3775 | id_serializer_class = NetworkTemplateIdSerializer |
| 3776 | filter_backends = (filters.DjangoFilterBackend,) |
| 3777 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',) |
| 3778 | |
| 3779 | def get_serializer_class(self): |
| 3780 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3781 | if (no_hyperlinks): |
| 3782 | return self.id_serializer_class |
| 3783 | else: |
| 3784 | return self.serializer_class |
| 3785 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3786 | def get_queryset(self): |
| 3787 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3788 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3789 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3790 | obj = NetworkTemplate(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3791 | obj.caller = request.user |
| 3792 | if obj.can_update(request.user): |
| 3793 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 3794 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3795 | raise Exception("failed obj.can_update") |
| 3796 | |
| 3797 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 3798 | if (ret.status_code%100 != 200): |
| 3799 | raise Exception(ret.data) |
| 3800 | |
| 3801 | return ret |
| 3802 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3803 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3804 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3805 | queryset = NetworkTemplate.objects.select_related().all() |
| 3806 | serializer_class = NetworkTemplateSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3807 | id_serializer_class = NetworkTemplateIdSerializer |
| 3808 | |
| 3809 | def get_serializer_class(self): |
| 3810 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3811 | if (no_hyperlinks): |
| 3812 | return self.id_serializer_class |
| 3813 | else: |
| 3814 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3815 | |
| 3816 | def get_queryset(self): |
| 3817 | return NetworkTemplate.select_by_user(self.request.user) |
| 3818 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3819 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3820 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3821 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3822 | |
| 3823 | |
| 3824 | |
| 3825 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3826 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3827 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3828 | id_serializer_class = RouterIdSerializer |
| 3829 | filter_backends = (filters.DjangoFilterBackend,) |
| 3830 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',) |
| 3831 | |
| 3832 | def get_serializer_class(self): |
| 3833 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3834 | if (no_hyperlinks): |
| 3835 | return self.id_serializer_class |
| 3836 | else: |
| 3837 | return self.serializer_class |
| 3838 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3839 | def get_queryset(self): |
| 3840 | return Router.select_by_user(self.request.user) |
| 3841 | |
| 3842 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3843 | obj = Router(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3844 | obj.caller = request.user |
| 3845 | if obj.can_update(request.user): |
| 3846 | return super(RouterList, self).create(request, *args, **kwargs) |
| 3847 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3848 | raise Exception("failed obj.can_update") |
| 3849 | |
| 3850 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 3851 | if (ret.status_code%100 != 200): |
| 3852 | raise Exception(ret.data) |
| 3853 | |
| 3854 | return ret |
| 3855 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3856 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3857 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3858 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3859 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3860 | id_serializer_class = RouterIdSerializer |
| 3861 | |
| 3862 | def get_serializer_class(self): |
| 3863 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3864 | if (no_hyperlinks): |
| 3865 | return self.id_serializer_class |
| 3866 | else: |
| 3867 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3868 | |
| 3869 | def get_queryset(self): |
| 3870 | return Router.select_by_user(self.request.user) |
| 3871 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3872 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3873 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3874 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3875 | |
| 3876 | |
| 3877 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3878 | class ServiceResourceList(generics.ListCreateAPIView): |
| 3879 | queryset = ServiceResource.objects.select_related().all() |
| 3880 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3881 | id_serializer_class = ServiceResourceIdSerializer |
| 3882 | filter_backends = (filters.DjangoFilterBackend,) |
| 3883 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 3884 | |
| 3885 | def get_serializer_class(self): |
| 3886 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3887 | if (no_hyperlinks): |
| 3888 | return self.id_serializer_class |
| 3889 | else: |
| 3890 | return self.serializer_class |
| 3891 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3892 | def get_queryset(self): |
| 3893 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3894 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3895 | def create(self, request, *args, **kwargs): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3896 | obj = ServiceResource(**request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3897 | obj.caller = request.user |
| 3898 | if obj.can_update(request.user): |
| 3899 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 3900 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3901 | raise Exception("failed obj.can_update") |
| 3902 | |
| 3903 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 3904 | if (ret.status_code%100 != 200): |
| 3905 | raise Exception(ret.data) |
| 3906 | |
| 3907 | return ret |
| 3908 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3909 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3910 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3911 | queryset = ServiceResource.objects.select_related().all() |
| 3912 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3913 | id_serializer_class = ServiceResourceIdSerializer |
| 3914 | |
| 3915 | def get_serializer_class(self): |
| 3916 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3917 | if (no_hyperlinks): |
| 3918 | return self.id_serializer_class |
| 3919 | else: |
| 3920 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3921 | |
| 3922 | def get_queryset(self): |
| 3923 | return ServiceResource.select_by_user(self.request.user) |
| 3924 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3925 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3926 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3927 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3928 | |
| 3929 | |
| 3930 | |