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