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