Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1 | from rest_framework.decorators import api_view |
| 2 | from rest_framework.response import Response |
| 3 | from rest_framework.reverse import reverse |
| 4 | from rest_framework import serializers |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5 | from rest_framework import generics |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 7 | from core.models import * |
| 8 | from django.forms import widgets |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 9 | from rest_framework import filters |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 10 | |
| 11 | """ |
| 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 |
| 21 | |
| 22 | TODO: Deal with subnets |
| 23 | """ |
| 24 | |
| 25 | # Based on api_root.py |
| 26 | |
| 27 | @api_view(['GET']) |
| 28 | def api_root(request, format=None): |
| 29 | return Response({ |
| 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), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 37 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 38 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 39 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 40 | 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format), |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 41 | 'flavors': reverse('flavor-list', request=request, format=format), |
| 42 | 'projects': reverse('project-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 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), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 47 | 'payments': reverse('payment-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 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), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 51 | 'siteroles': reverse('siterole-list', request=request, format=format), |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 52 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 53 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 54 | 'nodes': reverse('node-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 55 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
| 56 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 57 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 58 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 59 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 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), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 64 | 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 65 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 66 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 67 | 'userdeploymentses': reverse('userdeployments-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 68 | 'accounts': reverse('account-list', request=request, format=format), |
| 69 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 70 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 71 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 72 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 73 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
| 74 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 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 | |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 87 | id = serializers.Field() |
| 88 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 89 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 90 | model = ServiceAttribute |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 91 | fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 92 | |
| 93 | class ServiceAttributeIdSerializer(serializers.ModelSerializer): |
| 94 | id = serializers.Field() |
| 95 | |
| 96 | class Meta: |
| 97 | model = ServiceAttribute |
| 98 | fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 99 | |
| 100 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 101 | |
| 102 | |
| 103 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
| 104 | id = serializers.Field() |
| 105 | |
| 106 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 107 | model = Image |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 108 | fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
| 109 | |
| 110 | class ImageIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 121 | id = serializers.Field() |
| 122 | |
| 123 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 124 | model = NetworkParameter |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 125 | fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 126 | |
| 127 | class NetworkParameterIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 133 | |
| 134 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 135 | |
| 136 | |
| 137 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
| 138 | id = serializers.Field() |
| 139 | |
| 140 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 141 | model = Site |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 142 | fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
| 143 | |
| 144 | class SiteIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 155 | id = serializers.Field() |
| 156 | |
| 157 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 158 | model = SliceRole |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 159 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 160 | |
| 161 | class SliceRoleIdSerializer(serializers.ModelSerializer): |
| 162 | id = serializers.Field() |
| 163 | |
| 164 | class Meta: |
| 165 | model = SliceRole |
| 166 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 167 | |
| 168 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 169 | |
| 170 | |
| 171 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
| 172 | id = serializers.Field() |
| 173 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 174 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 175 | model = Tag |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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): |
| 179 | id = serializers.Field() |
| 180 | |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 181 | class Meta: |
| 182 | model = Tag |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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): |
| 189 | id = serializers.Field() |
| 190 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 191 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 192 | model = Invoice |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 193 | fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 194 | |
| 195 | class InvoiceIdSerializer(serializers.ModelSerializer): |
| 196 | id = serializers.Field() |
| 197 | |
| 198 | class Meta: |
| 199 | model = Invoice |
| 200 | fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 206 | id = serializers.Field() |
| 207 | |
| 208 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 209 | model = SlicePrivilege |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 210 | fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 211 | |
| 212 | class SlicePrivilegeIdSerializer(serializers.ModelSerializer): |
| 213 | id = serializers.Field() |
| 214 | |
| 215 | class Meta: |
| 216 | model = SlicePrivilege |
| 217 | fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 218 | |
| 219 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 220 | |
| 221 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 222 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
| 223 | id = serializers.Field() |
| 224 | |
| 225 | class Meta: |
| 226 | model = PlanetStackRole |
| 227 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 228 | |
| 229 | class PlanetStackRoleIdSerializer(serializers.ModelSerializer): |
| 230 | id = serializers.Field() |
| 231 | |
| 232 | class Meta: |
| 233 | model = PlanetStackRole |
| 234 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 239 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
| 240 | id = serializers.Field() |
| 241 | |
| 242 | class Meta: |
| 243 | model = NetworkSliver |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 244 | fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 245 | |
| 246 | class NetworkSliverIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 252 | |
| 253 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 254 | |
| 255 | |
| 256 | class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 257 | id = serializers.Field() |
| 258 | |
| 259 | class Meta: |
| 260 | model = NetworkDeployments |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 261 | fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
| 262 | |
| 263 | class NetworkDeploymentsIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 269 | |
| 270 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 271 | |
| 272 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 273 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
| 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',) |
| 279 | |
| 280 | class FlavorIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
| 291 | id = serializers.Field() |
| 292 | |
| 293 | class Meta: |
| 294 | model = Project |
| 295 | fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 296 | |
| 297 | class ProjectIdSerializer(serializers.ModelSerializer): |
| 298 | id = serializers.Field() |
| 299 | |
| 300 | class Meta: |
| 301 | model = Project |
| 302 | fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 307 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
| 308 | id = serializers.Field() |
| 309 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 310 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 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 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 325 | |
| 326 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 327 | model = Slice |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 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',) |
| 329 | |
| 330 | class SliceIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 352 | |
| 353 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 354 | |
| 355 | |
| 356 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
| 357 | id = serializers.Field() |
| 358 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 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 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 375 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 376 | model = Network |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 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',) |
| 378 | |
| 379 | class NetworkIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 401 | |
| 402 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 403 | |
| 404 | |
| 405 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
| 406 | id = serializers.Field() |
| 407 | |
| 408 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 409 | model = Service |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 410 | fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 411 | |
| 412 | class ServiceIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 423 | id = serializers.Field() |
| 424 | |
| 425 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 426 | model = ServiceClass |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 427 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 428 | |
| 429 | class ServiceClassIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 440 | id = serializers.Field() |
| 441 | |
| 442 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 443 | model = Payment |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 444 | fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 445 | |
| 446 | class PaymentIdSerializer(serializers.ModelSerializer): |
| 447 | id = serializers.Field() |
| 448 | |
| 449 | class Meta: |
| 450 | model = Payment |
| 451 | fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 452 | |
| 453 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 454 | |
| 455 | |
| 456 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
| 457 | id = serializers.Field() |
| 458 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 459 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 460 | model = Charge |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 461 | fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 462 | |
| 463 | class ChargeIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 469 | |
| 470 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 471 | |
| 472 | |
| 473 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
| 474 | id = serializers.Field() |
| 475 | |
| 476 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 477 | model = Role |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 478 | fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 479 | |
| 480 | class RoleIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 491 | id = serializers.Field() |
| 492 | |
| 493 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 494 | model = UsableObject |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 495 | fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 496 | |
| 497 | class UsableObjectIdSerializer(serializers.ModelSerializer): |
| 498 | id = serializers.Field() |
| 499 | |
| 500 | class Meta: |
| 501 | model = UsableObject |
| 502 | fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 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): |
| 508 | id = serializers.Field() |
| 509 | |
| 510 | class Meta: |
| 511 | model = SiteRole |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 512 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 513 | |
| 514 | class SiteRoleIdSerializer(serializers.ModelSerializer): |
| 515 | id = serializers.Field() |
| 516 | |
| 517 | class Meta: |
| 518 | model = SiteRole |
| 519 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 520 | |
| 521 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 522 | |
| 523 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 524 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
| 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',) |
| 530 | |
| 531 | class SliceCredentialIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 541 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
| 542 | id = serializers.Field() |
| 543 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 544 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 545 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 546 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 547 | |
| 548 | |
| 549 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 550 | |
| 551 | |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 552 | class Meta: |
| 553 | model = Sliver |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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): |
| 557 | id = serializers.Field() |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 558 | |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 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') |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 565 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 566 | |
| 567 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 568 | model = Sliver |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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): |
| 575 | id = serializers.Field() |
| 576 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 577 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 578 | model = Node |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 579 | fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
| 580 | |
| 581 | class NodeIdSerializer(serializers.ModelSerializer): |
| 582 | id = serializers.Field() |
| 583 | |
| 584 | class Meta: |
| 585 | model = Node |
| 586 | fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 592 | id = serializers.Field() |
| 593 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 594 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 595 | model = DashboardView |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 596 | fields = ('id','created','updated','enacted','backend_status','deleted','name','url',) |
| 597 | |
| 598 | class DashboardViewIdSerializer(serializers.ModelSerializer): |
| 599 | id = serializers.Field() |
| 600 | |
| 601 | class Meta: |
| 602 | model = DashboardView |
| 603 | fields = ('id','created','updated','enacted','backend_status','deleted','name','url',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 609 | id = serializers.Field() |
| 610 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 611 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 612 | model = ImageDeployments |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 613 | fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
| 614 | |
| 615 | class ImageDeploymentsIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 626 | id = serializers.Field() |
| 627 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 628 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 629 | model = ReservedResource |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 630 | fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 631 | |
| 632 | class ReservedResourceIdSerializer(serializers.ModelSerializer): |
| 633 | id = serializers.Field() |
| 634 | |
| 635 | class Meta: |
| 636 | model = ReservedResource |
| 637 | fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 643 | id = serializers.Field() |
| 644 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 645 | class Meta: |
| 646 | model = NetworkSlice |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 647 | fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 648 | |
| 649 | class NetworkSliceIdSerializer(serializers.ModelSerializer): |
| 650 | id = serializers.Field() |
| 651 | |
| 652 | class Meta: |
| 653 | model = NetworkSlice |
| 654 | fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 655 | |
| 656 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 657 | |
| 658 | |
| 659 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
| 660 | id = serializers.Field() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 661 | |
| 662 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 663 | model = UserDashboardView |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 664 | fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 665 | |
| 666 | class UserDashboardViewIdSerializer(serializers.ModelSerializer): |
| 667 | id = serializers.Field() |
| 668 | |
| 669 | class Meta: |
| 670 | model = UserDashboardView |
| 671 | fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 672 | |
| 673 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 674 | |
| 675 | |
| 676 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 677 | id = serializers.Field() |
| 678 | |
| 679 | class Meta: |
| 680 | model = PlanetStackPrivilege |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 681 | fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 682 | |
| 683 | class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer): |
| 684 | id = serializers.Field() |
| 685 | |
| 686 | class Meta: |
| 687 | model = PlanetStackPrivilege |
| 688 | fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 689 | |
| 690 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 691 | |
| 692 | |
| 693 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
| 694 | id = serializers.Field() |
| 695 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 696 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 697 | model = User |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 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',) |
| 699 | |
| 700 | class UserIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 706 | |
| 707 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 708 | |
| 709 | |
| 710 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
| 711 | id = serializers.Field() |
| 712 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 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 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 729 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 730 | model = Deployment |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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): |
| 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 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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 | |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 752 | class Meta: |
| 753 | model = Deployment |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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): |
| 760 | id = serializers.Field() |
| 761 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 762 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 763 | model = Reservation |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 764 | fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 765 | |
| 766 | class ReservationIdSerializer(serializers.ModelSerializer): |
| 767 | id = serializers.Field() |
| 768 | |
| 769 | class Meta: |
| 770 | model = Reservation |
| 771 | fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 777 | id = serializers.Field() |
| 778 | |
| 779 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 780 | model = SliceDeployments |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 781 | fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
| 782 | |
| 783 | class SliceDeploymentsIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 794 | id = serializers.Field() |
| 795 | |
| 796 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 797 | model = SitePrivilege |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 798 | fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 799 | |
| 800 | class SitePrivilegeIdSerializer(serializers.ModelSerializer): |
| 801 | id = serializers.Field() |
| 802 | |
| 803 | class Meta: |
| 804 | model = SitePrivilege |
| 805 | fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 806 | |
| 807 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 808 | |
| 809 | |
| 810 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
| 811 | id = serializers.Field() |
| 812 | |
| 813 | class Meta: |
| 814 | model = PlanetStack |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 815 | fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
| 816 | |
| 817 | class PlanetStackIdSerializer(serializers.ModelSerializer): |
| 818 | id = serializers.Field() |
| 819 | |
| 820 | class Meta: |
| 821 | model = PlanetStack |
| 822 | fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
| 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): |
| 828 | id = serializers.Field() |
| 829 | |
| 830 | class Meta: |
| 831 | model = UserDeployments |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 832 | fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
| 833 | |
| 834 | class UserDeploymentsIdSerializer(serializers.ModelSerializer): |
| 835 | id = serializers.Field() |
| 836 | |
| 837 | class Meta: |
| 838 | model = UserDeployments |
| 839 | fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
| 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): |
| 845 | id = serializers.Field() |
| 846 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 847 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 848 | model = Account |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 849 | fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 850 | |
| 851 | class AccountIdSerializer(serializers.ModelSerializer): |
| 852 | id = serializers.Field() |
| 853 | |
| 854 | class Meta: |
| 855 | model = Account |
| 856 | fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 862 | id = serializers.Field() |
| 863 | |
| 864 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 865 | model = NetworkParameterType |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 866 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 867 | |
| 868 | class NetworkParameterTypeIdSerializer(serializers.ModelSerializer): |
| 869 | id = serializers.Field() |
| 870 | |
| 871 | class Meta: |
| 872 | model = NetworkParameterType |
| 873 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 874 | |
| 875 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 876 | |
| 877 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 878 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 879 | id = serializers.Field() |
| 880 | |
| 881 | class Meta: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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 | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 885 | class SiteCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 886 | id = serializers.Field() |
| 887 | |
| 888 | class Meta: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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): |
| 896 | id = serializers.Field() |
| 897 | |
| 898 | class Meta: |
| 899 | model = DeploymentPrivilege |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 900 | fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 901 | |
| 902 | class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer): |
| 903 | id = serializers.Field() |
| 904 | |
| 905 | class Meta: |
| 906 | model = DeploymentPrivilege |
| 907 | fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 908 | |
| 909 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 910 | |
| 911 | |
| 912 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
| 913 | id = serializers.Field() |
| 914 | |
| 915 | class Meta: |
| 916 | model = DeploymentRole |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 917 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 918 | |
| 919 | class DeploymentRoleIdSerializer(serializers.ModelSerializer): |
| 920 | id = serializers.Field() |
| 921 | |
| 922 | class Meta: |
| 923 | model = DeploymentRole |
| 924 | fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 925 | |
| 926 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 927 | |
| 928 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 929 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 930 | id = serializers.Field() |
| 931 | |
| 932 | class Meta: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 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 | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 936 | class UserCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 937 | id = serializers.Field() |
| 938 | |
| 939 | class Meta: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 940 | model = UserCredential |
| 941 | fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 947 | id = serializers.Field() |
| 948 | |
| 949 | class Meta: |
| 950 | model = SiteDeployments |
| 951 | fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
| 952 | |
| 953 | class SiteDeploymentsIdSerializer(serializers.ModelSerializer): |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 964 | id = serializers.Field() |
| 965 | |
| 966 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 967 | model = SliceTag |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 968 | fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 969 | |
| 970 | class SliceTagIdSerializer(serializers.ModelSerializer): |
| 971 | id = serializers.Field() |
| 972 | |
| 973 | class Meta: |
| 974 | model = SliceTag |
| 975 | fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 976 | |
| 977 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 978 | |
| 979 | |
| 980 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
| 981 | id = serializers.Field() |
| 982 | |
| 983 | class Meta: |
| 984 | model = NetworkTemplate |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 985 | fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',) |
| 986 | |
| 987 | class NetworkTemplateIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 993 | |
| 994 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 995 | |
| 996 | |
| 997 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
| 998 | id = serializers.Field() |
| 999 | |
| 1000 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1001 | model = Router |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1002 | fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',) |
| 1003 | |
| 1004 | class RouterIdSerializer(serializers.ModelSerializer): |
| 1005 | id = serializers.Field() |
| 1006 | |
| 1007 | class Meta: |
| 1008 | model = Router |
| 1009 | fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',) |
| 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): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1015 | id = serializers.Field() |
| 1016 | |
| 1017 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1018 | model = ServiceResource |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1019 | fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 1020 | |
| 1021 | class ServiceResourceIdSerializer(serializers.ModelSerializer): |
| 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',) |
| 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 | dcb9b5d | 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 | dcb9b5d | 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 | dcb9b5d | 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 | dcb9b5d | 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 | dcb9b5d | 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 | dcb9b5d | 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):
|
| 1140 | partial = kwargs.pop('partial', False)
|
| 1141 | self.object = self.get_object_or_none()
|
| 1142 |
|
| 1143 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 1144 | files=request.FILES, partial=partial)
|
| 1145 |
|
| 1146 | if not serializer.is_valid():
|
| 1147 | print "UpdateModelMixin: not serializer.is_valid"
|
| 1148 | print serializer.errors
|
| 1149 | return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
| 1150 |
|
| 1151 | try:
|
| 1152 | self.pre_save(serializer.object)
|
| 1153 | except ValidationError as err:
|
| 1154 | # full_clean on model instance may be called in pre_save,
|
| 1155 | # so we have to handle eventual errors.
|
| 1156 | return Response(err.message_dict, status=status.HTTP_400_BAD_REQUEST)
|
| 1157 |
|
| 1158 | if serializer.object is not None:
|
| 1159 | if not serializer.object.can_update(request.user):
|
| 1160 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 1161 |
|
| 1162 | if self.object is None:
|
| 1163 | self.object = serializer.save(force_insert=True)
|
| 1164 | self.post_save(self.object, created=True)
|
| 1165 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 1166 |
|
| 1167 | self.object = serializer.save(force_update=True)
|
| 1168 | self.post_save(self.object, created=False)
|
| 1169 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 1170 | |
| 1171 | def destroy(self, request, *args, **kwargs): |
| 1172 | obj = self.get_object() |
| 1173 | if obj.can_update(request.user): |
| 1174 | return super(Detail, self).destroy(request, *args, **kwargs) |
| 1175 | else: |
| 1176 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1177 | |
| 1178 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1179 | # Based on core/views/*.py |
| 1180 | |
| 1181 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1182 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 1183 | queryset = ServiceAttribute.objects.select_related().all() |
| 1184 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1185 | id_serializer_class = ServiceAttributeIdSerializer |
| 1186 | filter_backends = (filters.DjangoFilterBackend,) |
| 1187 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 1188 | |
| 1189 | def get_serializer_class(self): |
| 1190 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1191 | if (no_hyperlinks): |
| 1192 | return self.id_serializer_class |
| 1193 | else: |
| 1194 | return self.serializer_class |
| 1195 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1196 | def get_queryset(self): |
| 1197 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1198 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1199 | def create(self, request, *args, **kwargs): |
| 1200 | #obj = ServiceAttribute().update(request.DATA) |
| 1201 | obj = self.get_object() |
| 1202 | obj.caller = request.user |
| 1203 | if obj.can_update(request.user): |
| 1204 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 1205 | else: |
| 1206 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1207 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1208 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1209 | queryset = ServiceAttribute.objects.select_related().all() |
| 1210 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1211 | id_serializer_class = ServiceAttributeIdSerializer |
| 1212 | |
| 1213 | def get_serializer_class(self): |
| 1214 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1215 | if (no_hyperlinks): |
| 1216 | return self.id_serializer_class |
| 1217 | else: |
| 1218 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1219 | |
| 1220 | def get_queryset(self): |
| 1221 | return ServiceAttribute.select_by_user(self.request.user) |
| 1222 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1223 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1224 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1225 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1226 | |
| 1227 | |
| 1228 | |
| 1229 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1230 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1231 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1232 | id_serializer_class = ImageIdSerializer |
| 1233 | filter_backends = (filters.DjangoFilterBackend,) |
| 1234 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
| 1235 | |
| 1236 | def get_serializer_class(self): |
| 1237 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1238 | if (no_hyperlinks): |
| 1239 | return self.id_serializer_class |
| 1240 | else: |
| 1241 | return self.serializer_class |
| 1242 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1243 | def get_queryset(self): |
| 1244 | return Image.select_by_user(self.request.user) |
| 1245 | |
| 1246 | def create(self, request, *args, **kwargs): |
| 1247 | #obj = Image().update(request.DATA) |
| 1248 | obj = self.get_object() |
| 1249 | obj.caller = request.user |
| 1250 | if obj.can_update(request.user): |
| 1251 | return super(ImageList, self).create(request, *args, **kwargs) |
| 1252 | else: |
| 1253 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1254 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1255 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1256 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1257 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1258 | id_serializer_class = ImageIdSerializer |
| 1259 | |
| 1260 | def get_serializer_class(self): |
| 1261 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1262 | if (no_hyperlinks): |
| 1263 | return self.id_serializer_class |
| 1264 | else: |
| 1265 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1266 | |
| 1267 | def get_queryset(self): |
| 1268 | return Image.select_by_user(self.request.user) |
| 1269 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1270 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1271 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1272 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1273 | |
| 1274 | |
| 1275 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1276 | class NetworkParameterList(generics.ListCreateAPIView): |
| 1277 | queryset = NetworkParameter.objects.select_related().all() |
| 1278 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1279 | id_serializer_class = NetworkParameterIdSerializer |
| 1280 | filter_backends = (filters.DjangoFilterBackend,) |
| 1281 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 1282 | |
| 1283 | def get_serializer_class(self): |
| 1284 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1285 | if (no_hyperlinks): |
| 1286 | return self.id_serializer_class |
| 1287 | else: |
| 1288 | return self.serializer_class |
| 1289 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1290 | def get_queryset(self): |
| 1291 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1292 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1293 | def create(self, request, *args, **kwargs): |
| 1294 | #obj = NetworkParameter().update(request.DATA) |
| 1295 | obj = self.get_object() |
| 1296 | obj.caller = request.user |
| 1297 | if obj.can_update(request.user): |
| 1298 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 1299 | else: |
| 1300 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1301 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1302 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1303 | queryset = NetworkParameter.objects.select_related().all() |
| 1304 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1305 | id_serializer_class = NetworkParameterIdSerializer |
| 1306 | |
| 1307 | def get_serializer_class(self): |
| 1308 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1309 | if (no_hyperlinks): |
| 1310 | return self.id_serializer_class |
| 1311 | else: |
| 1312 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1313 | |
| 1314 | def get_queryset(self): |
| 1315 | return NetworkParameter.select_by_user(self.request.user) |
| 1316 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1317 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1318 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1319 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1320 | |
| 1321 | |
| 1322 | |
| 1323 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1324 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1325 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1326 | id_serializer_class = SiteIdSerializer |
| 1327 | filter_backends = (filters.DjangoFilterBackend,) |
| 1328 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
| 1329 | |
| 1330 | def get_serializer_class(self): |
| 1331 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1332 | if (no_hyperlinks): |
| 1333 | return self.id_serializer_class |
| 1334 | else: |
| 1335 | return self.serializer_class |
| 1336 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1337 | def get_queryset(self): |
| 1338 | return Site.select_by_user(self.request.user) |
| 1339 | |
| 1340 | def create(self, request, *args, **kwargs): |
| 1341 | #obj = Site().update(request.DATA) |
| 1342 | obj = self.get_object() |
| 1343 | obj.caller = request.user |
| 1344 | if obj.can_update(request.user): |
| 1345 | return super(SiteList, self).create(request, *args, **kwargs) |
| 1346 | else: |
| 1347 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1348 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1349 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1350 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1351 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1352 | id_serializer_class = SiteIdSerializer |
| 1353 | |
| 1354 | def get_serializer_class(self): |
| 1355 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1356 | if (no_hyperlinks): |
| 1357 | return self.id_serializer_class |
| 1358 | else: |
| 1359 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1360 | |
| 1361 | def get_queryset(self): |
| 1362 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1363 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1364 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1365 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1366 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1367 | |
| 1368 | |
| 1369 | |
| 1370 | class SliceRoleList(generics.ListCreateAPIView): |
| 1371 | queryset = SliceRole.objects.select_related().all() |
| 1372 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1373 | id_serializer_class = SliceRoleIdSerializer |
| 1374 | filter_backends = (filters.DjangoFilterBackend,) |
| 1375 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 1376 | |
| 1377 | def get_serializer_class(self): |
| 1378 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1379 | if (no_hyperlinks): |
| 1380 | return self.id_serializer_class |
| 1381 | else: |
| 1382 | return self.serializer_class |
| 1383 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1384 | def get_queryset(self): |
| 1385 | return SliceRole.select_by_user(self.request.user) |
| 1386 | |
| 1387 | def create(self, request, *args, **kwargs): |
| 1388 | #obj = SliceRole().update(request.DATA) |
| 1389 | obj = self.get_object() |
| 1390 | obj.caller = request.user |
| 1391 | if obj.can_update(request.user): |
| 1392 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 1393 | else: |
| 1394 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1395 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1396 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1397 | queryset = SliceRole.objects.select_related().all() |
| 1398 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1399 | id_serializer_class = SliceRoleIdSerializer |
| 1400 | |
| 1401 | def get_serializer_class(self): |
| 1402 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1403 | if (no_hyperlinks): |
| 1404 | return self.id_serializer_class |
| 1405 | else: |
| 1406 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1407 | |
| 1408 | def get_queryset(self): |
| 1409 | return SliceRole.select_by_user(self.request.user) |
| 1410 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1411 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1412 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1413 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1414 | |
| 1415 | |
| 1416 | |
| 1417 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1418 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1419 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1420 | id_serializer_class = TagIdSerializer |
| 1421 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1422 | 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] | 1423 | |
| 1424 | def get_serializer_class(self): |
| 1425 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1426 | if (no_hyperlinks): |
| 1427 | return self.id_serializer_class |
| 1428 | else: |
| 1429 | return self.serializer_class |
| 1430 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1431 | def get_queryset(self): |
| 1432 | return Tag.select_by_user(self.request.user) |
| 1433 | |
| 1434 | def create(self, request, *args, **kwargs): |
| 1435 | #obj = Tag().update(request.DATA) |
| 1436 | obj = self.get_object() |
| 1437 | obj.caller = request.user |
| 1438 | if obj.can_update(request.user): |
| 1439 | return super(TagList, self).create(request, *args, **kwargs) |
| 1440 | else: |
| 1441 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1442 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1443 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1444 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1445 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1446 | id_serializer_class = TagIdSerializer |
| 1447 | |
| 1448 | def get_serializer_class(self): |
| 1449 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1450 | if (no_hyperlinks): |
| 1451 | return self.id_serializer_class |
| 1452 | else: |
| 1453 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1454 | |
| 1455 | def get_queryset(self): |
| 1456 | return Tag.select_by_user(self.request.user) |
| 1457 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1458 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1459 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1460 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1461 | |
| 1462 | |
| 1463 | |
| 1464 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1465 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1466 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1467 | id_serializer_class = InvoiceIdSerializer |
| 1468 | filter_backends = (filters.DjangoFilterBackend,) |
| 1469 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 1470 | |
| 1471 | def get_serializer_class(self): |
| 1472 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1473 | if (no_hyperlinks): |
| 1474 | return self.id_serializer_class |
| 1475 | else: |
| 1476 | return self.serializer_class |
| 1477 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1478 | def get_queryset(self): |
| 1479 | return Invoice.select_by_user(self.request.user) |
| 1480 | |
| 1481 | def create(self, request, *args, **kwargs): |
| 1482 | #obj = Invoice().update(request.DATA) |
| 1483 | obj = self.get_object() |
| 1484 | obj.caller = request.user |
| 1485 | if obj.can_update(request.user): |
| 1486 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 1487 | else: |
| 1488 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1489 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1490 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1491 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1492 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1493 | id_serializer_class = InvoiceIdSerializer |
| 1494 | |
| 1495 | def get_serializer_class(self): |
| 1496 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1497 | if (no_hyperlinks): |
| 1498 | return self.id_serializer_class |
| 1499 | else: |
| 1500 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1501 | |
| 1502 | def get_queryset(self): |
| 1503 | return Invoice.select_by_user(self.request.user) |
| 1504 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1505 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1506 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1507 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1508 | |
| 1509 | |
| 1510 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1511 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 1512 | queryset = SlicePrivilege.objects.select_related().all() |
| 1513 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1514 | id_serializer_class = SlicePrivilegeIdSerializer |
| 1515 | filter_backends = (filters.DjangoFilterBackend,) |
| 1516 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 1517 | |
| 1518 | def get_serializer_class(self): |
| 1519 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1520 | if (no_hyperlinks): |
| 1521 | return self.id_serializer_class |
| 1522 | else: |
| 1523 | return self.serializer_class |
| 1524 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1525 | def get_queryset(self): |
| 1526 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1527 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1528 | def create(self, request, *args, **kwargs): |
| 1529 | #obj = SlicePrivilege().update(request.DATA) |
| 1530 | obj = self.get_object() |
| 1531 | obj.caller = request.user |
| 1532 | if obj.can_update(request.user): |
| 1533 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 1534 | else: |
| 1535 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1536 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1537 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1538 | queryset = SlicePrivilege.objects.select_related().all() |
| 1539 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1540 | id_serializer_class = SlicePrivilegeIdSerializer |
| 1541 | |
| 1542 | def get_serializer_class(self): |
| 1543 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1544 | if (no_hyperlinks): |
| 1545 | return self.id_serializer_class |
| 1546 | else: |
| 1547 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1548 | |
| 1549 | def get_queryset(self): |
| 1550 | return SlicePrivilege.select_by_user(self.request.user) |
| 1551 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1552 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1553 | |
| 1554 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1555 | |
| 1556 | |
| 1557 | |
| 1558 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 1559 | queryset = PlanetStackRole.objects.select_related().all() |
| 1560 | serializer_class = PlanetStackRoleSerializer |
| 1561 | id_serializer_class = PlanetStackRoleIdSerializer |
| 1562 | filter_backends = (filters.DjangoFilterBackend,) |
| 1563 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 1564 | |
| 1565 | def get_serializer_class(self): |
| 1566 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1567 | if (no_hyperlinks): |
| 1568 | return self.id_serializer_class |
| 1569 | else: |
| 1570 | return self.serializer_class |
| 1571 | |
| 1572 | def get_queryset(self): |
| 1573 | return PlanetStackRole.select_by_user(self.request.user) |
| 1574 | |
| 1575 | def create(self, request, *args, **kwargs): |
| 1576 | #obj = PlanetStackRole().update(request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1577 | obj = self.get_object() |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1578 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1579 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1580 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1581 | else: |
| 1582 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1583 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1584 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 1585 | queryset = PlanetStackRole.objects.select_related().all() |
| 1586 | serializer_class = PlanetStackRoleSerializer |
| 1587 | id_serializer_class = PlanetStackRoleIdSerializer |
| 1588 | |
| 1589 | def get_serializer_class(self): |
| 1590 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1591 | if (no_hyperlinks): |
| 1592 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1593 | else: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1594 | return self.serializer_class |
| 1595 | |
| 1596 | def get_queryset(self): |
| 1597 | return PlanetStackRole.select_by_user(self.request.user) |
| 1598 | |
| 1599 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1600 | |
| 1601 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1602 | |
| 1603 | |
| 1604 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1605 | class NetworkSliverList(generics.ListCreateAPIView): |
| 1606 | queryset = NetworkSliver.objects.select_related().all() |
| 1607 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1608 | id_serializer_class = NetworkSliverIdSerializer |
| 1609 | filter_backends = (filters.DjangoFilterBackend,) |
| 1610 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 1611 | |
| 1612 | def get_serializer_class(self): |
| 1613 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1614 | if (no_hyperlinks): |
| 1615 | return self.id_serializer_class |
| 1616 | else: |
| 1617 | return self.serializer_class |
| 1618 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1619 | def get_queryset(self): |
| 1620 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1621 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1622 | def create(self, request, *args, **kwargs): |
| 1623 | #obj = NetworkSliver().update(request.DATA) |
| 1624 | obj = self.get_object() |
| 1625 | obj.caller = request.user |
| 1626 | if obj.can_update(request.user): |
| 1627 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 1628 | else: |
| 1629 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1630 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1631 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1632 | queryset = NetworkSliver.objects.select_related().all() |
| 1633 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1634 | id_serializer_class = NetworkSliverIdSerializer |
| 1635 | |
| 1636 | def get_serializer_class(self): |
| 1637 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1638 | if (no_hyperlinks): |
| 1639 | return self.id_serializer_class |
| 1640 | else: |
| 1641 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1642 | |
| 1643 | def get_queryset(self): |
| 1644 | return NetworkSliver.select_by_user(self.request.user) |
| 1645 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1646 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1647 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1648 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1649 | |
| 1650 | |
| 1651 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1652 | class NetworkDeploymentsList(generics.ListCreateAPIView): |
| 1653 | queryset = NetworkDeployments.objects.select_related().all() |
| 1654 | serializer_class = NetworkDeploymentsSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1655 | id_serializer_class = NetworkDeploymentsIdSerializer |
| 1656 | filter_backends = (filters.DjangoFilterBackend,) |
| 1657 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
| 1658 | |
| 1659 | def get_serializer_class(self): |
| 1660 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1661 | if (no_hyperlinks): |
| 1662 | return self.id_serializer_class |
| 1663 | else: |
| 1664 | return self.serializer_class |
| 1665 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1666 | def get_queryset(self): |
| 1667 | return NetworkDeployments.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1668 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1669 | def create(self, request, *args, **kwargs): |
| 1670 | #obj = NetworkDeployments().update(request.DATA) |
| 1671 | obj = self.get_object() |
| 1672 | obj.caller = request.user |
| 1673 | if obj.can_update(request.user): |
| 1674 | return super(NetworkDeploymentsList, self).create(request, *args, **kwargs) |
| 1675 | else: |
| 1676 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1677 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1678 | class NetworkDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1679 | queryset = NetworkDeployments.objects.select_related().all() |
| 1680 | serializer_class = NetworkDeploymentsSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1681 | id_serializer_class = NetworkDeploymentsIdSerializer |
| 1682 | |
| 1683 | def get_serializer_class(self): |
| 1684 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1685 | if (no_hyperlinks): |
| 1686 | return self.id_serializer_class |
| 1687 | else: |
| 1688 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1689 | |
| 1690 | def get_queryset(self): |
| 1691 | return NetworkDeployments.select_by_user(self.request.user) |
| 1692 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1693 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1694 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1695 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1696 | |
| 1697 | |
| 1698 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1699 | class FlavorList(generics.ListCreateAPIView): |
| 1700 | queryset = Flavor.objects.select_related().all() |
| 1701 | serializer_class = FlavorSerializer |
| 1702 | id_serializer_class = FlavorIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1703 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1704 | 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] | 1705 | |
| 1706 | def get_serializer_class(self): |
| 1707 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1708 | if (no_hyperlinks): |
| 1709 | return self.id_serializer_class |
| 1710 | else: |
| 1711 | return self.serializer_class |
| 1712 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1713 | def get_queryset(self): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1714 | return Flavor.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1715 | |
| 1716 | def create(self, request, *args, **kwargs): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1717 | #obj = Flavor().update(request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1718 | obj = self.get_object() |
| 1719 | obj.caller = request.user |
| 1720 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1721 | return super(FlavorList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1722 | else: |
| 1723 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1724 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1725 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 1726 | queryset = Flavor.objects.select_related().all() |
| 1727 | serializer_class = FlavorSerializer |
| 1728 | id_serializer_class = FlavorIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1729 | |
| 1730 | def get_serializer_class(self): |
| 1731 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1732 | if (no_hyperlinks): |
| 1733 | return self.id_serializer_class |
| 1734 | else: |
| 1735 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1736 | |
| 1737 | def get_queryset(self): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1738 | return Flavor.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1739 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1740 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1741 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1742 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1743 | |
| 1744 | |
| 1745 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1746 | class ProjectList(generics.ListCreateAPIView): |
| 1747 | queryset = Project.objects.select_related().all() |
| 1748 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1749 | id_serializer_class = ProjectIdSerializer |
| 1750 | filter_backends = (filters.DjangoFilterBackend,) |
| 1751 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 1752 | |
| 1753 | def get_serializer_class(self): |
| 1754 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1755 | if (no_hyperlinks): |
| 1756 | return self.id_serializer_class |
| 1757 | else: |
| 1758 | return self.serializer_class |
| 1759 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1760 | def get_queryset(self): |
| 1761 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1762 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1763 | def create(self, request, *args, **kwargs): |
| 1764 | #obj = Project().update(request.DATA) |
| 1765 | obj = self.get_object() |
| 1766 | obj.caller = request.user |
| 1767 | if obj.can_update(request.user): |
| 1768 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 1769 | else: |
| 1770 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1771 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1772 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1773 | queryset = Project.objects.select_related().all() |
| 1774 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1775 | id_serializer_class = ProjectIdSerializer |
| 1776 | |
| 1777 | def get_serializer_class(self): |
| 1778 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1779 | if (no_hyperlinks): |
| 1780 | return self.id_serializer_class |
| 1781 | else: |
| 1782 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1783 | |
| 1784 | def get_queryset(self): |
| 1785 | return Project.select_by_user(self.request.user) |
| 1786 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1787 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1788 | |
| 1789 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1790 | |
| 1791 | |
| 1792 | |
| 1793 | class SliceList(generics.ListCreateAPIView): |
| 1794 | queryset = Slice.objects.select_related().all() |
| 1795 | serializer_class = SliceSerializer |
| 1796 | id_serializer_class = SliceIdSerializer |
| 1797 | filter_backends = (filters.DjangoFilterBackend,) |
| 1798 | 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',) |
| 1799 | |
| 1800 | def get_serializer_class(self): |
| 1801 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1802 | if (no_hyperlinks): |
| 1803 | return self.id_serializer_class |
| 1804 | else: |
| 1805 | return self.serializer_class |
| 1806 | |
| 1807 | def get_queryset(self): |
| 1808 | return Slice.select_by_user(self.request.user) |
| 1809 | |
| 1810 | def create(self, request, *args, **kwargs): |
| 1811 | #obj = Slice().update(request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1812 | obj = self.get_object() |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1813 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1814 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1815 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1816 | else: |
| 1817 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1818 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1819 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 1820 | queryset = Slice.objects.select_related().all() |
| 1821 | serializer_class = SliceSerializer |
| 1822 | id_serializer_class = SliceIdSerializer |
| 1823 | |
| 1824 | def get_serializer_class(self): |
| 1825 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1826 | if (no_hyperlinks): |
| 1827 | return self.id_serializer_class |
| 1828 | else: |
| 1829 | return self.serializer_class |
| 1830 | |
| 1831 | def get_queryset(self): |
| 1832 | return Slice.select_by_user(self.request.user) |
| 1833 | |
| 1834 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1835 | |
| 1836 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1837 | |
| 1838 | |
| 1839 | |
| 1840 | class NetworkList(generics.ListCreateAPIView): |
| 1841 | queryset = Network.objects.select_related().all() |
| 1842 | serializer_class = NetworkSerializer |
| 1843 | id_serializer_class = NetworkIdSerializer |
| 1844 | filter_backends = (filters.DjangoFilterBackend,) |
| 1845 | 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',) |
| 1846 | |
| 1847 | def get_serializer_class(self): |
| 1848 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1849 | if (no_hyperlinks): |
| 1850 | return self.id_serializer_class |
| 1851 | else: |
| 1852 | return self.serializer_class |
| 1853 | |
| 1854 | def get_queryset(self): |
| 1855 | return Network.select_by_user(self.request.user) |
| 1856 | |
| 1857 | def create(self, request, *args, **kwargs): |
| 1858 | #obj = Network().update(request.DATA) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1859 | obj = self.get_object() |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1860 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1861 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1862 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1863 | else: |
| 1864 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1865 | |
| 1866 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 1867 | queryset = Network.objects.select_related().all() |
| 1868 | serializer_class = NetworkSerializer |
| 1869 | id_serializer_class = NetworkIdSerializer |
| 1870 | |
| 1871 | def get_serializer_class(self): |
| 1872 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1873 | if (no_hyperlinks): |
| 1874 | return self.id_serializer_class |
| 1875 | else: |
| 1876 | return self.serializer_class |
| 1877 | |
| 1878 | def get_queryset(self): |
| 1879 | return Network.select_by_user(self.request.user) |
| 1880 | |
| 1881 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1882 | |
| 1883 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1884 | |
| 1885 | |
| 1886 | |
| 1887 | class ServiceList(generics.ListCreateAPIView): |
| 1888 | queryset = Service.objects.select_related().all() |
| 1889 | serializer_class = ServiceSerializer |
| 1890 | id_serializer_class = ServiceIdSerializer |
| 1891 | filter_backends = (filters.DjangoFilterBackend,) |
| 1892 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 1893 | |
| 1894 | def get_serializer_class(self): |
| 1895 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1896 | if (no_hyperlinks): |
| 1897 | return self.id_serializer_class |
| 1898 | else: |
| 1899 | return self.serializer_class |
| 1900 | |
| 1901 | def get_queryset(self): |
| 1902 | return Service.select_by_user(self.request.user) |
| 1903 | |
| 1904 | def create(self, request, *args, **kwargs): |
| 1905 | #obj = Service().update(request.DATA) |
| 1906 | obj = self.get_object() |
| 1907 | obj.caller = request.user |
| 1908 | if obj.can_update(request.user): |
| 1909 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 1910 | else: |
| 1911 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1912 | |
| 1913 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 1914 | queryset = Service.objects.select_related().all() |
| 1915 | serializer_class = ServiceSerializer |
| 1916 | id_serializer_class = ServiceIdSerializer |
| 1917 | |
| 1918 | def get_serializer_class(self): |
| 1919 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1920 | if (no_hyperlinks): |
| 1921 | return self.id_serializer_class |
| 1922 | else: |
| 1923 | return self.serializer_class |
| 1924 | |
| 1925 | def get_queryset(self): |
| 1926 | return Service.select_by_user(self.request.user) |
| 1927 | |
| 1928 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1929 | |
| 1930 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1931 | |
| 1932 | |
| 1933 | |
| 1934 | class ServiceClassList(generics.ListCreateAPIView): |
| 1935 | queryset = ServiceClass.objects.select_related().all() |
| 1936 | serializer_class = ServiceClassSerializer |
| 1937 | id_serializer_class = ServiceClassIdSerializer |
| 1938 | filter_backends = (filters.DjangoFilterBackend,) |
| 1939 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 1940 | |
| 1941 | def get_serializer_class(self): |
| 1942 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1943 | if (no_hyperlinks): |
| 1944 | return self.id_serializer_class |
| 1945 | else: |
| 1946 | return self.serializer_class |
| 1947 | |
| 1948 | def get_queryset(self): |
| 1949 | return ServiceClass.select_by_user(self.request.user) |
| 1950 | |
| 1951 | def create(self, request, *args, **kwargs): |
| 1952 | #obj = ServiceClass().update(request.DATA) |
| 1953 | obj = self.get_object() |
| 1954 | obj.caller = request.user |
| 1955 | if obj.can_update(request.user): |
| 1956 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 1957 | else: |
| 1958 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1959 | |
| 1960 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 1961 | queryset = ServiceClass.objects.select_related().all() |
| 1962 | serializer_class = ServiceClassSerializer |
| 1963 | id_serializer_class = ServiceClassIdSerializer |
| 1964 | |
| 1965 | def get_serializer_class(self): |
| 1966 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1967 | if (no_hyperlinks): |
| 1968 | return self.id_serializer_class |
| 1969 | else: |
| 1970 | return self.serializer_class |
| 1971 | |
| 1972 | def get_queryset(self): |
| 1973 | return ServiceClass.select_by_user(self.request.user) |
| 1974 | |
| 1975 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1976 | |
| 1977 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 1978 | |
| 1979 | |
| 1980 | |
| 1981 | class PaymentList(generics.ListCreateAPIView): |
| 1982 | queryset = Payment.objects.select_related().all() |
| 1983 | serializer_class = PaymentSerializer |
| 1984 | id_serializer_class = PaymentIdSerializer |
| 1985 | filter_backends = (filters.DjangoFilterBackend,) |
| 1986 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1987 | |
| 1988 | def get_serializer_class(self): |
| 1989 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1990 | if (no_hyperlinks): |
| 1991 | return self.id_serializer_class |
| 1992 | else: |
| 1993 | return self.serializer_class |
| 1994 | |
| 1995 | def get_queryset(self): |
| 1996 | return Payment.select_by_user(self.request.user) |
| 1997 | |
| 1998 | def create(self, request, *args, **kwargs): |
| 1999 | #obj = Payment().update(request.DATA) |
| 2000 | obj = self.get_object() |
| 2001 | obj.caller = request.user |
| 2002 | if obj.can_update(request.user): |
| 2003 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 2004 | else: |
| 2005 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2006 | |
| 2007 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2008 | queryset = Payment.objects.select_related().all() |
| 2009 | serializer_class = PaymentSerializer |
| 2010 | id_serializer_class = PaymentIdSerializer |
| 2011 | |
| 2012 | def get_serializer_class(self): |
| 2013 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2014 | if (no_hyperlinks): |
| 2015 | return self.id_serializer_class |
| 2016 | else: |
| 2017 | return self.serializer_class |
| 2018 | |
| 2019 | def get_queryset(self): |
| 2020 | return Payment.select_by_user(self.request.user) |
| 2021 | |
| 2022 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2023 | |
| 2024 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2025 | |
| 2026 | |
| 2027 | |
| 2028 | class ChargeList(generics.ListCreateAPIView): |
| 2029 | queryset = Charge.objects.select_related().all() |
| 2030 | serializer_class = ChargeSerializer |
| 2031 | id_serializer_class = ChargeIdSerializer |
| 2032 | filter_backends = (filters.DjangoFilterBackend,) |
| 2033 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 2034 | |
| 2035 | def get_serializer_class(self): |
| 2036 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2037 | if (no_hyperlinks): |
| 2038 | return self.id_serializer_class |
| 2039 | else: |
| 2040 | return self.serializer_class |
| 2041 | |
| 2042 | def get_queryset(self): |
| 2043 | return Charge.select_by_user(self.request.user) |
| 2044 | |
| 2045 | def create(self, request, *args, **kwargs): |
| 2046 | #obj = Charge().update(request.DATA) |
| 2047 | obj = self.get_object() |
| 2048 | obj.caller = request.user |
| 2049 | if obj.can_update(request.user): |
| 2050 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 2051 | else: |
| 2052 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2053 | |
| 2054 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2055 | queryset = Charge.objects.select_related().all() |
| 2056 | serializer_class = ChargeSerializer |
| 2057 | id_serializer_class = ChargeIdSerializer |
| 2058 | |
| 2059 | def get_serializer_class(self): |
| 2060 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2061 | if (no_hyperlinks): |
| 2062 | return self.id_serializer_class |
| 2063 | else: |
| 2064 | return self.serializer_class |
| 2065 | |
| 2066 | def get_queryset(self): |
| 2067 | return Charge.select_by_user(self.request.user) |
| 2068 | |
| 2069 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2070 | |
| 2071 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2072 | |
| 2073 | |
| 2074 | |
| 2075 | class RoleList(generics.ListCreateAPIView): |
| 2076 | queryset = Role.objects.select_related().all() |
| 2077 | serializer_class = RoleSerializer |
| 2078 | id_serializer_class = RoleIdSerializer |
| 2079 | filter_backends = (filters.DjangoFilterBackend,) |
| 2080 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 2081 | |
| 2082 | def get_serializer_class(self): |
| 2083 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2084 | if (no_hyperlinks): |
| 2085 | return self.id_serializer_class |
| 2086 | else: |
| 2087 | return self.serializer_class |
| 2088 | |
| 2089 | def get_queryset(self): |
| 2090 | return Role.select_by_user(self.request.user) |
| 2091 | |
| 2092 | def create(self, request, *args, **kwargs): |
| 2093 | #obj = Role().update(request.DATA) |
| 2094 | obj = self.get_object() |
| 2095 | obj.caller = request.user |
| 2096 | if obj.can_update(request.user): |
| 2097 | return super(RoleList, self).create(request, *args, **kwargs) |
| 2098 | else: |
| 2099 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2100 | |
| 2101 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2102 | queryset = Role.objects.select_related().all() |
| 2103 | serializer_class = RoleSerializer |
| 2104 | id_serializer_class = RoleIdSerializer |
| 2105 | |
| 2106 | def get_serializer_class(self): |
| 2107 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2108 | if (no_hyperlinks): |
| 2109 | return self.id_serializer_class |
| 2110 | else: |
| 2111 | return self.serializer_class |
| 2112 | |
| 2113 | def get_queryset(self): |
| 2114 | return Role.select_by_user(self.request.user) |
| 2115 | |
| 2116 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2117 | |
| 2118 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2119 | |
| 2120 | |
| 2121 | |
| 2122 | class UsableObjectList(generics.ListCreateAPIView): |
| 2123 | queryset = UsableObject.objects.select_related().all() |
| 2124 | serializer_class = UsableObjectSerializer |
| 2125 | id_serializer_class = UsableObjectIdSerializer |
| 2126 | filter_backends = (filters.DjangoFilterBackend,) |
| 2127 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 2128 | |
| 2129 | def get_serializer_class(self): |
| 2130 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2131 | if (no_hyperlinks): |
| 2132 | return self.id_serializer_class |
| 2133 | else: |
| 2134 | return self.serializer_class |
| 2135 | |
| 2136 | def get_queryset(self): |
| 2137 | return UsableObject.select_by_user(self.request.user) |
| 2138 | |
| 2139 | def create(self, request, *args, **kwargs): |
| 2140 | #obj = UsableObject().update(request.DATA) |
| 2141 | obj = self.get_object() |
| 2142 | obj.caller = request.user |
| 2143 | if obj.can_update(request.user): |
| 2144 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 2145 | else: |
| 2146 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2147 | |
| 2148 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2149 | queryset = UsableObject.objects.select_related().all() |
| 2150 | serializer_class = UsableObjectSerializer |
| 2151 | id_serializer_class = UsableObjectIdSerializer |
| 2152 | |
| 2153 | def get_serializer_class(self): |
| 2154 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2155 | if (no_hyperlinks): |
| 2156 | return self.id_serializer_class |
| 2157 | else: |
| 2158 | return self.serializer_class |
| 2159 | |
| 2160 | def get_queryset(self): |
| 2161 | return UsableObject.select_by_user(self.request.user) |
| 2162 | |
| 2163 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2164 | |
| 2165 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2166 | |
| 2167 | |
| 2168 | |
| 2169 | class SiteRoleList(generics.ListCreateAPIView): |
| 2170 | queryset = SiteRole.objects.select_related().all() |
| 2171 | serializer_class = SiteRoleSerializer |
| 2172 | id_serializer_class = SiteRoleIdSerializer |
| 2173 | filter_backends = (filters.DjangoFilterBackend,) |
| 2174 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2175 | |
| 2176 | def get_serializer_class(self): |
| 2177 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2178 | if (no_hyperlinks): |
| 2179 | return self.id_serializer_class |
| 2180 | else: |
| 2181 | return self.serializer_class |
| 2182 | |
| 2183 | def get_queryset(self): |
| 2184 | return SiteRole.select_by_user(self.request.user) |
| 2185 | |
| 2186 | def create(self, request, *args, **kwargs): |
| 2187 | #obj = SiteRole().update(request.DATA) |
| 2188 | obj = self.get_object() |
| 2189 | obj.caller = request.user |
| 2190 | if obj.can_update(request.user): |
| 2191 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 2192 | else: |
| 2193 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2194 | |
| 2195 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2196 | queryset = SiteRole.objects.select_related().all() |
| 2197 | serializer_class = SiteRoleSerializer |
| 2198 | id_serializer_class = SiteRoleIdSerializer |
| 2199 | |
| 2200 | def get_serializer_class(self): |
| 2201 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2202 | if (no_hyperlinks): |
| 2203 | return self.id_serializer_class |
| 2204 | else: |
| 2205 | return self.serializer_class |
| 2206 | |
| 2207 | def get_queryset(self): |
| 2208 | return SiteRole.select_by_user(self.request.user) |
| 2209 | |
| 2210 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2211 | |
| 2212 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2213 | |
| 2214 | |
| 2215 | |
| 2216 | class SliceCredentialList(generics.ListCreateAPIView): |
| 2217 | queryset = SliceCredential.objects.select_related().all() |
| 2218 | serializer_class = SliceCredentialSerializer |
| 2219 | id_serializer_class = SliceCredentialIdSerializer |
| 2220 | filter_backends = (filters.DjangoFilterBackend,) |
| 2221 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 2222 | |
| 2223 | def get_serializer_class(self): |
| 2224 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2225 | if (no_hyperlinks): |
| 2226 | return self.id_serializer_class |
| 2227 | else: |
| 2228 | return self.serializer_class |
| 2229 | |
| 2230 | def get_queryset(self): |
| 2231 | return SliceCredential.select_by_user(self.request.user) |
| 2232 | |
| 2233 | def create(self, request, *args, **kwargs): |
| 2234 | #obj = SliceCredential().update(request.DATA) |
| 2235 | obj = self.get_object() |
| 2236 | obj.caller = request.user |
| 2237 | if obj.can_update(request.user): |
| 2238 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 2239 | else: |
| 2240 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2241 | |
| 2242 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2243 | queryset = SliceCredential.objects.select_related().all() |
| 2244 | serializer_class = SliceCredentialSerializer |
| 2245 | id_serializer_class = SliceCredentialIdSerializer |
| 2246 | |
| 2247 | def get_serializer_class(self): |
| 2248 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2249 | if (no_hyperlinks): |
| 2250 | return self.id_serializer_class |
| 2251 | else: |
| 2252 | return self.serializer_class |
| 2253 | |
| 2254 | def get_queryset(self): |
| 2255 | return SliceCredential.select_by_user(self.request.user) |
| 2256 | |
| 2257 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2258 | |
| 2259 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2260 | |
| 2261 | |
| 2262 | |
| 2263 | class SliverList(generics.ListCreateAPIView): |
| 2264 | queryset = Sliver.objects.select_related().all() |
| 2265 | serializer_class = SliverSerializer |
| 2266 | id_serializer_class = SliverIdSerializer |
| 2267 | filter_backends = (filters.DjangoFilterBackend,) |
| 2268 | 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',) |
| 2269 | |
| 2270 | def get_serializer_class(self): |
| 2271 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2272 | if (no_hyperlinks): |
| 2273 | return self.id_serializer_class |
| 2274 | else: |
| 2275 | return self.serializer_class |
| 2276 | |
| 2277 | def get_queryset(self): |
| 2278 | return Sliver.select_by_user(self.request.user) |
| 2279 | |
| 2280 | def create(self, request, *args, **kwargs): |
| 2281 | #obj = Sliver().update(request.DATA) |
| 2282 | obj = self.get_object() |
| 2283 | obj.caller = request.user |
| 2284 | if obj.can_update(request.user): |
| 2285 | return super(SliverList, self).create(request, *args, **kwargs) |
| 2286 | else: |
| 2287 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2288 | |
| 2289 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2290 | queryset = Sliver.objects.select_related().all() |
| 2291 | serializer_class = SliverSerializer |
| 2292 | id_serializer_class = SliverIdSerializer |
| 2293 | |
| 2294 | def get_serializer_class(self): |
| 2295 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2296 | if (no_hyperlinks): |
| 2297 | return self.id_serializer_class |
| 2298 | else: |
| 2299 | return self.serializer_class |
| 2300 | |
| 2301 | def get_queryset(self): |
| 2302 | return Sliver.select_by_user(self.request.user) |
| 2303 | |
| 2304 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2305 | |
| 2306 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2307 | |
| 2308 | |
| 2309 | |
| 2310 | class NodeList(generics.ListCreateAPIView): |
| 2311 | queryset = Node.objects.select_related().all() |
| 2312 | serializer_class = NodeSerializer |
| 2313 | id_serializer_class = NodeIdSerializer |
| 2314 | filter_backends = (filters.DjangoFilterBackend,) |
| 2315 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
| 2316 | |
| 2317 | def get_serializer_class(self): |
| 2318 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2319 | if (no_hyperlinks): |
| 2320 | return self.id_serializer_class |
| 2321 | else: |
| 2322 | return self.serializer_class |
| 2323 | |
| 2324 | def get_queryset(self): |
| 2325 | return Node.select_by_user(self.request.user) |
| 2326 | |
| 2327 | def create(self, request, *args, **kwargs): |
| 2328 | #obj = Node().update(request.DATA) |
| 2329 | obj = self.get_object() |
| 2330 | obj.caller = request.user |
| 2331 | if obj.can_update(request.user): |
| 2332 | return super(NodeList, self).create(request, *args, **kwargs) |
| 2333 | else: |
| 2334 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2335 | |
| 2336 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2337 | queryset = Node.objects.select_related().all() |
| 2338 | serializer_class = NodeSerializer |
| 2339 | id_serializer_class = NodeIdSerializer |
| 2340 | |
| 2341 | def get_serializer_class(self): |
| 2342 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2343 | if (no_hyperlinks): |
| 2344 | return self.id_serializer_class |
| 2345 | else: |
| 2346 | return self.serializer_class |
| 2347 | |
| 2348 | def get_queryset(self): |
| 2349 | return Node.select_by_user(self.request.user) |
| 2350 | |
| 2351 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2352 | |
| 2353 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2354 | |
| 2355 | |
| 2356 | |
| 2357 | class DashboardViewList(generics.ListCreateAPIView): |
| 2358 | queryset = DashboardView.objects.select_related().all() |
| 2359 | serializer_class = DashboardViewSerializer |
| 2360 | id_serializer_class = DashboardViewIdSerializer |
| 2361 | filter_backends = (filters.DjangoFilterBackend,) |
| 2362 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',) |
| 2363 | |
| 2364 | def get_serializer_class(self): |
| 2365 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2366 | if (no_hyperlinks): |
| 2367 | return self.id_serializer_class |
| 2368 | else: |
| 2369 | return self.serializer_class |
| 2370 | |
| 2371 | def get_queryset(self): |
| 2372 | return DashboardView.select_by_user(self.request.user) |
| 2373 | |
| 2374 | def create(self, request, *args, **kwargs): |
| 2375 | #obj = DashboardView().update(request.DATA) |
| 2376 | obj = self.get_object() |
| 2377 | obj.caller = request.user |
| 2378 | if obj.can_update(request.user): |
| 2379 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 2380 | else: |
| 2381 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2382 | |
| 2383 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2384 | queryset = DashboardView.objects.select_related().all() |
| 2385 | serializer_class = DashboardViewSerializer |
| 2386 | id_serializer_class = DashboardViewIdSerializer |
| 2387 | |
| 2388 | def get_serializer_class(self): |
| 2389 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2390 | if (no_hyperlinks): |
| 2391 | return self.id_serializer_class |
| 2392 | else: |
| 2393 | return self.serializer_class |
| 2394 | |
| 2395 | def get_queryset(self): |
| 2396 | return DashboardView.select_by_user(self.request.user) |
| 2397 | |
| 2398 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2399 | |
| 2400 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2401 | |
| 2402 | |
| 2403 | |
| 2404 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 2405 | queryset = ImageDeployments.objects.select_related().all() |
| 2406 | serializer_class = ImageDeploymentsSerializer |
| 2407 | id_serializer_class = ImageDeploymentsIdSerializer |
| 2408 | filter_backends = (filters.DjangoFilterBackend,) |
| 2409 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
| 2410 | |
| 2411 | def get_serializer_class(self): |
| 2412 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2413 | if (no_hyperlinks): |
| 2414 | return self.id_serializer_class |
| 2415 | else: |
| 2416 | return self.serializer_class |
| 2417 | |
| 2418 | def get_queryset(self): |
| 2419 | return ImageDeployments.select_by_user(self.request.user) |
| 2420 | |
| 2421 | def create(self, request, *args, **kwargs): |
| 2422 | #obj = ImageDeployments().update(request.DATA) |
| 2423 | obj = self.get_object() |
| 2424 | obj.caller = request.user |
| 2425 | if obj.can_update(request.user): |
| 2426 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
| 2427 | else: |
| 2428 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2429 | |
| 2430 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2431 | queryset = ImageDeployments.objects.select_related().all() |
| 2432 | serializer_class = ImageDeploymentsSerializer |
| 2433 | id_serializer_class = ImageDeploymentsIdSerializer |
| 2434 | |
| 2435 | def get_serializer_class(self): |
| 2436 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2437 | if (no_hyperlinks): |
| 2438 | return self.id_serializer_class |
| 2439 | else: |
| 2440 | return self.serializer_class |
| 2441 | |
| 2442 | def get_queryset(self): |
| 2443 | return ImageDeployments.select_by_user(self.request.user) |
| 2444 | |
| 2445 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2446 | |
| 2447 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2448 | |
| 2449 | |
| 2450 | |
| 2451 | class ReservedResourceList(generics.ListCreateAPIView): |
| 2452 | queryset = ReservedResource.objects.select_related().all() |
| 2453 | serializer_class = ReservedResourceSerializer |
| 2454 | id_serializer_class = ReservedResourceIdSerializer |
| 2455 | filter_backends = (filters.DjangoFilterBackend,) |
| 2456 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 2457 | |
| 2458 | def get_serializer_class(self): |
| 2459 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2460 | if (no_hyperlinks): |
| 2461 | return self.id_serializer_class |
| 2462 | else: |
| 2463 | return self.serializer_class |
| 2464 | |
| 2465 | def get_queryset(self): |
| 2466 | return ReservedResource.select_by_user(self.request.user) |
| 2467 | |
| 2468 | def create(self, request, *args, **kwargs): |
| 2469 | #obj = ReservedResource().update(request.DATA) |
| 2470 | obj = self.get_object() |
| 2471 | obj.caller = request.user |
| 2472 | if obj.can_update(request.user): |
| 2473 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 2474 | else: |
| 2475 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2476 | |
| 2477 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2478 | queryset = ReservedResource.objects.select_related().all() |
| 2479 | serializer_class = ReservedResourceSerializer |
| 2480 | id_serializer_class = ReservedResourceIdSerializer |
| 2481 | |
| 2482 | def get_serializer_class(self): |
| 2483 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2484 | if (no_hyperlinks): |
| 2485 | return self.id_serializer_class |
| 2486 | else: |
| 2487 | return self.serializer_class |
| 2488 | |
| 2489 | def get_queryset(self): |
| 2490 | return ReservedResource.select_by_user(self.request.user) |
| 2491 | |
| 2492 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2493 | |
| 2494 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2495 | |
| 2496 | |
| 2497 | |
| 2498 | class NetworkSliceList(generics.ListCreateAPIView): |
| 2499 | queryset = NetworkSlice.objects.select_related().all() |
| 2500 | serializer_class = NetworkSliceSerializer |
| 2501 | id_serializer_class = NetworkSliceIdSerializer |
| 2502 | filter_backends = (filters.DjangoFilterBackend,) |
| 2503 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 2504 | |
| 2505 | def get_serializer_class(self): |
| 2506 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2507 | if (no_hyperlinks): |
| 2508 | return self.id_serializer_class |
| 2509 | else: |
| 2510 | return self.serializer_class |
| 2511 | |
| 2512 | def get_queryset(self): |
| 2513 | return NetworkSlice.select_by_user(self.request.user) |
| 2514 | |
| 2515 | def create(self, request, *args, **kwargs): |
| 2516 | #obj = NetworkSlice().update(request.DATA) |
| 2517 | obj = self.get_object() |
| 2518 | obj.caller = request.user |
| 2519 | if obj.can_update(request.user): |
| 2520 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 2521 | else: |
| 2522 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2523 | |
| 2524 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2525 | queryset = NetworkSlice.objects.select_related().all() |
| 2526 | serializer_class = NetworkSliceSerializer |
| 2527 | id_serializer_class = NetworkSliceIdSerializer |
| 2528 | |
| 2529 | def get_serializer_class(self): |
| 2530 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2531 | if (no_hyperlinks): |
| 2532 | return self.id_serializer_class |
| 2533 | else: |
| 2534 | return self.serializer_class |
| 2535 | |
| 2536 | def get_queryset(self): |
| 2537 | return NetworkSlice.select_by_user(self.request.user) |
| 2538 | |
| 2539 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2540 | |
| 2541 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2542 | |
| 2543 | |
| 2544 | |
| 2545 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 2546 | queryset = UserDashboardView.objects.select_related().all() |
| 2547 | serializer_class = UserDashboardViewSerializer |
| 2548 | id_serializer_class = UserDashboardViewIdSerializer |
| 2549 | filter_backends = (filters.DjangoFilterBackend,) |
| 2550 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 2551 | |
| 2552 | def get_serializer_class(self): |
| 2553 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2554 | if (no_hyperlinks): |
| 2555 | return self.id_serializer_class |
| 2556 | else: |
| 2557 | return self.serializer_class |
| 2558 | |
| 2559 | def get_queryset(self): |
| 2560 | return UserDashboardView.select_by_user(self.request.user) |
| 2561 | |
| 2562 | def create(self, request, *args, **kwargs): |
| 2563 | #obj = UserDashboardView().update(request.DATA) |
| 2564 | obj = self.get_object() |
| 2565 | obj.caller = request.user |
| 2566 | if obj.can_update(request.user): |
| 2567 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 2568 | else: |
| 2569 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2570 | |
| 2571 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2572 | queryset = UserDashboardView.objects.select_related().all() |
| 2573 | serializer_class = UserDashboardViewSerializer |
| 2574 | id_serializer_class = UserDashboardViewIdSerializer |
| 2575 | |
| 2576 | def get_serializer_class(self): |
| 2577 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2578 | if (no_hyperlinks): |
| 2579 | return self.id_serializer_class |
| 2580 | else: |
| 2581 | return self.serializer_class |
| 2582 | |
| 2583 | def get_queryset(self): |
| 2584 | return UserDashboardView.select_by_user(self.request.user) |
| 2585 | |
| 2586 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2587 | |
| 2588 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2589 | |
| 2590 | |
| 2591 | |
| 2592 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 2593 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 2594 | serializer_class = PlanetStackPrivilegeSerializer |
| 2595 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 2596 | filter_backends = (filters.DjangoFilterBackend,) |
| 2597 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 2598 | |
| 2599 | def get_serializer_class(self): |
| 2600 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2601 | if (no_hyperlinks): |
| 2602 | return self.id_serializer_class |
| 2603 | else: |
| 2604 | return self.serializer_class |
| 2605 | |
| 2606 | def get_queryset(self): |
| 2607 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 2608 | |
| 2609 | def create(self, request, *args, **kwargs): |
| 2610 | #obj = PlanetStackPrivilege().update(request.DATA) |
| 2611 | obj = self.get_object() |
| 2612 | obj.caller = request.user |
| 2613 | if obj.can_update(request.user): |
| 2614 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 2615 | else: |
| 2616 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2617 | |
| 2618 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2619 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 2620 | serializer_class = PlanetStackPrivilegeSerializer |
| 2621 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 2622 | |
| 2623 | def get_serializer_class(self): |
| 2624 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2625 | if (no_hyperlinks): |
| 2626 | return self.id_serializer_class |
| 2627 | else: |
| 2628 | return self.serializer_class |
| 2629 | |
| 2630 | def get_queryset(self): |
| 2631 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 2632 | |
| 2633 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2634 | |
| 2635 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2636 | |
| 2637 | |
| 2638 | |
| 2639 | class UserList(generics.ListCreateAPIView): |
| 2640 | queryset = User.objects.select_related().all() |
| 2641 | serializer_class = UserSerializer |
| 2642 | id_serializer_class = UserIdSerializer |
| 2643 | filter_backends = (filters.DjangoFilterBackend,) |
| 2644 | 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',) |
| 2645 | |
| 2646 | def get_serializer_class(self): |
| 2647 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2648 | if (no_hyperlinks): |
| 2649 | return self.id_serializer_class |
| 2650 | else: |
| 2651 | return self.serializer_class |
| 2652 | |
| 2653 | def get_queryset(self): |
| 2654 | return User.select_by_user(self.request.user) |
| 2655 | |
| 2656 | def create(self, request, *args, **kwargs): |
| 2657 | #obj = User().update(request.DATA) |
| 2658 | obj = self.get_object() |
| 2659 | obj.caller = request.user |
| 2660 | if obj.can_update(request.user): |
| 2661 | return super(UserList, self).create(request, *args, **kwargs) |
| 2662 | else: |
| 2663 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2664 | |
| 2665 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2666 | queryset = User.objects.select_related().all() |
| 2667 | serializer_class = UserSerializer |
| 2668 | id_serializer_class = UserIdSerializer |
| 2669 | |
| 2670 | def get_serializer_class(self): |
| 2671 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2672 | if (no_hyperlinks): |
| 2673 | return self.id_serializer_class |
| 2674 | else: |
| 2675 | return self.serializer_class |
| 2676 | |
| 2677 | def get_queryset(self): |
| 2678 | return User.select_by_user(self.request.user) |
| 2679 | |
| 2680 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2681 | |
| 2682 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2683 | |
| 2684 | |
| 2685 | |
| 2686 | class DeploymentList(generics.ListCreateAPIView): |
| 2687 | queryset = Deployment.objects.select_related().all() |
| 2688 | serializer_class = DeploymentSerializer |
| 2689 | id_serializer_class = DeploymentIdSerializer |
| 2690 | filter_backends = (filters.DjangoFilterBackend,) |
| 2691 | 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',) |
| 2692 | |
| 2693 | def get_serializer_class(self): |
| 2694 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2695 | if (no_hyperlinks): |
| 2696 | return self.id_serializer_class |
| 2697 | else: |
| 2698 | return self.serializer_class |
| 2699 | |
| 2700 | def get_queryset(self): |
| 2701 | return Deployment.select_by_user(self.request.user) |
| 2702 | |
| 2703 | def create(self, request, *args, **kwargs): |
| 2704 | #obj = Deployment().update(request.DATA) |
| 2705 | obj = self.get_object() |
| 2706 | obj.caller = request.user |
| 2707 | if obj.can_update(request.user): |
| 2708 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 2709 | else: |
| 2710 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2711 | |
| 2712 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2713 | queryset = Deployment.objects.select_related().all() |
| 2714 | serializer_class = DeploymentSerializer |
| 2715 | id_serializer_class = DeploymentIdSerializer |
| 2716 | |
| 2717 | def get_serializer_class(self): |
| 2718 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2719 | if (no_hyperlinks): |
| 2720 | return self.id_serializer_class |
| 2721 | else: |
| 2722 | return self.serializer_class |
| 2723 | |
| 2724 | def get_queryset(self): |
| 2725 | return Deployment.select_by_user(self.request.user) |
| 2726 | |
| 2727 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2728 | |
| 2729 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2730 | |
| 2731 | |
| 2732 | |
| 2733 | class ReservationList(generics.ListCreateAPIView): |
| 2734 | queryset = Reservation.objects.select_related().all() |
| 2735 | serializer_class = ReservationSerializer |
| 2736 | id_serializer_class = ReservationIdSerializer |
| 2737 | filter_backends = (filters.DjangoFilterBackend,) |
| 2738 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 2739 | |
| 2740 | def get_serializer_class(self): |
| 2741 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2742 | if (no_hyperlinks): |
| 2743 | return self.id_serializer_class |
| 2744 | else: |
| 2745 | return self.serializer_class |
| 2746 | |
| 2747 | def get_queryset(self): |
| 2748 | return Reservation.select_by_user(self.request.user) |
| 2749 | |
| 2750 | def create(self, request, *args, **kwargs): |
| 2751 | #obj = Reservation().update(request.DATA) |
| 2752 | obj = self.get_object() |
| 2753 | obj.caller = request.user |
| 2754 | if obj.can_update(request.user): |
| 2755 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 2756 | else: |
| 2757 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2758 | |
| 2759 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2760 | queryset = Reservation.objects.select_related().all() |
| 2761 | serializer_class = ReservationSerializer |
| 2762 | id_serializer_class = ReservationIdSerializer |
| 2763 | |
| 2764 | def get_serializer_class(self): |
| 2765 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2766 | if (no_hyperlinks): |
| 2767 | return self.id_serializer_class |
| 2768 | else: |
| 2769 | return self.serializer_class |
| 2770 | |
| 2771 | def get_queryset(self): |
| 2772 | return Reservation.select_by_user(self.request.user) |
| 2773 | |
| 2774 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2775 | |
| 2776 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2777 | |
| 2778 | |
| 2779 | |
| 2780 | class SliceDeploymentsList(generics.ListCreateAPIView): |
| 2781 | queryset = SliceDeployments.objects.select_related().all() |
| 2782 | serializer_class = SliceDeploymentsSerializer |
| 2783 | id_serializer_class = SliceDeploymentsIdSerializer |
| 2784 | filter_backends = (filters.DjangoFilterBackend,) |
| 2785 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
| 2786 | |
| 2787 | def get_serializer_class(self): |
| 2788 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2789 | if (no_hyperlinks): |
| 2790 | return self.id_serializer_class |
| 2791 | else: |
| 2792 | return self.serializer_class |
| 2793 | |
| 2794 | def get_queryset(self): |
| 2795 | return SliceDeployments.select_by_user(self.request.user) |
| 2796 | |
| 2797 | def create(self, request, *args, **kwargs): |
| 2798 | #obj = SliceDeployments().update(request.DATA) |
| 2799 | obj = self.get_object() |
| 2800 | obj.caller = request.user |
| 2801 | if obj.can_update(request.user): |
| 2802 | return super(SliceDeploymentsList, self).create(request, *args, **kwargs) |
| 2803 | else: |
| 2804 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2805 | |
| 2806 | class SliceDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2807 | queryset = SliceDeployments.objects.select_related().all() |
| 2808 | serializer_class = SliceDeploymentsSerializer |
| 2809 | id_serializer_class = SliceDeploymentsIdSerializer |
| 2810 | |
| 2811 | def get_serializer_class(self): |
| 2812 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2813 | if (no_hyperlinks): |
| 2814 | return self.id_serializer_class |
| 2815 | else: |
| 2816 | return self.serializer_class |
| 2817 | |
| 2818 | def get_queryset(self): |
| 2819 | return SliceDeployments.select_by_user(self.request.user) |
| 2820 | |
| 2821 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2822 | |
| 2823 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2824 | |
| 2825 | |
| 2826 | |
| 2827 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 2828 | queryset = SitePrivilege.objects.select_related().all() |
| 2829 | serializer_class = SitePrivilegeSerializer |
| 2830 | id_serializer_class = SitePrivilegeIdSerializer |
| 2831 | filter_backends = (filters.DjangoFilterBackend,) |
| 2832 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 2833 | |
| 2834 | def get_serializer_class(self): |
| 2835 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2836 | if (no_hyperlinks): |
| 2837 | return self.id_serializer_class |
| 2838 | else: |
| 2839 | return self.serializer_class |
| 2840 | |
| 2841 | def get_queryset(self): |
| 2842 | return SitePrivilege.select_by_user(self.request.user) |
| 2843 | |
| 2844 | def create(self, request, *args, **kwargs): |
| 2845 | #obj = SitePrivilege().update(request.DATA) |
| 2846 | obj = self.get_object() |
| 2847 | obj.caller = request.user |
| 2848 | if obj.can_update(request.user): |
| 2849 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 2850 | else: |
| 2851 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2852 | |
| 2853 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2854 | queryset = SitePrivilege.objects.select_related().all() |
| 2855 | serializer_class = SitePrivilegeSerializer |
| 2856 | id_serializer_class = SitePrivilegeIdSerializer |
| 2857 | |
| 2858 | def get_serializer_class(self): |
| 2859 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2860 | if (no_hyperlinks): |
| 2861 | return self.id_serializer_class |
| 2862 | else: |
| 2863 | return self.serializer_class |
| 2864 | |
| 2865 | def get_queryset(self): |
| 2866 | return SitePrivilege.select_by_user(self.request.user) |
| 2867 | |
| 2868 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2869 | |
| 2870 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2871 | |
| 2872 | |
| 2873 | |
| 2874 | class PlanetStackList(generics.ListCreateAPIView): |
| 2875 | queryset = PlanetStack.objects.select_related().all() |
| 2876 | serializer_class = PlanetStackSerializer |
| 2877 | id_serializer_class = PlanetStackIdSerializer |
| 2878 | filter_backends = (filters.DjangoFilterBackend,) |
| 2879 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
| 2880 | |
| 2881 | def get_serializer_class(self): |
| 2882 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2883 | if (no_hyperlinks): |
| 2884 | return self.id_serializer_class |
| 2885 | else: |
| 2886 | return self.serializer_class |
| 2887 | |
| 2888 | def get_queryset(self): |
| 2889 | return PlanetStack.select_by_user(self.request.user) |
| 2890 | |
| 2891 | def create(self, request, *args, **kwargs): |
| 2892 | #obj = PlanetStack().update(request.DATA) |
| 2893 | obj = self.get_object() |
| 2894 | obj.caller = request.user |
| 2895 | if obj.can_update(request.user): |
| 2896 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
| 2897 | else: |
| 2898 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2899 | |
| 2900 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2901 | queryset = PlanetStack.objects.select_related().all() |
| 2902 | serializer_class = PlanetStackSerializer |
| 2903 | id_serializer_class = PlanetStackIdSerializer |
| 2904 | |
| 2905 | def get_serializer_class(self): |
| 2906 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2907 | if (no_hyperlinks): |
| 2908 | return self.id_serializer_class |
| 2909 | else: |
| 2910 | return self.serializer_class |
| 2911 | |
| 2912 | def get_queryset(self): |
| 2913 | return PlanetStack.select_by_user(self.request.user) |
| 2914 | |
| 2915 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2916 | |
| 2917 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2918 | |
| 2919 | |
| 2920 | |
| 2921 | class UserDeploymentsList(generics.ListCreateAPIView): |
| 2922 | queryset = UserDeployments.objects.select_related().all() |
| 2923 | serializer_class = UserDeploymentsSerializer |
| 2924 | id_serializer_class = UserDeploymentsIdSerializer |
| 2925 | filter_backends = (filters.DjangoFilterBackend,) |
| 2926 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
| 2927 | |
| 2928 | def get_serializer_class(self): |
| 2929 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2930 | if (no_hyperlinks): |
| 2931 | return self.id_serializer_class |
| 2932 | else: |
| 2933 | return self.serializer_class |
| 2934 | |
| 2935 | def get_queryset(self): |
| 2936 | return UserDeployments.select_by_user(self.request.user) |
| 2937 | |
| 2938 | def create(self, request, *args, **kwargs): |
| 2939 | #obj = UserDeployments().update(request.DATA) |
| 2940 | obj = self.get_object() |
| 2941 | obj.caller = request.user |
| 2942 | if obj.can_update(request.user): |
| 2943 | return super(UserDeploymentsList, self).create(request, *args, **kwargs) |
| 2944 | else: |
| 2945 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2946 | |
| 2947 | class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2948 | queryset = UserDeployments.objects.select_related().all() |
| 2949 | serializer_class = UserDeploymentsSerializer |
| 2950 | id_serializer_class = UserDeploymentsIdSerializer |
| 2951 | |
| 2952 | def get_serializer_class(self): |
| 2953 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2954 | if (no_hyperlinks): |
| 2955 | return self.id_serializer_class |
| 2956 | else: |
| 2957 | return self.serializer_class |
| 2958 | |
| 2959 | def get_queryset(self): |
| 2960 | return UserDeployments.select_by_user(self.request.user) |
| 2961 | |
| 2962 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2963 | |
| 2964 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2965 | |
| 2966 | |
| 2967 | |
| 2968 | class AccountList(generics.ListCreateAPIView): |
| 2969 | queryset = Account.objects.select_related().all() |
| 2970 | serializer_class = AccountSerializer |
| 2971 | id_serializer_class = AccountIdSerializer |
| 2972 | filter_backends = (filters.DjangoFilterBackend,) |
| 2973 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 2974 | |
| 2975 | def get_serializer_class(self): |
| 2976 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2977 | if (no_hyperlinks): |
| 2978 | return self.id_serializer_class |
| 2979 | else: |
| 2980 | return self.serializer_class |
| 2981 | |
| 2982 | def get_queryset(self): |
| 2983 | return Account.select_by_user(self.request.user) |
| 2984 | |
| 2985 | def create(self, request, *args, **kwargs): |
| 2986 | #obj = Account().update(request.DATA) |
| 2987 | obj = self.get_object() |
| 2988 | obj.caller = request.user |
| 2989 | if obj.can_update(request.user): |
| 2990 | return super(AccountList, self).create(request, *args, **kwargs) |
| 2991 | else: |
| 2992 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2993 | |
| 2994 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2995 | queryset = Account.objects.select_related().all() |
| 2996 | serializer_class = AccountSerializer |
| 2997 | id_serializer_class = AccountIdSerializer |
| 2998 | |
| 2999 | def get_serializer_class(self): |
| 3000 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3001 | if (no_hyperlinks): |
| 3002 | return self.id_serializer_class |
| 3003 | else: |
| 3004 | return self.serializer_class |
| 3005 | |
| 3006 | def get_queryset(self): |
| 3007 | return Account.select_by_user(self.request.user) |
| 3008 | |
| 3009 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3010 | |
| 3011 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3012 | |
| 3013 | |
| 3014 | |
| 3015 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 3016 | queryset = NetworkParameterType.objects.select_related().all() |
| 3017 | serializer_class = NetworkParameterTypeSerializer |
| 3018 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 3019 | filter_backends = (filters.DjangoFilterBackend,) |
| 3020 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 3021 | |
| 3022 | def get_serializer_class(self): |
| 3023 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3024 | if (no_hyperlinks): |
| 3025 | return self.id_serializer_class |
| 3026 | else: |
| 3027 | return self.serializer_class |
| 3028 | |
| 3029 | def get_queryset(self): |
| 3030 | return NetworkParameterType.select_by_user(self.request.user) |
| 3031 | |
| 3032 | def create(self, request, *args, **kwargs): |
| 3033 | #obj = NetworkParameterType().update(request.DATA) |
| 3034 | obj = self.get_object() |
| 3035 | obj.caller = request.user |
| 3036 | if obj.can_update(request.user): |
| 3037 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 3038 | else: |
| 3039 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3040 | |
| 3041 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3042 | queryset = NetworkParameterType.objects.select_related().all() |
| 3043 | serializer_class = NetworkParameterTypeSerializer |
| 3044 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 3045 | |
| 3046 | def get_serializer_class(self): |
| 3047 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3048 | if (no_hyperlinks): |
| 3049 | return self.id_serializer_class |
| 3050 | else: |
| 3051 | return self.serializer_class |
| 3052 | |
| 3053 | def get_queryset(self): |
| 3054 | return NetworkParameterType.select_by_user(self.request.user) |
| 3055 | |
| 3056 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3057 | |
| 3058 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3059 | |
| 3060 | |
| 3061 | |
| 3062 | class SiteCredentialList(generics.ListCreateAPIView): |
| 3063 | queryset = SiteCredential.objects.select_related().all() |
| 3064 | serializer_class = SiteCredentialSerializer |
| 3065 | id_serializer_class = SiteCredentialIdSerializer |
| 3066 | filter_backends = (filters.DjangoFilterBackend,) |
| 3067 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 3068 | |
| 3069 | def get_serializer_class(self): |
| 3070 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3071 | if (no_hyperlinks): |
| 3072 | return self.id_serializer_class |
| 3073 | else: |
| 3074 | return self.serializer_class |
| 3075 | |
| 3076 | def get_queryset(self): |
| 3077 | return SiteCredential.select_by_user(self.request.user) |
| 3078 | |
| 3079 | def create(self, request, *args, **kwargs): |
| 3080 | #obj = SiteCredential().update(request.DATA) |
| 3081 | obj = self.get_object() |
| 3082 | obj.caller = request.user |
| 3083 | if obj.can_update(request.user): |
| 3084 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 3085 | else: |
| 3086 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3087 | |
| 3088 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3089 | queryset = SiteCredential.objects.select_related().all() |
| 3090 | serializer_class = SiteCredentialSerializer |
| 3091 | id_serializer_class = SiteCredentialIdSerializer |
| 3092 | |
| 3093 | def get_serializer_class(self): |
| 3094 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3095 | if (no_hyperlinks): |
| 3096 | return self.id_serializer_class |
| 3097 | else: |
| 3098 | return self.serializer_class |
| 3099 | |
| 3100 | def get_queryset(self): |
| 3101 | return SiteCredential.select_by_user(self.request.user) |
| 3102 | |
| 3103 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3104 | |
| 3105 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3106 | |
| 3107 | |
| 3108 | |
| 3109 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 3110 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 3111 | serializer_class = DeploymentPrivilegeSerializer |
| 3112 | id_serializer_class = DeploymentPrivilegeIdSerializer |
| 3113 | filter_backends = (filters.DjangoFilterBackend,) |
| 3114 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 3115 | |
| 3116 | def get_serializer_class(self): |
| 3117 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3118 | if (no_hyperlinks): |
| 3119 | return self.id_serializer_class |
| 3120 | else: |
| 3121 | return self.serializer_class |
| 3122 | |
| 3123 | def get_queryset(self): |
| 3124 | return DeploymentPrivilege.select_by_user(self.request.user) |
| 3125 | |
| 3126 | def create(self, request, *args, **kwargs): |
| 3127 | #obj = DeploymentPrivilege().update(request.DATA) |
| 3128 | obj = self.get_object() |
| 3129 | obj.caller = request.user |
| 3130 | if obj.can_update(request.user): |
| 3131 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
| 3132 | else: |
| 3133 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3134 | |
| 3135 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3136 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 3137 | serializer_class = DeploymentPrivilegeSerializer |
| 3138 | id_serializer_class = DeploymentPrivilegeIdSerializer |
| 3139 | |
| 3140 | def get_serializer_class(self): |
| 3141 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3142 | if (no_hyperlinks): |
| 3143 | return self.id_serializer_class |
| 3144 | else: |
| 3145 | return self.serializer_class |
| 3146 | |
| 3147 | def get_queryset(self): |
| 3148 | return DeploymentPrivilege.select_by_user(self.request.user) |
| 3149 | |
| 3150 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3151 | |
| 3152 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3153 | |
| 3154 | |
| 3155 | |
| 3156 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 3157 | queryset = DeploymentRole.objects.select_related().all() |
| 3158 | serializer_class = DeploymentRoleSerializer |
| 3159 | id_serializer_class = DeploymentRoleIdSerializer |
| 3160 | filter_backends = (filters.DjangoFilterBackend,) |
| 3161 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3162 | |
| 3163 | def get_serializer_class(self): |
| 3164 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3165 | if (no_hyperlinks): |
| 3166 | return self.id_serializer_class |
| 3167 | else: |
| 3168 | return self.serializer_class |
| 3169 | |
| 3170 | def get_queryset(self): |
| 3171 | return DeploymentRole.select_by_user(self.request.user) |
| 3172 | |
| 3173 | def create(self, request, *args, **kwargs): |
| 3174 | #obj = DeploymentRole().update(request.DATA) |
| 3175 | obj = self.get_object() |
| 3176 | obj.caller = request.user |
| 3177 | if obj.can_update(request.user): |
| 3178 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
| 3179 | else: |
| 3180 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3181 | |
| 3182 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3183 | queryset = DeploymentRole.objects.select_related().all() |
| 3184 | serializer_class = DeploymentRoleSerializer |
| 3185 | id_serializer_class = DeploymentRoleIdSerializer |
| 3186 | |
| 3187 | def get_serializer_class(self): |
| 3188 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3189 | if (no_hyperlinks): |
| 3190 | return self.id_serializer_class |
| 3191 | else: |
| 3192 | return self.serializer_class |
| 3193 | |
| 3194 | def get_queryset(self): |
| 3195 | return DeploymentRole.select_by_user(self.request.user) |
| 3196 | |
| 3197 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3198 | |
| 3199 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3200 | |
| 3201 | |
| 3202 | |
| 3203 | class UserCredentialList(generics.ListCreateAPIView): |
| 3204 | queryset = UserCredential.objects.select_related().all() |
| 3205 | serializer_class = UserCredentialSerializer |
| 3206 | id_serializer_class = UserCredentialIdSerializer |
| 3207 | filter_backends = (filters.DjangoFilterBackend,) |
| 3208 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 3209 | |
| 3210 | def get_serializer_class(self): |
| 3211 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3212 | if (no_hyperlinks): |
| 3213 | return self.id_serializer_class |
| 3214 | else: |
| 3215 | return self.serializer_class |
| 3216 | |
| 3217 | def get_queryset(self): |
| 3218 | return UserCredential.select_by_user(self.request.user) |
| 3219 | |
| 3220 | def create(self, request, *args, **kwargs): |
| 3221 | #obj = UserCredential().update(request.DATA) |
| 3222 | obj = self.get_object() |
| 3223 | obj.caller = request.user |
| 3224 | if obj.can_update(request.user): |
| 3225 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 3226 | else: |
| 3227 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3228 | |
| 3229 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3230 | queryset = UserCredential.objects.select_related().all() |
| 3231 | serializer_class = UserCredentialSerializer |
| 3232 | id_serializer_class = UserCredentialIdSerializer |
| 3233 | |
| 3234 | def get_serializer_class(self): |
| 3235 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3236 | if (no_hyperlinks): |
| 3237 | return self.id_serializer_class |
| 3238 | else: |
| 3239 | return self.serializer_class |
| 3240 | |
| 3241 | def get_queryset(self): |
| 3242 | return UserCredential.select_by_user(self.request.user) |
| 3243 | |
| 3244 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3245 | |
| 3246 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3247 | |
| 3248 | |
| 3249 | |
| 3250 | class SiteDeploymentsList(generics.ListCreateAPIView): |
| 3251 | queryset = SiteDeployments.objects.select_related().all() |
| 3252 | serializer_class = SiteDeploymentsSerializer |
| 3253 | id_serializer_class = SiteDeploymentsIdSerializer |
| 3254 | filter_backends = (filters.DjangoFilterBackend,) |
| 3255 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
| 3256 | |
| 3257 | def get_serializer_class(self): |
| 3258 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3259 | if (no_hyperlinks): |
| 3260 | return self.id_serializer_class |
| 3261 | else: |
| 3262 | return self.serializer_class |
| 3263 | |
| 3264 | def get_queryset(self): |
| 3265 | return SiteDeployments.select_by_user(self.request.user) |
| 3266 | |
| 3267 | def create(self, request, *args, **kwargs): |
| 3268 | #obj = SiteDeployments().update(request.DATA) |
| 3269 | obj = self.get_object() |
| 3270 | obj.caller = request.user |
| 3271 | if obj.can_update(request.user): |
| 3272 | return super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 3273 | else: |
| 3274 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3275 | |
| 3276 | class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3277 | queryset = SiteDeployments.objects.select_related().all() |
| 3278 | serializer_class = SiteDeploymentsSerializer |
| 3279 | id_serializer_class = SiteDeploymentsIdSerializer |
| 3280 | |
| 3281 | def get_serializer_class(self): |
| 3282 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3283 | if (no_hyperlinks): |
| 3284 | return self.id_serializer_class |
| 3285 | else: |
| 3286 | return self.serializer_class |
| 3287 | |
| 3288 | def get_queryset(self): |
| 3289 | return SiteDeployments.select_by_user(self.request.user) |
| 3290 | |
| 3291 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3292 | |
| 3293 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3294 | |
| 3295 | |
| 3296 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3297 | class SliceTagList(generics.ListCreateAPIView): |
| 3298 | queryset = SliceTag.objects.select_related().all() |
| 3299 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3300 | id_serializer_class = SliceTagIdSerializer |
| 3301 | filter_backends = (filters.DjangoFilterBackend,) |
| 3302 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 3303 | |
| 3304 | def get_serializer_class(self): |
| 3305 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3306 | if (no_hyperlinks): |
| 3307 | return self.id_serializer_class |
| 3308 | else: |
| 3309 | return self.serializer_class |
| 3310 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3311 | def get_queryset(self): |
| 3312 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3313 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3314 | def create(self, request, *args, **kwargs): |
| 3315 | #obj = SliceTag().update(request.DATA) |
| 3316 | obj = self.get_object() |
| 3317 | obj.caller = request.user |
| 3318 | if obj.can_update(request.user): |
| 3319 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 3320 | else: |
| 3321 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3322 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3323 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3324 | queryset = SliceTag.objects.select_related().all() |
| 3325 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3326 | id_serializer_class = SliceTagIdSerializer |
| 3327 | |
| 3328 | def get_serializer_class(self): |
| 3329 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3330 | if (no_hyperlinks): |
| 3331 | return self.id_serializer_class |
| 3332 | else: |
| 3333 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3334 | |
| 3335 | def get_queryset(self): |
| 3336 | return SliceTag.select_by_user(self.request.user) |
| 3337 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3338 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3339 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3340 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3341 | |
| 3342 | |
| 3343 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3344 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 3345 | queryset = NetworkTemplate.objects.select_related().all() |
| 3346 | serializer_class = NetworkTemplateSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3347 | id_serializer_class = NetworkTemplateIdSerializer |
| 3348 | filter_backends = (filters.DjangoFilterBackend,) |
| 3349 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',) |
| 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 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3358 | def get_queryset(self): |
| 3359 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3360 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3361 | def create(self, request, *args, **kwargs): |
| 3362 | #obj = NetworkTemplate().update(request.DATA) |
| 3363 | obj = self.get_object() |
| 3364 | obj.caller = request.user |
| 3365 | if obj.can_update(request.user): |
| 3366 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 3367 | else: |
| 3368 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3369 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3370 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3371 | queryset = NetworkTemplate.objects.select_related().all() |
| 3372 | serializer_class = NetworkTemplateSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3373 | id_serializer_class = NetworkTemplateIdSerializer |
| 3374 | |
| 3375 | def get_serializer_class(self): |
| 3376 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3377 | if (no_hyperlinks): |
| 3378 | return self.id_serializer_class |
| 3379 | else: |
| 3380 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3381 | |
| 3382 | def get_queryset(self): |
| 3383 | return NetworkTemplate.select_by_user(self.request.user) |
| 3384 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3385 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3386 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3387 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3388 | |
| 3389 | |
| 3390 | |
| 3391 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3392 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3393 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3394 | id_serializer_class = RouterIdSerializer |
| 3395 | filter_backends = (filters.DjangoFilterBackend,) |
| 3396 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',) |
| 3397 | |
| 3398 | def get_serializer_class(self): |
| 3399 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3400 | if (no_hyperlinks): |
| 3401 | return self.id_serializer_class |
| 3402 | else: |
| 3403 | return self.serializer_class |
| 3404 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3405 | def get_queryset(self): |
| 3406 | return Router.select_by_user(self.request.user) |
| 3407 | |
| 3408 | def create(self, request, *args, **kwargs): |
| 3409 | #obj = Router().update(request.DATA) |
| 3410 | obj = self.get_object() |
| 3411 | obj.caller = request.user |
| 3412 | if obj.can_update(request.user): |
| 3413 | return super(RouterList, self).create(request, *args, **kwargs) |
| 3414 | else: |
| 3415 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3416 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3417 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3418 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3419 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3420 | id_serializer_class = RouterIdSerializer |
| 3421 | |
| 3422 | def get_serializer_class(self): |
| 3423 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3424 | if (no_hyperlinks): |
| 3425 | return self.id_serializer_class |
| 3426 | else: |
| 3427 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3428 | |
| 3429 | def get_queryset(self): |
| 3430 | return Router.select_by_user(self.request.user) |
| 3431 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3432 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3433 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3434 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3435 | |
| 3436 | |
| 3437 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3438 | class ServiceResourceList(generics.ListCreateAPIView): |
| 3439 | queryset = ServiceResource.objects.select_related().all() |
| 3440 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3441 | id_serializer_class = ServiceResourceIdSerializer |
| 3442 | filter_backends = (filters.DjangoFilterBackend,) |
| 3443 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 3444 | |
| 3445 | def get_serializer_class(self): |
| 3446 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3447 | if (no_hyperlinks): |
| 3448 | return self.id_serializer_class |
| 3449 | else: |
| 3450 | return self.serializer_class |
| 3451 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3452 | def get_queryset(self): |
| 3453 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3454 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3455 | def create(self, request, *args, **kwargs): |
| 3456 | #obj = ServiceResource().update(request.DATA) |
| 3457 | obj = self.get_object() |
| 3458 | obj.caller = request.user |
| 3459 | if obj.can_update(request.user): |
| 3460 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 3461 | else: |
| 3462 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 3463 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3464 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3465 | queryset = ServiceResource.objects.select_related().all() |
| 3466 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3467 | id_serializer_class = ServiceResourceIdSerializer |
| 3468 | |
| 3469 | def get_serializer_class(self): |
| 3470 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3471 | if (no_hyperlinks): |
| 3472 | return self.id_serializer_class |
| 3473 | else: |
| 3474 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3475 | |
| 3476 | def get_queryset(self): |
| 3477 | return ServiceResource.select_by_user(self.request.user) |
| 3478 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3479 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3480 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3481 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3482 | |
| 3483 | |
| 3484 | |