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 |
| 8 | |
| 9 | """ |
| 10 | Schema of the generator object: |
| 11 | all: Set of all Model objects |
| 12 | all_if(regex): Set of Model objects that match regex |
| 13 | |
| 14 | Model object: |
| 15 | plural: English plural of object name |
| 16 | camel: CamelCase version of object name |
| 17 | refs: list of references to other Model objects |
| 18 | props: list of properties minus refs |
| 19 | |
| 20 | TODO: Deal with subnets |
| 21 | """ |
| 22 | |
| 23 | # Based on api_root.py |
| 24 | |
| 25 | @api_view(['GET']) |
| 26 | def api_root(request, format=None): |
| 27 | return Response({ |
| 28 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
| 29 | 'images': reverse('image-list', request=request, format=format), |
| 30 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 31 | 'sites': reverse('site-list', request=request, format=format), |
| 32 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 33 | 'tags': reverse('tag-list', request=request, format=format), |
| 34 | 'invoices': reverse('invoice-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 35 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 36 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 37 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 38 | 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 39 | 'slices': reverse('slice-list', request=request, format=format), |
| 40 | 'networks': reverse('network-list', request=request, format=format), |
| 41 | 'services': reverse('service-list', request=request, format=format), |
| 42 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 43 | 'payments': reverse('payment-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 44 | 'charges': reverse('charge-list', request=request, format=format), |
| 45 | 'roles': reverse('role-list', request=request, format=format), |
| 46 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 47 | 'siteroles': reverse('siterole-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 48 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 49 | 'nodes': reverse('node-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 50 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
| 51 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 52 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 53 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 54 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 55 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 56 | 'users': reverse('user-list', request=request, format=format), |
| 57 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 58 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 59 | 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 60 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 61 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 62 | 'userdeploymentses': reverse('userdeployments-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 63 | 'accounts': reverse('account-list', request=request, format=format), |
| 64 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 65 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
| 66 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 67 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 68 | 'projects': reverse('project-list', request=request, format=format), |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 69 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
| 70 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
| 71 | 'routers': reverse('router-list', request=request, format=format), |
| 72 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
| 73 | |
| 74 | }) |
| 75 | |
| 76 | # Based on serializers.py |
| 77 | |
| 78 | |
| 79 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 80 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 81 | id = serializers.Field() |
| 82 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 83 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 84 | model = ServiceAttribute |
| 85 | fields = ('id','created','updated','enacted','name','value','service',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 86 | |
| 87 | |
| 88 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
| 89 | id = serializers.Field() |
| 90 | |
| 91 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 92 | model = Image |
| 93 | fields = ('id','created','updated','enacted','name','disk_format','container_format','path',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 94 | |
| 95 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 96 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 97 | id = serializers.Field() |
| 98 | |
| 99 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 100 | model = NetworkParameter |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 101 | fields = ('id','created','updated','enacted','parameter','value','content_type','object_id',) |
| 102 | |
| 103 | |
| 104 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
| 105 | id = serializers.Field() |
| 106 | |
| 107 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 108 | model = Site |
| 109 | fields = ('id','created','updated','enacted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 110 | |
| 111 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 112 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 113 | id = serializers.Field() |
| 114 | |
| 115 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 116 | model = SliceRole |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 117 | fields = ('id','created','updated','enacted','role',) |
| 118 | |
| 119 | |
| 120 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
| 121 | id = serializers.Field() |
| 122 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 123 | |
| 124 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 125 | |
| 126 | |
| 127 | |
| 128 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 129 | |
| 130 | |
| 131 | |
| 132 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
| 133 | |
| 134 | |
| 135 | |
| 136 | nodes = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='node-detail') |
| 137 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 138 | |
| 139 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 140 | model = Tag |
| 141 | fields = ('id','created','updated','enacted','service','name','value','content_type','object_id','sites','slices','slivers','nodes',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 142 | |
| 143 | |
| 144 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
| 145 | id = serializers.Field() |
| 146 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 147 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 148 | model = Invoice |
| 149 | fields = ('id','created','updated','enacted','date','account',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 150 | |
| 151 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 152 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 153 | id = serializers.Field() |
| 154 | |
| 155 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 156 | model = PlanetStackRole |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 157 | fields = ('id','created','updated','enacted','role',) |
| 158 | |
| 159 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 160 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 161 | id = serializers.Field() |
| 162 | |
| 163 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 164 | model = SlicePrivilege |
| 165 | fields = ('id','created','updated','enacted','user','slice','role',) |
| 166 | |
| 167 | |
| 168 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
| 169 | id = serializers.Field() |
| 170 | |
| 171 | class Meta: |
| 172 | model = NetworkSliver |
| 173 | fields = ('id','created','updated','enacted','network','sliver','ip','port_id',) |
| 174 | |
| 175 | |
| 176 | class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 177 | id = serializers.Field() |
| 178 | |
| 179 | class Meta: |
| 180 | model = NetworkDeployments |
| 181 | fields = ('id','created','updated','enacted','network','deployment','net_id','router_id','subnet_id','subnet',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 182 | |
| 183 | |
| 184 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
| 185 | id = serializers.Field() |
| 186 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 187 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 188 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 189 | |
| 190 | |
| 191 | |
| 192 | availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 193 | |
| 194 | |
| 195 | |
| 196 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 197 | |
| 198 | |
| 199 | |
| 200 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 201 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 202 | |
| 203 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 204 | model = Slice |
| 205 | fields = ('id','created','updated','enacted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 206 | |
| 207 | |
| 208 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
| 209 | id = serializers.Field() |
| 210 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 211 | |
| 212 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 213 | |
| 214 | |
| 215 | |
| 216 | availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 217 | |
| 218 | |
| 219 | |
| 220 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 221 | |
| 222 | |
| 223 | |
| 224 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 225 | |
| 226 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 227 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 228 | model = Network |
| 229 | fields = ('id','created','updated','enacted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 230 | |
| 231 | |
| 232 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
| 233 | id = serializers.Field() |
| 234 | |
| 235 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 236 | model = Service |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 237 | fields = ('id','created','updated','enacted','description','enabled','name','versionNumber','published',) |
| 238 | |
| 239 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 240 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 241 | id = serializers.Field() |
| 242 | |
| 243 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 244 | model = ServiceClass |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 245 | fields = ('id','created','updated','enacted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 246 | |
| 247 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 248 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 249 | id = serializers.Field() |
| 250 | |
| 251 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 252 | model = Payment |
| 253 | fields = ('id','created','updated','enacted','account','amount','date',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 254 | |
| 255 | |
| 256 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
| 257 | id = serializers.Field() |
| 258 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 259 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 260 | model = Charge |
| 261 | fields = ('id','created','updated','enacted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 262 | |
| 263 | |
| 264 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
| 265 | id = serializers.Field() |
| 266 | |
| 267 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 268 | model = Role |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 269 | fields = ('id','created','updated','enacted','role_type','role','description','content_type',) |
| 270 | |
| 271 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 272 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 273 | id = serializers.Field() |
| 274 | |
| 275 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 276 | model = UsableObject |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 277 | fields = ('id','created','updated','enacted','name',) |
| 278 | |
| 279 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 280 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
| 281 | id = serializers.Field() |
| 282 | |
| 283 | class Meta: |
| 284 | model = SiteRole |
| 285 | fields = ('id','created','updated','enacted','role',) |
| 286 | |
| 287 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 288 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
| 289 | id = serializers.Field() |
| 290 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 291 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 292 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 293 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 294 | |
| 295 | |
| 296 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 297 | |
| 298 | |
| 299 | |
| 300 | # upgradeFrom_rel_+ = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='serviceclass-detail') |
| 301 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 302 | |
| 303 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 304 | model = Sliver |
| 305 | fields = ('id','created','updated','enacted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','userData','networks','networks','upgradeFrom_rel_+',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 306 | |
| 307 | |
| 308 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
| 309 | id = serializers.Field() |
| 310 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 311 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 312 | model = Node |
| 313 | fields = ('id','created','updated','enacted','name','site','deployment',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 314 | |
| 315 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 316 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 317 | id = serializers.Field() |
| 318 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 319 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 320 | model = DashboardView |
| 321 | fields = ('id','created','updated','enacted','name','url',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 322 | |
| 323 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 324 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 325 | id = serializers.Field() |
| 326 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 327 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 328 | model = ImageDeployments |
| 329 | fields = ('id','created','updated','enacted','image','deployment','glance_image_id',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 330 | |
| 331 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 332 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 333 | id = serializers.Field() |
| 334 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 335 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 336 | model = ReservedResource |
| 337 | fields = ('id','created','updated','enacted','sliver','resource','quantity','reservationSet',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 338 | |
| 339 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 340 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 341 | id = serializers.Field() |
| 342 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 343 | class Meta: |
| 344 | model = NetworkSlice |
| 345 | fields = ('id','created','updated','enacted','network','slice',) |
| 346 | |
| 347 | |
| 348 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
| 349 | id = serializers.Field() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 350 | |
| 351 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 352 | model = UserDashboardView |
| 353 | fields = ('id','created','updated','enacted','user','dashboardView','order',) |
| 354 | |
| 355 | |
| 356 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 357 | id = serializers.Field() |
| 358 | |
| 359 | class Meta: |
| 360 | model = PlanetStackPrivilege |
| 361 | fields = ('id','created','updated','enacted','user','planetstack','role',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 362 | |
| 363 | |
| 364 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
| 365 | id = serializers.Field() |
| 366 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 367 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 368 | model = User |
| 369 | 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','timezone',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 370 | |
| 371 | |
| 372 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
| 373 | id = serializers.Field() |
| 374 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 375 | |
| 376 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 377 | |
| 378 | |
| 379 | |
| 380 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 381 | |
| 382 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 383 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 384 | model = Deployment |
| 385 | fields = ('id','created','updated','enacted','name','admin_user','admin_password','admin_tenant','auth_url','accessControl','sites','sites',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 386 | |
| 387 | |
| 388 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
| 389 | id = serializers.Field() |
| 390 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 391 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 392 | model = Reservation |
| 393 | fields = ('id','created','updated','enacted','startTime','slice','duration',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 394 | |
| 395 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 396 | class SliceDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 397 | id = serializers.Field() |
| 398 | |
| 399 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 400 | model = SliceDeployments |
| 401 | fields = ('id','created','updated','enacted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 402 | |
| 403 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 404 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 405 | id = serializers.Field() |
| 406 | |
| 407 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 408 | model = SitePrivilege |
| 409 | fields = ('id','created','updated','enacted','user','site','role',) |
| 410 | |
| 411 | |
| 412 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
| 413 | id = serializers.Field() |
| 414 | |
| 415 | class Meta: |
| 416 | model = PlanetStack |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 417 | fields = ('id','created','updated','enacted','description',) |
| 418 | |
| 419 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 420 | class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 421 | id = serializers.Field() |
| 422 | |
| 423 | class Meta: |
| 424 | model = UserDeployments |
| 425 | fields = ('id','created','updated','enacted','user','deployment','kuser_id',) |
| 426 | |
| 427 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 428 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
| 429 | id = serializers.Field() |
| 430 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 431 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 432 | model = Account |
| 433 | fields = ('id','created','updated','enacted','site',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 434 | |
| 435 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 436 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 437 | id = serializers.Field() |
| 438 | |
| 439 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 440 | model = NetworkParameterType |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 441 | fields = ('id','created','updated','enacted','name','description',) |
| 442 | |
| 443 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 444 | class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 445 | id = serializers.Field() |
| 446 | |
| 447 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 448 | model = SiteDeployments |
| 449 | fields = ('id','created','updated','enacted','site','deployment','tenant_id',) |
| 450 | |
| 451 | |
| 452 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 453 | id = serializers.Field() |
| 454 | |
| 455 | class Meta: |
| 456 | model = DeploymentPrivilege |
| 457 | fields = ('id','created','updated','enacted','user','deployment','role',) |
| 458 | |
| 459 | |
| 460 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
| 461 | id = serializers.Field() |
| 462 | |
| 463 | class Meta: |
| 464 | model = DeploymentRole |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 465 | fields = ('id','created','updated','enacted','role',) |
| 466 | |
| 467 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 468 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 469 | id = serializers.Field() |
| 470 | |
| 471 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 472 | model = Project |
| 473 | fields = ('id','created','updated','enacted','name',) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 474 | |
| 475 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 476 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 477 | id = serializers.Field() |
| 478 | |
| 479 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 480 | model = SliceTag |
| 481 | fields = ('id','created','updated','enacted','slice','name','value',) |
| 482 | |
| 483 | |
| 484 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
| 485 | id = serializers.Field() |
| 486 | |
| 487 | class Meta: |
| 488 | model = NetworkTemplate |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 489 | fields = ('id','created','updated','enacted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',) |
| 490 | |
| 491 | |
| 492 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
| 493 | id = serializers.Field() |
| 494 | |
| 495 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 496 | model = Router |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 497 | fields = ('id','created','updated','enacted','name','owner',) |
| 498 | |
| 499 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 500 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 501 | id = serializers.Field() |
| 502 | |
| 503 | class Meta: |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 504 | model = ServiceResource |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 505 | fields = ('id','created','updated','enacted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 506 | |
| 507 | |
| 508 | serializerLookUp = { |
| 509 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 510 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 511 | |
| 512 | Image: ImageSerializer, |
| 513 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 514 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 515 | |
| 516 | Site: SiteSerializer, |
| 517 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 518 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 519 | |
| 520 | Tag: TagSerializer, |
| 521 | |
| 522 | Invoice: InvoiceSerializer, |
| 523 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 524 | PlanetStackRole: PlanetStackRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 525 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 526 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 527 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 528 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 529 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 530 | NetworkDeployments: NetworkDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 531 | |
| 532 | Slice: SliceSerializer, |
| 533 | |
| 534 | Network: NetworkSerializer, |
| 535 | |
| 536 | Service: ServiceSerializer, |
| 537 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 538 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 539 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 540 | Payment: PaymentSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 541 | |
| 542 | Charge: ChargeSerializer, |
| 543 | |
| 544 | Role: RoleSerializer, |
| 545 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 546 | UsableObject: UsableObjectSerializer, |
| 547 | |
| 548 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 549 | |
| 550 | Sliver: SliverSerializer, |
| 551 | |
| 552 | Node: NodeSerializer, |
| 553 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 554 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 555 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 556 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 557 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 558 | ReservedResource: ReservedResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 559 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 560 | NetworkSlice: NetworkSliceSerializer, |
| 561 | |
| 562 | UserDashboardView: UserDashboardViewSerializer, |
| 563 | |
| 564 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 565 | |
| 566 | User: UserSerializer, |
| 567 | |
| 568 | Deployment: DeploymentSerializer, |
| 569 | |
| 570 | Reservation: ReservationSerializer, |
| 571 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 572 | SliceDeployments: SliceDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 573 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 574 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 575 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 576 | PlanetStack: PlanetStackSerializer, |
| 577 | |
| 578 | UserDeployments: UserDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 579 | |
| 580 | Account: AccountSerializer, |
| 581 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 582 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 583 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 584 | SiteDeployments: SiteDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 585 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 586 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 587 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 588 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 589 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 590 | Project: ProjectSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 591 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 592 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 593 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 594 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 595 | |
| 596 | Router: RouterSerializer, |
| 597 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 598 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 599 | |
| 600 | None: None, |
| 601 | } |
| 602 | |
| 603 | # Based on core/views/*.py |
| 604 | |
| 605 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 606 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 607 | queryset = ServiceAttribute.objects.select_related().all() |
| 608 | serializer_class = ServiceAttributeSerializer |
| 609 | |
| 610 | def get_queryset(self): |
| 611 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 612 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 613 | def create(self, request, *args, **kwargs): |
| 614 | #obj = ServiceAttribute().update(request.DATA) |
| 615 | obj = self.get_object() |
| 616 | obj.caller = request.user |
| 617 | if obj.can_update(request.user): |
| 618 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 619 | else: |
| 620 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 621 | |
| 622 | class ServiceAttributeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 623 | queryset = ServiceAttribute.objects.select_related().all() |
| 624 | serializer_class = ServiceAttributeSerializer |
| 625 | |
| 626 | def get_queryset(self): |
| 627 | return ServiceAttribute.select_by_user(self.request.user) |
| 628 | |
| 629 | def update(self, request, *args, **kwargs): |
| 630 | obj = self.get_object() |
| 631 | if obj.can_update(request.user): |
| 632 | return super(ServiceAttributeDetail, self).update(request, *args, **kwargs) |
| 633 | else: |
| 634 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 635 | |
| 636 | def destroy(self, request, *args, **kwargs): |
| 637 | obj = self.get_object() |
| 638 | if obj.can_update(request.user): |
| 639 | return super(ServiceAttributeDetail, self).destroy(request, *args, **kwargs) |
| 640 | else: |
| 641 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 642 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 643 | |
| 644 | |
| 645 | |
| 646 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 647 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 648 | serializer_class = ImageSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 649 | |
| 650 | def get_queryset(self): |
| 651 | return Image.select_by_user(self.request.user) |
| 652 | |
| 653 | def create(self, request, *args, **kwargs): |
| 654 | #obj = Image().update(request.DATA) |
| 655 | obj = self.get_object() |
| 656 | obj.caller = request.user |
| 657 | if obj.can_update(request.user): |
| 658 | return super(ImageList, self).create(request, *args, **kwargs) |
| 659 | else: |
| 660 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 661 | |
| 662 | class ImageDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 663 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 664 | serializer_class = ImageSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 665 | |
| 666 | def get_queryset(self): |
| 667 | return Image.select_by_user(self.request.user) |
| 668 | |
| 669 | def update(self, request, *args, **kwargs): |
| 670 | obj = self.get_object() |
| 671 | if obj.can_update(request.user): |
| 672 | return super(ImageDetail, self).update(request, *args, **kwargs) |
| 673 | else: |
| 674 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 675 | |
| 676 | def destroy(self, request, *args, **kwargs): |
| 677 | obj = self.get_object() |
| 678 | if obj.can_update(request.user): |
| 679 | return super(ImageDetail, self).destroy(request, *args, **kwargs) |
| 680 | else: |
| 681 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 682 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 683 | |
| 684 | |
| 685 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 686 | class NetworkParameterList(generics.ListCreateAPIView): |
| 687 | queryset = NetworkParameter.objects.select_related().all() |
| 688 | serializer_class = NetworkParameterSerializer |
| 689 | |
| 690 | def get_queryset(self): |
| 691 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 692 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 693 | def create(self, request, *args, **kwargs): |
| 694 | #obj = NetworkParameter().update(request.DATA) |
| 695 | obj = self.get_object() |
| 696 | obj.caller = request.user |
| 697 | if obj.can_update(request.user): |
| 698 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 699 | else: |
| 700 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 701 | |
| 702 | class NetworkParameterDetail(generics.RetrieveUpdateDestroyAPIView): |
| 703 | queryset = NetworkParameter.objects.select_related().all() |
| 704 | serializer_class = NetworkParameterSerializer |
| 705 | |
| 706 | def get_queryset(self): |
| 707 | return NetworkParameter.select_by_user(self.request.user) |
| 708 | |
| 709 | def update(self, request, *args, **kwargs): |
| 710 | obj = self.get_object() |
| 711 | if obj.can_update(request.user): |
| 712 | return super(NetworkParameterDetail, self).update(request, *args, **kwargs) |
| 713 | else: |
| 714 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 715 | |
| 716 | def destroy(self, request, *args, **kwargs): |
| 717 | obj = self.get_object() |
| 718 | if obj.can_update(request.user): |
| 719 | return super(NetworkParameterDetail, self).destroy(request, *args, **kwargs) |
| 720 | else: |
| 721 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 722 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 723 | |
| 724 | |
| 725 | |
| 726 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 727 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 728 | serializer_class = SiteSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 729 | |
| 730 | def get_queryset(self): |
| 731 | return Site.select_by_user(self.request.user) |
| 732 | |
| 733 | def create(self, request, *args, **kwargs): |
| 734 | #obj = Site().update(request.DATA) |
| 735 | obj = self.get_object() |
| 736 | obj.caller = request.user |
| 737 | if obj.can_update(request.user): |
| 738 | return super(SiteList, self).create(request, *args, **kwargs) |
| 739 | else: |
| 740 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 741 | |
| 742 | class SiteDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 743 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 744 | serializer_class = SiteSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 745 | |
| 746 | def get_queryset(self): |
| 747 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 748 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 749 | def update(self, request, *args, **kwargs): |
| 750 | obj = self.get_object() |
| 751 | if obj.can_update(request.user): |
| 752 | return super(SiteDetail, self).update(request, *args, **kwargs) |
| 753 | else: |
| 754 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 755 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 756 | def destroy(self, request, *args, **kwargs): |
| 757 | obj = self.get_object() |
| 758 | if obj.can_update(request.user): |
| 759 | return super(SiteDetail, self).destroy(request, *args, **kwargs) |
| 760 | else: |
| 761 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
| 766 | class SliceRoleList(generics.ListCreateAPIView): |
| 767 | queryset = SliceRole.objects.select_related().all() |
| 768 | serializer_class = SliceRoleSerializer |
| 769 | |
| 770 | def get_queryset(self): |
| 771 | return SliceRole.select_by_user(self.request.user) |
| 772 | |
| 773 | def create(self, request, *args, **kwargs): |
| 774 | #obj = SliceRole().update(request.DATA) |
| 775 | obj = self.get_object() |
| 776 | obj.caller = request.user |
| 777 | if obj.can_update(request.user): |
| 778 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 779 | else: |
| 780 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 781 | |
| 782 | class SliceRoleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 783 | queryset = SliceRole.objects.select_related().all() |
| 784 | serializer_class = SliceRoleSerializer |
| 785 | |
| 786 | def get_queryset(self): |
| 787 | return SliceRole.select_by_user(self.request.user) |
| 788 | |
| 789 | def update(self, request, *args, **kwargs): |
| 790 | obj = self.get_object() |
| 791 | if obj.can_update(request.user): |
| 792 | return super(SliceRoleDetail, self).update(request, *args, **kwargs) |
| 793 | else: |
| 794 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 795 | |
| 796 | def destroy(self, request, *args, **kwargs): |
| 797 | obj = self.get_object() |
| 798 | if obj.can_update(request.user): |
| 799 | return super(SliceRoleDetail, self).destroy(request, *args, **kwargs) |
| 800 | else: |
| 801 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 802 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 803 | |
| 804 | |
| 805 | |
| 806 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 807 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 808 | serializer_class = TagSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 809 | |
| 810 | def get_queryset(self): |
| 811 | return Tag.select_by_user(self.request.user) |
| 812 | |
| 813 | def create(self, request, *args, **kwargs): |
| 814 | #obj = Tag().update(request.DATA) |
| 815 | obj = self.get_object() |
| 816 | obj.caller = request.user |
| 817 | if obj.can_update(request.user): |
| 818 | return super(TagList, self).create(request, *args, **kwargs) |
| 819 | else: |
| 820 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 821 | |
| 822 | class TagDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 823 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 824 | serializer_class = TagSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 825 | |
| 826 | def get_queryset(self): |
| 827 | return Tag.select_by_user(self.request.user) |
| 828 | |
| 829 | def update(self, request, *args, **kwargs): |
| 830 | obj = self.get_object() |
| 831 | if obj.can_update(request.user): |
| 832 | return super(TagDetail, self).update(request, *args, **kwargs) |
| 833 | else: |
| 834 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 835 | |
| 836 | def destroy(self, request, *args, **kwargs): |
| 837 | obj = self.get_object() |
| 838 | if obj.can_update(request.user): |
| 839 | return super(TagDetail, self).destroy(request, *args, **kwargs) |
| 840 | else: |
| 841 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 842 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 843 | |
| 844 | |
| 845 | |
| 846 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 847 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 848 | serializer_class = InvoiceSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 849 | |
| 850 | def get_queryset(self): |
| 851 | return Invoice.select_by_user(self.request.user) |
| 852 | |
| 853 | def create(self, request, *args, **kwargs): |
| 854 | #obj = Invoice().update(request.DATA) |
| 855 | obj = self.get_object() |
| 856 | obj.caller = request.user |
| 857 | if obj.can_update(request.user): |
| 858 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 859 | else: |
| 860 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 861 | |
| 862 | class InvoiceDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 863 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 864 | serializer_class = InvoiceSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 865 | |
| 866 | def get_queryset(self): |
| 867 | return Invoice.select_by_user(self.request.user) |
| 868 | |
| 869 | def update(self, request, *args, **kwargs): |
| 870 | obj = self.get_object() |
| 871 | if obj.can_update(request.user): |
| 872 | return super(InvoiceDetail, self).update(request, *args, **kwargs) |
| 873 | else: |
| 874 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 875 | |
| 876 | def destroy(self, request, *args, **kwargs): |
| 877 | obj = self.get_object() |
| 878 | if obj.can_update(request.user): |
| 879 | return super(InvoiceDetail, self).destroy(request, *args, **kwargs) |
| 880 | else: |
| 881 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 882 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 883 | |
| 884 | |
| 885 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 886 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 887 | queryset = PlanetStackRole.objects.select_related().all() |
| 888 | serializer_class = PlanetStackRoleSerializer |
| 889 | |
| 890 | def get_queryset(self): |
| 891 | return PlanetStackRole.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 892 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 893 | def create(self, request, *args, **kwargs): |
| 894 | #obj = PlanetStackRole().update(request.DATA) |
| 895 | obj = self.get_object() |
| 896 | obj.caller = request.user |
| 897 | if obj.can_update(request.user): |
| 898 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 899 | else: |
| 900 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 901 | |
| 902 | class PlanetStackRoleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 903 | queryset = PlanetStackRole.objects.select_related().all() |
| 904 | serializer_class = PlanetStackRoleSerializer |
| 905 | |
| 906 | def get_queryset(self): |
| 907 | return PlanetStackRole.select_by_user(self.request.user) |
| 908 | |
| 909 | def update(self, request, *args, **kwargs): |
| 910 | obj = self.get_object() |
| 911 | if obj.can_update(request.user): |
| 912 | return super(PlanetStackRoleDetail, self).update(request, *args, **kwargs) |
| 913 | else: |
| 914 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 915 | |
| 916 | def destroy(self, request, *args, **kwargs): |
| 917 | obj = self.get_object() |
| 918 | if obj.can_update(request.user): |
| 919 | return super(PlanetStackRoleDetail, self).destroy(request, *args, **kwargs) |
| 920 | else: |
| 921 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 922 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 923 | |
| 924 | |
| 925 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 926 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 927 | queryset = SlicePrivilege.objects.select_related().all() |
| 928 | serializer_class = SlicePrivilegeSerializer |
| 929 | |
| 930 | def get_queryset(self): |
| 931 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 932 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 933 | def create(self, request, *args, **kwargs): |
| 934 | #obj = SlicePrivilege().update(request.DATA) |
| 935 | obj = self.get_object() |
| 936 | obj.caller = request.user |
| 937 | if obj.can_update(request.user): |
| 938 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 939 | else: |
| 940 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 941 | |
| 942 | class SlicePrivilegeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 943 | queryset = SlicePrivilege.objects.select_related().all() |
| 944 | serializer_class = SlicePrivilegeSerializer |
| 945 | |
| 946 | def get_queryset(self): |
| 947 | return SlicePrivilege.select_by_user(self.request.user) |
| 948 | |
| 949 | def update(self, request, *args, **kwargs): |
| 950 | obj = self.get_object() |
| 951 | if obj.can_update(request.user): |
| 952 | return super(SlicePrivilegeDetail, self).update(request, *args, **kwargs) |
| 953 | else: |
| 954 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 955 | |
| 956 | def destroy(self, request, *args, **kwargs): |
| 957 | obj = self.get_object() |
| 958 | if obj.can_update(request.user): |
| 959 | return super(SlicePrivilegeDetail, self).destroy(request, *args, **kwargs) |
| 960 | else: |
| 961 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 962 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 963 | |
| 964 | |
| 965 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 966 | class NetworkSliverList(generics.ListCreateAPIView): |
| 967 | queryset = NetworkSliver.objects.select_related().all() |
| 968 | serializer_class = NetworkSliverSerializer |
| 969 | |
| 970 | def get_queryset(self): |
| 971 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 972 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 973 | def create(self, request, *args, **kwargs): |
| 974 | #obj = NetworkSliver().update(request.DATA) |
| 975 | obj = self.get_object() |
| 976 | obj.caller = request.user |
| 977 | if obj.can_update(request.user): |
| 978 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 979 | else: |
| 980 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 981 | |
| 982 | class NetworkSliverDetail(generics.RetrieveUpdateDestroyAPIView): |
| 983 | queryset = NetworkSliver.objects.select_related().all() |
| 984 | serializer_class = NetworkSliverSerializer |
| 985 | |
| 986 | def get_queryset(self): |
| 987 | return NetworkSliver.select_by_user(self.request.user) |
| 988 | |
| 989 | def update(self, request, *args, **kwargs): |
| 990 | obj = self.get_object() |
| 991 | if obj.can_update(request.user): |
| 992 | return super(NetworkSliverDetail, self).update(request, *args, **kwargs) |
| 993 | else: |
| 994 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 995 | |
| 996 | def destroy(self, request, *args, **kwargs): |
| 997 | obj = self.get_object() |
| 998 | if obj.can_update(request.user): |
| 999 | return super(NetworkSliverDetail, self).destroy(request, *args, **kwargs) |
| 1000 | else: |
| 1001 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1002 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1003 | |
| 1004 | |
| 1005 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1006 | class NetworkDeploymentsList(generics.ListCreateAPIView): |
| 1007 | queryset = NetworkDeployments.objects.select_related().all() |
| 1008 | serializer_class = NetworkDeploymentsSerializer |
| 1009 | |
| 1010 | def get_queryset(self): |
| 1011 | return NetworkDeployments.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1012 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1013 | def create(self, request, *args, **kwargs): |
| 1014 | #obj = NetworkDeployments().update(request.DATA) |
| 1015 | obj = self.get_object() |
| 1016 | obj.caller = request.user |
| 1017 | if obj.can_update(request.user): |
| 1018 | return super(NetworkDeploymentsList, self).create(request, *args, **kwargs) |
| 1019 | else: |
| 1020 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1021 | |
| 1022 | class NetworkDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1023 | queryset = NetworkDeployments.objects.select_related().all() |
| 1024 | serializer_class = NetworkDeploymentsSerializer |
| 1025 | |
| 1026 | def get_queryset(self): |
| 1027 | return NetworkDeployments.select_by_user(self.request.user) |
| 1028 | |
| 1029 | def update(self, request, *args, **kwargs): |
| 1030 | obj = self.get_object() |
| 1031 | if obj.can_update(request.user): |
| 1032 | return super(NetworkDeploymentsDetail, self).update(request, *args, **kwargs) |
| 1033 | else: |
| 1034 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1035 | |
| 1036 | def destroy(self, request, *args, **kwargs): |
| 1037 | obj = self.get_object() |
| 1038 | if obj.can_update(request.user): |
| 1039 | return super(NetworkDeploymentsDetail, self).destroy(request, *args, **kwargs) |
| 1040 | else: |
| 1041 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1042 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1043 | |
| 1044 | |
| 1045 | |
| 1046 | class SliceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1047 | queryset = Slice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1048 | serializer_class = SliceSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1049 | |
| 1050 | def get_queryset(self): |
| 1051 | return Slice.select_by_user(self.request.user) |
| 1052 | |
| 1053 | def create(self, request, *args, **kwargs): |
| 1054 | #obj = Slice().update(request.DATA) |
| 1055 | obj = self.get_object() |
| 1056 | obj.caller = request.user |
| 1057 | if obj.can_update(request.user): |
| 1058 | return super(SliceList, self).create(request, *args, **kwargs) |
| 1059 | else: |
| 1060 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1061 | |
| 1062 | class SliceDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1063 | queryset = Slice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1064 | serializer_class = SliceSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1065 | |
| 1066 | def get_queryset(self): |
| 1067 | return Slice.select_by_user(self.request.user) |
| 1068 | |
| 1069 | def update(self, request, *args, **kwargs): |
| 1070 | obj = self.get_object() |
| 1071 | if obj.can_update(request.user): |
| 1072 | return super(SliceDetail, self).update(request, *args, **kwargs) |
| 1073 | else: |
| 1074 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1075 | |
| 1076 | def destroy(self, request, *args, **kwargs): |
| 1077 | obj = self.get_object() |
| 1078 | if obj.can_update(request.user): |
| 1079 | return super(SliceDetail, self).destroy(request, *args, **kwargs) |
| 1080 | else: |
| 1081 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1082 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1083 | |
| 1084 | |
| 1085 | |
| 1086 | class NetworkList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1087 | queryset = Network.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1088 | serializer_class = NetworkSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1089 | |
| 1090 | def get_queryset(self): |
| 1091 | return Network.select_by_user(self.request.user) |
| 1092 | |
| 1093 | def create(self, request, *args, **kwargs): |
| 1094 | #obj = Network().update(request.DATA) |
| 1095 | obj = self.get_object() |
| 1096 | obj.caller = request.user |
| 1097 | if obj.can_update(request.user): |
| 1098 | return super(NetworkList, self).create(request, *args, **kwargs) |
| 1099 | else: |
| 1100 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1101 | |
| 1102 | class NetworkDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1103 | queryset = Network.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1104 | serializer_class = NetworkSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1105 | |
| 1106 | def get_queryset(self): |
| 1107 | return Network.select_by_user(self.request.user) |
| 1108 | |
| 1109 | def update(self, request, *args, **kwargs): |
| 1110 | obj = self.get_object() |
| 1111 | if obj.can_update(request.user): |
| 1112 | return super(NetworkDetail, self).update(request, *args, **kwargs) |
| 1113 | else: |
| 1114 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1115 | |
| 1116 | def destroy(self, request, *args, **kwargs): |
| 1117 | obj = self.get_object() |
| 1118 | if obj.can_update(request.user): |
| 1119 | return super(NetworkDetail, self).destroy(request, *args, **kwargs) |
| 1120 | else: |
| 1121 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1122 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1123 | |
| 1124 | |
| 1125 | |
| 1126 | class ServiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1127 | queryset = Service.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1128 | serializer_class = ServiceSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1129 | |
| 1130 | def get_queryset(self): |
| 1131 | return Service.select_by_user(self.request.user) |
| 1132 | |
| 1133 | def create(self, request, *args, **kwargs): |
| 1134 | #obj = Service().update(request.DATA) |
| 1135 | obj = self.get_object() |
| 1136 | obj.caller = request.user |
| 1137 | if obj.can_update(request.user): |
| 1138 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 1139 | else: |
| 1140 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1141 | |
| 1142 | class ServiceDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1143 | queryset = Service.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1144 | serializer_class = ServiceSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1145 | |
| 1146 | def get_queryset(self): |
| 1147 | return Service.select_by_user(self.request.user) |
| 1148 | |
| 1149 | def update(self, request, *args, **kwargs): |
| 1150 | obj = self.get_object() |
| 1151 | if obj.can_update(request.user): |
| 1152 | return super(ServiceDetail, self).update(request, *args, **kwargs) |
| 1153 | else: |
| 1154 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1155 | |
| 1156 | def destroy(self, request, *args, **kwargs): |
| 1157 | obj = self.get_object() |
| 1158 | if obj.can_update(request.user): |
| 1159 | return super(ServiceDetail, self).destroy(request, *args, **kwargs) |
| 1160 | else: |
| 1161 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1162 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1163 | |
| 1164 | |
| 1165 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1166 | class ServiceClassList(generics.ListCreateAPIView): |
| 1167 | queryset = ServiceClass.objects.select_related().all() |
| 1168 | serializer_class = ServiceClassSerializer |
| 1169 | |
| 1170 | def get_queryset(self): |
| 1171 | return ServiceClass.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1172 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1173 | def create(self, request, *args, **kwargs): |
| 1174 | #obj = ServiceClass().update(request.DATA) |
| 1175 | obj = self.get_object() |
| 1176 | obj.caller = request.user |
| 1177 | if obj.can_update(request.user): |
| 1178 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 1179 | else: |
| 1180 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1181 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1182 | class ServiceClassDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1183 | queryset = ServiceClass.objects.select_related().all() |
| 1184 | serializer_class = ServiceClassSerializer |
| 1185 | |
| 1186 | def get_queryset(self): |
| 1187 | return ServiceClass.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1188 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1189 | def update(self, request, *args, **kwargs): |
| 1190 | obj = self.get_object() |
| 1191 | if obj.can_update(request.user): |
| 1192 | return super(ServiceClassDetail, self).update(request, *args, **kwargs) |
| 1193 | else: |
| 1194 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1195 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1196 | def destroy(self, request, *args, **kwargs): |
| 1197 | obj = self.get_object() |
| 1198 | if obj.can_update(request.user): |
| 1199 | return super(ServiceClassDetail, self).destroy(request, *args, **kwargs) |
| 1200 | else: |
| 1201 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1202 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1203 | |
| 1204 | |
| 1205 | |
| 1206 | class PaymentList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1207 | queryset = Payment.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1208 | serializer_class = PaymentSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1209 | |
| 1210 | def get_queryset(self): |
| 1211 | return Payment.select_by_user(self.request.user) |
| 1212 | |
| 1213 | def create(self, request, *args, **kwargs): |
| 1214 | #obj = Payment().update(request.DATA) |
| 1215 | obj = self.get_object() |
| 1216 | obj.caller = request.user |
| 1217 | if obj.can_update(request.user): |
| 1218 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 1219 | else: |
| 1220 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1221 | |
| 1222 | class PaymentDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1223 | queryset = Payment.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1224 | serializer_class = PaymentSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1225 | |
| 1226 | def get_queryset(self): |
| 1227 | return Payment.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(PaymentDetail, 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(PaymentDetail, 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 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1246 | class ChargeList(generics.ListCreateAPIView): |
| 1247 | queryset = Charge.objects.select_related().all() |
| 1248 | serializer_class = ChargeSerializer |
| 1249 | |
| 1250 | def get_queryset(self): |
| 1251 | return Charge.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1252 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1253 | def create(self, request, *args, **kwargs): |
| 1254 | #obj = Charge().update(request.DATA) |
| 1255 | obj = self.get_object() |
| 1256 | obj.caller = request.user |
| 1257 | if obj.can_update(request.user): |
| 1258 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 1259 | else: |
| 1260 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1261 | |
| 1262 | class ChargeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1263 | queryset = Charge.objects.select_related().all() |
| 1264 | serializer_class = ChargeSerializer |
| 1265 | |
| 1266 | def get_queryset(self): |
| 1267 | return Charge.select_by_user(self.request.user) |
| 1268 | |
| 1269 | def update(self, request, *args, **kwargs): |
| 1270 | obj = self.get_object() |
| 1271 | if obj.can_update(request.user): |
| 1272 | return super(ChargeDetail, self).update(request, *args, **kwargs) |
| 1273 | else: |
| 1274 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1275 | |
| 1276 | def destroy(self, request, *args, **kwargs): |
| 1277 | obj = self.get_object() |
| 1278 | if obj.can_update(request.user): |
| 1279 | return super(ChargeDetail, self).destroy(request, *args, **kwargs) |
| 1280 | else: |
| 1281 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1282 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1283 | |
| 1284 | |
| 1285 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1286 | class RoleList(generics.ListCreateAPIView): |
| 1287 | queryset = Role.objects.select_related().all() |
| 1288 | serializer_class = RoleSerializer |
| 1289 | |
| 1290 | def get_queryset(self): |
| 1291 | return Role.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1292 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1293 | def create(self, request, *args, **kwargs): |
| 1294 | #obj = Role().update(request.DATA) |
| 1295 | obj = self.get_object() |
| 1296 | obj.caller = request.user |
| 1297 | if obj.can_update(request.user): |
| 1298 | return super(RoleList, self).create(request, *args, **kwargs) |
| 1299 | else: |
| 1300 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1301 | |
| 1302 | class RoleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1303 | queryset = Role.objects.select_related().all() |
| 1304 | serializer_class = RoleSerializer |
| 1305 | |
| 1306 | def get_queryset(self): |
| 1307 | return Role.select_by_user(self.request.user) |
| 1308 | |
| 1309 | def update(self, request, *args, **kwargs): |
| 1310 | obj = self.get_object() |
| 1311 | if obj.can_update(request.user): |
| 1312 | return super(RoleDetail, self).update(request, *args, **kwargs) |
| 1313 | else: |
| 1314 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1315 | |
| 1316 | def destroy(self, request, *args, **kwargs): |
| 1317 | obj = self.get_object() |
| 1318 | if obj.can_update(request.user): |
| 1319 | return super(RoleDetail, self).destroy(request, *args, **kwargs) |
| 1320 | else: |
| 1321 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1322 | |
| 1323 | |
| 1324 | |
| 1325 | |
| 1326 | class UsableObjectList(generics.ListCreateAPIView): |
| 1327 | queryset = UsableObject.objects.select_related().all() |
| 1328 | serializer_class = UsableObjectSerializer |
| 1329 | |
| 1330 | def get_queryset(self): |
| 1331 | return UsableObject.select_by_user(self.request.user) |
| 1332 | |
| 1333 | def create(self, request, *args, **kwargs): |
| 1334 | #obj = UsableObject().update(request.DATA) |
| 1335 | obj = self.get_object() |
| 1336 | obj.caller = request.user |
| 1337 | if obj.can_update(request.user): |
| 1338 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 1339 | else: |
| 1340 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1341 | |
| 1342 | class UsableObjectDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1343 | queryset = UsableObject.objects.select_related().all() |
| 1344 | serializer_class = UsableObjectSerializer |
| 1345 | |
| 1346 | def get_queryset(self): |
| 1347 | return UsableObject.select_by_user(self.request.user) |
| 1348 | |
| 1349 | def update(self, request, *args, **kwargs): |
| 1350 | obj = self.get_object() |
| 1351 | if obj.can_update(request.user): |
| 1352 | return super(UsableObjectDetail, self).update(request, *args, **kwargs) |
| 1353 | else: |
| 1354 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1355 | |
| 1356 | def destroy(self, request, *args, **kwargs): |
| 1357 | obj = self.get_object() |
| 1358 | if obj.can_update(request.user): |
| 1359 | return super(UsableObjectDetail, self).destroy(request, *args, **kwargs) |
| 1360 | else: |
| 1361 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1362 | |
| 1363 | |
| 1364 | |
| 1365 | |
| 1366 | class SiteRoleList(generics.ListCreateAPIView): |
| 1367 | queryset = SiteRole.objects.select_related().all() |
| 1368 | serializer_class = SiteRoleSerializer |
| 1369 | |
| 1370 | def get_queryset(self): |
| 1371 | return SiteRole.select_by_user(self.request.user) |
| 1372 | |
| 1373 | def create(self, request, *args, **kwargs): |
| 1374 | #obj = SiteRole().update(request.DATA) |
| 1375 | obj = self.get_object() |
| 1376 | obj.caller = request.user |
| 1377 | if obj.can_update(request.user): |
| 1378 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 1379 | else: |
| 1380 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1381 | |
| 1382 | class SiteRoleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1383 | queryset = SiteRole.objects.select_related().all() |
| 1384 | serializer_class = SiteRoleSerializer |
| 1385 | |
| 1386 | def get_queryset(self): |
| 1387 | return SiteRole.select_by_user(self.request.user) |
| 1388 | |
| 1389 | def update(self, request, *args, **kwargs): |
| 1390 | obj = self.get_object() |
| 1391 | if obj.can_update(request.user): |
| 1392 | return super(SiteRoleDetail, self).update(request, *args, **kwargs) |
| 1393 | else: |
| 1394 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1395 | |
| 1396 | def destroy(self, request, *args, **kwargs): |
| 1397 | obj = self.get_object() |
| 1398 | if obj.can_update(request.user): |
| 1399 | return super(SiteRoleDetail, self).destroy(request, *args, **kwargs) |
| 1400 | else: |
| 1401 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1402 | |
| 1403 | |
| 1404 | |
| 1405 | |
| 1406 | class SliverList(generics.ListCreateAPIView): |
| 1407 | queryset = Sliver.objects.select_related().all() |
| 1408 | serializer_class = SliverSerializer |
| 1409 | |
| 1410 | def get_queryset(self): |
| 1411 | return Sliver.select_by_user(self.request.user) |
| 1412 | |
| 1413 | def create(self, request, *args, **kwargs): |
| 1414 | #obj = Sliver().update(request.DATA) |
| 1415 | obj = self.get_object() |
| 1416 | obj.caller = request.user |
| 1417 | if obj.can_update(request.user): |
| 1418 | return super(SliverList, self).create(request, *args, **kwargs) |
| 1419 | else: |
| 1420 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1421 | |
| 1422 | class SliverDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1423 | queryset = Sliver.objects.select_related().all() |
| 1424 | serializer_class = SliverSerializer |
| 1425 | |
| 1426 | def get_queryset(self): |
| 1427 | return Sliver.select_by_user(self.request.user) |
| 1428 | |
| 1429 | def update(self, request, *args, **kwargs): |
| 1430 | obj = self.get_object() |
| 1431 | if obj.can_update(request.user): |
| 1432 | return super(SliverDetail, self).update(request, *args, **kwargs) |
| 1433 | else: |
| 1434 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1435 | |
| 1436 | def destroy(self, request, *args, **kwargs): |
| 1437 | obj = self.get_object() |
| 1438 | if obj.can_update(request.user): |
| 1439 | return super(SliverDetail, self).destroy(request, *args, **kwargs) |
| 1440 | else: |
| 1441 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1442 | |
| 1443 | |
| 1444 | |
| 1445 | |
| 1446 | class NodeList(generics.ListCreateAPIView): |
| 1447 | queryset = Node.objects.select_related().all() |
| 1448 | serializer_class = NodeSerializer |
| 1449 | |
| 1450 | def get_queryset(self): |
| 1451 | return Node.select_by_user(self.request.user) |
| 1452 | |
| 1453 | def create(self, request, *args, **kwargs): |
| 1454 | #obj = Node().update(request.DATA) |
| 1455 | obj = self.get_object() |
| 1456 | obj.caller = request.user |
| 1457 | if obj.can_update(request.user): |
| 1458 | return super(NodeList, self).create(request, *args, **kwargs) |
| 1459 | else: |
| 1460 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1461 | |
| 1462 | class NodeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1463 | queryset = Node.objects.select_related().all() |
| 1464 | serializer_class = NodeSerializer |
| 1465 | |
| 1466 | def get_queryset(self): |
| 1467 | return Node.select_by_user(self.request.user) |
| 1468 | |
| 1469 | def update(self, request, *args, **kwargs): |
| 1470 | obj = self.get_object() |
| 1471 | if obj.can_update(request.user): |
| 1472 | return super(NodeDetail, self).update(request, *args, **kwargs) |
| 1473 | else: |
| 1474 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1475 | |
| 1476 | def destroy(self, request, *args, **kwargs): |
| 1477 | obj = self.get_object() |
| 1478 | if obj.can_update(request.user): |
| 1479 | return super(NodeDetail, self).destroy(request, *args, **kwargs) |
| 1480 | else: |
| 1481 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1482 | |
| 1483 | |
| 1484 | |
| 1485 | |
| 1486 | class DashboardViewList(generics.ListCreateAPIView): |
| 1487 | queryset = DashboardView.objects.select_related().all() |
| 1488 | serializer_class = DashboardViewSerializer |
| 1489 | |
| 1490 | def get_queryset(self): |
| 1491 | return DashboardView.select_by_user(self.request.user) |
| 1492 | |
| 1493 | def create(self, request, *args, **kwargs): |
| 1494 | #obj = DashboardView().update(request.DATA) |
| 1495 | obj = self.get_object() |
| 1496 | obj.caller = request.user |
| 1497 | if obj.can_update(request.user): |
| 1498 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 1499 | else: |
| 1500 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1501 | |
| 1502 | class DashboardViewDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1503 | queryset = DashboardView.objects.select_related().all() |
| 1504 | serializer_class = DashboardViewSerializer |
| 1505 | |
| 1506 | def get_queryset(self): |
| 1507 | return DashboardView.select_by_user(self.request.user) |
| 1508 | |
| 1509 | def update(self, request, *args, **kwargs): |
| 1510 | obj = self.get_object() |
| 1511 | if obj.can_update(request.user): |
| 1512 | return super(DashboardViewDetail, self).update(request, *args, **kwargs) |
| 1513 | else: |
| 1514 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1515 | |
| 1516 | def destroy(self, request, *args, **kwargs): |
| 1517 | obj = self.get_object() |
| 1518 | if obj.can_update(request.user): |
| 1519 | return super(DashboardViewDetail, self).destroy(request, *args, **kwargs) |
| 1520 | else: |
| 1521 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1522 | |
| 1523 | |
| 1524 | |
| 1525 | |
| 1526 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 1527 | queryset = ImageDeployments.objects.select_related().all() |
| 1528 | serializer_class = ImageDeploymentsSerializer |
| 1529 | |
| 1530 | def get_queryset(self): |
| 1531 | return ImageDeployments.select_by_user(self.request.user) |
| 1532 | |
| 1533 | def create(self, request, *args, **kwargs): |
| 1534 | #obj = ImageDeployments().update(request.DATA) |
| 1535 | obj = self.get_object() |
| 1536 | obj.caller = request.user |
| 1537 | if obj.can_update(request.user): |
| 1538 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
| 1539 | else: |
| 1540 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1541 | |
| 1542 | class ImageDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1543 | queryset = ImageDeployments.objects.select_related().all() |
| 1544 | serializer_class = ImageDeploymentsSerializer |
| 1545 | |
| 1546 | def get_queryset(self): |
| 1547 | return ImageDeployments.select_by_user(self.request.user) |
| 1548 | |
| 1549 | def update(self, request, *args, **kwargs): |
| 1550 | obj = self.get_object() |
| 1551 | if obj.can_update(request.user): |
| 1552 | return super(ImageDeploymentsDetail, self).update(request, *args, **kwargs) |
| 1553 | else: |
| 1554 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1555 | |
| 1556 | def destroy(self, request, *args, **kwargs): |
| 1557 | obj = self.get_object() |
| 1558 | if obj.can_update(request.user): |
| 1559 | return super(ImageDeploymentsDetail, self).destroy(request, *args, **kwargs) |
| 1560 | else: |
| 1561 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1562 | |
| 1563 | |
| 1564 | |
| 1565 | |
| 1566 | class ReservedResourceList(generics.ListCreateAPIView): |
| 1567 | queryset = ReservedResource.objects.select_related().all() |
| 1568 | serializer_class = ReservedResourceSerializer |
| 1569 | |
| 1570 | def get_queryset(self): |
| 1571 | return ReservedResource.select_by_user(self.request.user) |
| 1572 | |
| 1573 | def create(self, request, *args, **kwargs): |
| 1574 | #obj = ReservedResource().update(request.DATA) |
| 1575 | obj = self.get_object() |
| 1576 | obj.caller = request.user |
| 1577 | if obj.can_update(request.user): |
| 1578 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 1579 | else: |
| 1580 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1581 | |
| 1582 | class ReservedResourceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1583 | queryset = ReservedResource.objects.select_related().all() |
| 1584 | serializer_class = ReservedResourceSerializer |
| 1585 | |
| 1586 | def get_queryset(self): |
| 1587 | return ReservedResource.select_by_user(self.request.user) |
| 1588 | |
| 1589 | def update(self, request, *args, **kwargs): |
| 1590 | obj = self.get_object() |
| 1591 | if obj.can_update(request.user): |
| 1592 | return super(ReservedResourceDetail, self).update(request, *args, **kwargs) |
| 1593 | else: |
| 1594 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1595 | |
| 1596 | def destroy(self, request, *args, **kwargs): |
| 1597 | obj = self.get_object() |
| 1598 | if obj.can_update(request.user): |
| 1599 | return super(ReservedResourceDetail, self).destroy(request, *args, **kwargs) |
| 1600 | else: |
| 1601 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1602 | |
| 1603 | |
| 1604 | |
| 1605 | |
| 1606 | class NetworkSliceList(generics.ListCreateAPIView): |
| 1607 | queryset = NetworkSlice.objects.select_related().all() |
| 1608 | serializer_class = NetworkSliceSerializer |
| 1609 | |
| 1610 | def get_queryset(self): |
| 1611 | return NetworkSlice.select_by_user(self.request.user) |
| 1612 | |
| 1613 | def create(self, request, *args, **kwargs): |
| 1614 | #obj = NetworkSlice().update(request.DATA) |
| 1615 | obj = self.get_object() |
| 1616 | obj.caller = request.user |
| 1617 | if obj.can_update(request.user): |
| 1618 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 1619 | else: |
| 1620 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1621 | |
| 1622 | class NetworkSliceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1623 | queryset = NetworkSlice.objects.select_related().all() |
| 1624 | serializer_class = NetworkSliceSerializer |
| 1625 | |
| 1626 | def get_queryset(self): |
| 1627 | return NetworkSlice.select_by_user(self.request.user) |
| 1628 | |
| 1629 | def update(self, request, *args, **kwargs): |
| 1630 | obj = self.get_object() |
| 1631 | if obj.can_update(request.user): |
| 1632 | return super(NetworkSliceDetail, self).update(request, *args, **kwargs) |
| 1633 | else: |
| 1634 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1635 | |
| 1636 | def destroy(self, request, *args, **kwargs): |
| 1637 | obj = self.get_object() |
| 1638 | if obj.can_update(request.user): |
| 1639 | return super(NetworkSliceDetail, self).destroy(request, *args, **kwargs) |
| 1640 | else: |
| 1641 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1642 | |
| 1643 | |
| 1644 | |
| 1645 | |
| 1646 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 1647 | queryset = UserDashboardView.objects.select_related().all() |
| 1648 | serializer_class = UserDashboardViewSerializer |
| 1649 | |
| 1650 | def get_queryset(self): |
| 1651 | return UserDashboardView.select_by_user(self.request.user) |
| 1652 | |
| 1653 | def create(self, request, *args, **kwargs): |
| 1654 | #obj = UserDashboardView().update(request.DATA) |
| 1655 | obj = self.get_object() |
| 1656 | obj.caller = request.user |
| 1657 | if obj.can_update(request.user): |
| 1658 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 1659 | else: |
| 1660 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1661 | |
| 1662 | class UserDashboardViewDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1663 | queryset = UserDashboardView.objects.select_related().all() |
| 1664 | serializer_class = UserDashboardViewSerializer |
| 1665 | |
| 1666 | def get_queryset(self): |
| 1667 | return UserDashboardView.select_by_user(self.request.user) |
| 1668 | |
| 1669 | def update(self, request, *args, **kwargs): |
| 1670 | obj = self.get_object() |
| 1671 | if obj.can_update(request.user): |
| 1672 | return super(UserDashboardViewDetail, self).update(request, *args, **kwargs) |
| 1673 | else: |
| 1674 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1675 | |
| 1676 | def destroy(self, request, *args, **kwargs): |
| 1677 | obj = self.get_object() |
| 1678 | if obj.can_update(request.user): |
| 1679 | return super(UserDashboardViewDetail, self).destroy(request, *args, **kwargs) |
| 1680 | else: |
| 1681 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1682 | |
| 1683 | |
| 1684 | |
| 1685 | |
| 1686 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 1687 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 1688 | serializer_class = PlanetStackPrivilegeSerializer |
| 1689 | |
| 1690 | def get_queryset(self): |
| 1691 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 1692 | |
| 1693 | def create(self, request, *args, **kwargs): |
| 1694 | #obj = PlanetStackPrivilege().update(request.DATA) |
| 1695 | obj = self.get_object() |
| 1696 | obj.caller = request.user |
| 1697 | if obj.can_update(request.user): |
| 1698 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 1699 | else: |
| 1700 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1701 | |
| 1702 | class PlanetStackPrivilegeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1703 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 1704 | serializer_class = PlanetStackPrivilegeSerializer |
| 1705 | |
| 1706 | def get_queryset(self): |
| 1707 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 1708 | |
| 1709 | def update(self, request, *args, **kwargs): |
| 1710 | obj = self.get_object() |
| 1711 | if obj.can_update(request.user): |
| 1712 | return super(PlanetStackPrivilegeDetail, self).update(request, *args, **kwargs) |
| 1713 | else: |
| 1714 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1715 | |
| 1716 | def destroy(self, request, *args, **kwargs): |
| 1717 | obj = self.get_object() |
| 1718 | if obj.can_update(request.user): |
| 1719 | return super(PlanetStackPrivilegeDetail, self).destroy(request, *args, **kwargs) |
| 1720 | else: |
| 1721 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1722 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1723 | |
| 1724 | |
| 1725 | |
| 1726 | class UserList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1727 | queryset = User.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1728 | serializer_class = UserSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1729 | |
| 1730 | def get_queryset(self): |
| 1731 | return User.select_by_user(self.request.user) |
| 1732 | |
| 1733 | def create(self, request, *args, **kwargs): |
| 1734 | #obj = User().update(request.DATA) |
| 1735 | obj = self.get_object() |
| 1736 | obj.caller = request.user |
| 1737 | if obj.can_update(request.user): |
| 1738 | return super(UserList, self).create(request, *args, **kwargs) |
| 1739 | else: |
| 1740 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1741 | |
| 1742 | class UserDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1743 | queryset = User.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1744 | serializer_class = UserSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1745 | |
| 1746 | def get_queryset(self): |
| 1747 | return User.select_by_user(self.request.user) |
| 1748 | |
| 1749 | def update(self, request, *args, **kwargs): |
| 1750 | obj = self.get_object() |
| 1751 | if obj.can_update(request.user): |
| 1752 | return super(UserDetail, self).update(request, *args, **kwargs) |
| 1753 | else: |
| 1754 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1755 | |
| 1756 | def destroy(self, request, *args, **kwargs): |
| 1757 | obj = self.get_object() |
| 1758 | if obj.can_update(request.user): |
| 1759 | return super(UserDetail, self).destroy(request, *args, **kwargs) |
| 1760 | else: |
| 1761 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1762 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1763 | |
| 1764 | |
| 1765 | |
| 1766 | class DeploymentList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1767 | queryset = Deployment.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1768 | serializer_class = DeploymentSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1769 | |
| 1770 | def get_queryset(self): |
| 1771 | return Deployment.select_by_user(self.request.user) |
| 1772 | |
| 1773 | def create(self, request, *args, **kwargs): |
| 1774 | #obj = Deployment().update(request.DATA) |
| 1775 | obj = self.get_object() |
| 1776 | obj.caller = request.user |
| 1777 | if obj.can_update(request.user): |
| 1778 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 1779 | else: |
| 1780 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1781 | |
| 1782 | class DeploymentDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1783 | queryset = Deployment.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1784 | serializer_class = DeploymentSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1785 | |
| 1786 | def get_queryset(self): |
| 1787 | return Deployment.select_by_user(self.request.user) |
| 1788 | |
| 1789 | def update(self, request, *args, **kwargs): |
| 1790 | obj = self.get_object() |
| 1791 | if obj.can_update(request.user): |
| 1792 | return super(DeploymentDetail, self).update(request, *args, **kwargs) |
| 1793 | else: |
| 1794 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1795 | |
| 1796 | def destroy(self, request, *args, **kwargs): |
| 1797 | obj = self.get_object() |
| 1798 | if obj.can_update(request.user): |
| 1799 | return super(DeploymentDetail, self).destroy(request, *args, **kwargs) |
| 1800 | else: |
| 1801 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1802 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1803 | |
| 1804 | |
| 1805 | |
| 1806 | class ReservationList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1807 | queryset = Reservation.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1808 | serializer_class = ReservationSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1809 | |
| 1810 | def get_queryset(self): |
| 1811 | return Reservation.select_by_user(self.request.user) |
| 1812 | |
| 1813 | def create(self, request, *args, **kwargs): |
| 1814 | #obj = Reservation().update(request.DATA) |
| 1815 | obj = self.get_object() |
| 1816 | obj.caller = request.user |
| 1817 | if obj.can_update(request.user): |
| 1818 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 1819 | else: |
| 1820 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1821 | |
| 1822 | class ReservationDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1823 | queryset = Reservation.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1824 | serializer_class = ReservationSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1825 | |
| 1826 | def get_queryset(self): |
| 1827 | return Reservation.select_by_user(self.request.user) |
| 1828 | |
| 1829 | def update(self, request, *args, **kwargs): |
| 1830 | obj = self.get_object() |
| 1831 | if obj.can_update(request.user): |
| 1832 | return super(ReservationDetail, self).update(request, *args, **kwargs) |
| 1833 | else: |
| 1834 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1835 | |
| 1836 | def destroy(self, request, *args, **kwargs): |
| 1837 | obj = self.get_object() |
| 1838 | if obj.can_update(request.user): |
| 1839 | return super(ReservationDetail, self).destroy(request, *args, **kwargs) |
| 1840 | else: |
| 1841 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1842 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1843 | |
| 1844 | |
| 1845 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1846 | class SliceDeploymentsList(generics.ListCreateAPIView): |
| 1847 | queryset = SliceDeployments.objects.select_related().all() |
| 1848 | serializer_class = SliceDeploymentsSerializer |
| 1849 | |
| 1850 | def get_queryset(self): |
| 1851 | return SliceDeployments.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1852 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1853 | def create(self, request, *args, **kwargs): |
| 1854 | #obj = SliceDeployments().update(request.DATA) |
| 1855 | obj = self.get_object() |
| 1856 | obj.caller = request.user |
| 1857 | if obj.can_update(request.user): |
| 1858 | return super(SliceDeploymentsList, self).create(request, *args, **kwargs) |
| 1859 | else: |
| 1860 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1861 | |
| 1862 | class SliceDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1863 | queryset = SliceDeployments.objects.select_related().all() |
| 1864 | serializer_class = SliceDeploymentsSerializer |
| 1865 | |
| 1866 | def get_queryset(self): |
| 1867 | return SliceDeployments.select_by_user(self.request.user) |
| 1868 | |
| 1869 | def update(self, request, *args, **kwargs): |
| 1870 | obj = self.get_object() |
| 1871 | if obj.can_update(request.user): |
| 1872 | return super(SliceDeploymentsDetail, self).update(request, *args, **kwargs) |
| 1873 | else: |
| 1874 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1875 | |
| 1876 | def destroy(self, request, *args, **kwargs): |
| 1877 | obj = self.get_object() |
| 1878 | if obj.can_update(request.user): |
| 1879 | return super(SliceDeploymentsDetail, self).destroy(request, *args, **kwargs) |
| 1880 | else: |
| 1881 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1882 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1883 | |
| 1884 | |
| 1885 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1886 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 1887 | queryset = SitePrivilege.objects.select_related().all() |
| 1888 | serializer_class = SitePrivilegeSerializer |
| 1889 | |
| 1890 | def get_queryset(self): |
| 1891 | return SitePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1892 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1893 | def create(self, request, *args, **kwargs): |
| 1894 | #obj = SitePrivilege().update(request.DATA) |
| 1895 | obj = self.get_object() |
| 1896 | obj.caller = request.user |
| 1897 | if obj.can_update(request.user): |
| 1898 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 1899 | else: |
| 1900 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1901 | |
| 1902 | class SitePrivilegeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1903 | queryset = SitePrivilege.objects.select_related().all() |
| 1904 | serializer_class = SitePrivilegeSerializer |
| 1905 | |
| 1906 | def get_queryset(self): |
| 1907 | return SitePrivilege.select_by_user(self.request.user) |
| 1908 | |
| 1909 | def update(self, request, *args, **kwargs): |
| 1910 | obj = self.get_object() |
| 1911 | if obj.can_update(request.user): |
| 1912 | return super(SitePrivilegeDetail, self).update(request, *args, **kwargs) |
| 1913 | else: |
| 1914 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1915 | |
| 1916 | def destroy(self, request, *args, **kwargs): |
| 1917 | obj = self.get_object() |
| 1918 | if obj.can_update(request.user): |
| 1919 | return super(SitePrivilegeDetail, self).destroy(request, *args, **kwargs) |
| 1920 | else: |
| 1921 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1922 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1923 | |
| 1924 | |
| 1925 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1926 | class PlanetStackList(generics.ListCreateAPIView): |
| 1927 | queryset = PlanetStack.objects.select_related().all() |
| 1928 | serializer_class = PlanetStackSerializer |
| 1929 | |
| 1930 | def get_queryset(self): |
| 1931 | return PlanetStack.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1932 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1933 | def create(self, request, *args, **kwargs): |
| 1934 | #obj = PlanetStack().update(request.DATA) |
| 1935 | obj = self.get_object() |
| 1936 | obj.caller = request.user |
| 1937 | if obj.can_update(request.user): |
| 1938 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
| 1939 | else: |
| 1940 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1941 | |
| 1942 | class PlanetStackDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1943 | queryset = PlanetStack.objects.select_related().all() |
| 1944 | serializer_class = PlanetStackSerializer |
| 1945 | |
| 1946 | def get_queryset(self): |
| 1947 | return PlanetStack.select_by_user(self.request.user) |
| 1948 | |
| 1949 | def update(self, request, *args, **kwargs): |
| 1950 | obj = self.get_object() |
| 1951 | if obj.can_update(request.user): |
| 1952 | return super(PlanetStackDetail, self).update(request, *args, **kwargs) |
| 1953 | else: |
| 1954 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1955 | |
| 1956 | def destroy(self, request, *args, **kwargs): |
| 1957 | obj = self.get_object() |
| 1958 | if obj.can_update(request.user): |
| 1959 | return super(PlanetStackDetail, self).destroy(request, *args, **kwargs) |
| 1960 | else: |
| 1961 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1962 | |
| 1963 | |
| 1964 | |
| 1965 | |
| 1966 | class UserDeploymentsList(generics.ListCreateAPIView): |
| 1967 | queryset = UserDeployments.objects.select_related().all() |
| 1968 | serializer_class = UserDeploymentsSerializer |
| 1969 | |
| 1970 | def get_queryset(self): |
| 1971 | return UserDeployments.select_by_user(self.request.user) |
| 1972 | |
| 1973 | def create(self, request, *args, **kwargs): |
| 1974 | #obj = UserDeployments().update(request.DATA) |
| 1975 | obj = self.get_object() |
| 1976 | obj.caller = request.user |
| 1977 | if obj.can_update(request.user): |
| 1978 | return super(UserDeploymentsList, self).create(request, *args, **kwargs) |
| 1979 | else: |
| 1980 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1981 | |
| 1982 | class UserDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1983 | queryset = UserDeployments.objects.select_related().all() |
| 1984 | serializer_class = UserDeploymentsSerializer |
| 1985 | |
| 1986 | def get_queryset(self): |
| 1987 | return UserDeployments.select_by_user(self.request.user) |
| 1988 | |
| 1989 | def update(self, request, *args, **kwargs): |
| 1990 | obj = self.get_object() |
| 1991 | if obj.can_update(request.user): |
| 1992 | return super(UserDeploymentsDetail, self).update(request, *args, **kwargs) |
| 1993 | else: |
| 1994 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1995 | |
| 1996 | def destroy(self, request, *args, **kwargs): |
| 1997 | obj = self.get_object() |
| 1998 | if obj.can_update(request.user): |
| 1999 | return super(UserDeploymentsDetail, self).destroy(request, *args, **kwargs) |
| 2000 | else: |
| 2001 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2002 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2003 | |
| 2004 | |
| 2005 | |
| 2006 | class AccountList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2007 | queryset = Account.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2008 | serializer_class = AccountSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2009 | |
| 2010 | def get_queryset(self): |
| 2011 | return Account.select_by_user(self.request.user) |
| 2012 | |
| 2013 | def create(self, request, *args, **kwargs): |
| 2014 | #obj = Account().update(request.DATA) |
| 2015 | obj = self.get_object() |
| 2016 | obj.caller = request.user |
| 2017 | if obj.can_update(request.user): |
| 2018 | return super(AccountList, self).create(request, *args, **kwargs) |
| 2019 | else: |
| 2020 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2021 | |
| 2022 | class AccountDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2023 | queryset = Account.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2024 | serializer_class = AccountSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2025 | |
| 2026 | def get_queryset(self): |
| 2027 | return Account.select_by_user(self.request.user) |
| 2028 | |
| 2029 | def update(self, request, *args, **kwargs): |
| 2030 | obj = self.get_object() |
| 2031 | if obj.can_update(request.user): |
| 2032 | return super(AccountDetail, self).update(request, *args, **kwargs) |
| 2033 | else: |
| 2034 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2035 | |
| 2036 | def destroy(self, request, *args, **kwargs): |
| 2037 | obj = self.get_object() |
| 2038 | if obj.can_update(request.user): |
| 2039 | return super(AccountDetail, self).destroy(request, *args, **kwargs) |
| 2040 | else: |
| 2041 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2042 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2043 | |
| 2044 | |
| 2045 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2046 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 2047 | queryset = NetworkParameterType.objects.select_related().all() |
| 2048 | serializer_class = NetworkParameterTypeSerializer |
| 2049 | |
| 2050 | def get_queryset(self): |
| 2051 | return NetworkParameterType.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2052 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2053 | def create(self, request, *args, **kwargs): |
| 2054 | #obj = NetworkParameterType().update(request.DATA) |
| 2055 | obj = self.get_object() |
| 2056 | obj.caller = request.user |
| 2057 | if obj.can_update(request.user): |
| 2058 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 2059 | else: |
| 2060 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2061 | |
| 2062 | class NetworkParameterTypeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 2063 | queryset = NetworkParameterType.objects.select_related().all() |
| 2064 | serializer_class = NetworkParameterTypeSerializer |
| 2065 | |
| 2066 | def get_queryset(self): |
| 2067 | return NetworkParameterType.select_by_user(self.request.user) |
| 2068 | |
| 2069 | def update(self, request, *args, **kwargs): |
| 2070 | obj = self.get_object() |
| 2071 | if obj.can_update(request.user): |
| 2072 | return super(NetworkParameterTypeDetail, self).update(request, *args, **kwargs) |
| 2073 | else: |
| 2074 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2075 | |
| 2076 | def destroy(self, request, *args, **kwargs): |
| 2077 | obj = self.get_object() |
| 2078 | if obj.can_update(request.user): |
| 2079 | return super(NetworkParameterTypeDetail, self).destroy(request, *args, **kwargs) |
| 2080 | else: |
| 2081 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2082 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2083 | |
| 2084 | |
| 2085 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2086 | class SiteDeploymentsList(generics.ListCreateAPIView): |
| 2087 | queryset = SiteDeployments.objects.select_related().all() |
| 2088 | serializer_class = SiteDeploymentsSerializer |
| 2089 | |
| 2090 | def get_queryset(self): |
| 2091 | return SiteDeployments.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2092 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2093 | def create(self, request, *args, **kwargs): |
| 2094 | #obj = SiteDeployments().update(request.DATA) |
| 2095 | obj = self.get_object() |
| 2096 | obj.caller = request.user |
| 2097 | if obj.can_update(request.user): |
| 2098 | return super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 2099 | else: |
| 2100 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2101 | |
| 2102 | class SiteDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView): |
| 2103 | queryset = SiteDeployments.objects.select_related().all() |
| 2104 | serializer_class = SiteDeploymentsSerializer |
| 2105 | |
| 2106 | def get_queryset(self): |
| 2107 | return SiteDeployments.select_by_user(self.request.user) |
| 2108 | |
| 2109 | def update(self, request, *args, **kwargs): |
| 2110 | obj = self.get_object() |
| 2111 | if obj.can_update(request.user): |
| 2112 | return super(SiteDeploymentsDetail, self).update(request, *args, **kwargs) |
| 2113 | else: |
| 2114 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2115 | |
| 2116 | def destroy(self, request, *args, **kwargs): |
| 2117 | obj = self.get_object() |
| 2118 | if obj.can_update(request.user): |
| 2119 | return super(SiteDeploymentsDetail, self).destroy(request, *args, **kwargs) |
| 2120 | else: |
| 2121 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2122 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2123 | |
| 2124 | |
| 2125 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2126 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 2127 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 2128 | serializer_class = DeploymentPrivilegeSerializer |
| 2129 | |
| 2130 | def get_queryset(self): |
| 2131 | return DeploymentPrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2132 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2133 | def create(self, request, *args, **kwargs): |
| 2134 | #obj = DeploymentPrivilege().update(request.DATA) |
| 2135 | obj = self.get_object() |
| 2136 | obj.caller = request.user |
| 2137 | if obj.can_update(request.user): |
| 2138 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
| 2139 | else: |
| 2140 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2141 | |
| 2142 | class DeploymentPrivilegeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 2143 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 2144 | serializer_class = DeploymentPrivilegeSerializer |
| 2145 | |
| 2146 | def get_queryset(self): |
| 2147 | return DeploymentPrivilege.select_by_user(self.request.user) |
| 2148 | |
| 2149 | def update(self, request, *args, **kwargs): |
| 2150 | obj = self.get_object() |
| 2151 | if obj.can_update(request.user): |
| 2152 | return super(DeploymentPrivilegeDetail, self).update(request, *args, **kwargs) |
| 2153 | else: |
| 2154 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2155 | |
| 2156 | def destroy(self, request, *args, **kwargs): |
| 2157 | obj = self.get_object() |
| 2158 | if obj.can_update(request.user): |
| 2159 | return super(DeploymentPrivilegeDetail, self).destroy(request, *args, **kwargs) |
| 2160 | else: |
| 2161 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2162 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2163 | |
| 2164 | |
| 2165 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2166 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 2167 | queryset = DeploymentRole.objects.select_related().all() |
| 2168 | serializer_class = DeploymentRoleSerializer |
| 2169 | |
| 2170 | def get_queryset(self): |
| 2171 | return DeploymentRole.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2172 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2173 | def create(self, request, *args, **kwargs): |
| 2174 | #obj = DeploymentRole().update(request.DATA) |
| 2175 | obj = self.get_object() |
| 2176 | obj.caller = request.user |
| 2177 | if obj.can_update(request.user): |
| 2178 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
| 2179 | else: |
| 2180 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2181 | |
| 2182 | class DeploymentRoleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 2183 | queryset = DeploymentRole.objects.select_related().all() |
| 2184 | serializer_class = DeploymentRoleSerializer |
| 2185 | |
| 2186 | def get_queryset(self): |
| 2187 | return DeploymentRole.select_by_user(self.request.user) |
| 2188 | |
| 2189 | def update(self, request, *args, **kwargs): |
| 2190 | obj = self.get_object() |
| 2191 | if obj.can_update(request.user): |
| 2192 | return super(DeploymentRoleDetail, self).update(request, *args, **kwargs) |
| 2193 | else: |
| 2194 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2195 | |
| 2196 | def destroy(self, request, *args, **kwargs): |
| 2197 | obj = self.get_object() |
| 2198 | if obj.can_update(request.user): |
| 2199 | return super(DeploymentRoleDetail, self).destroy(request, *args, **kwargs) |
| 2200 | else: |
| 2201 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2202 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2203 | |
| 2204 | |
| 2205 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2206 | class ProjectList(generics.ListCreateAPIView): |
| 2207 | queryset = Project.objects.select_related().all() |
| 2208 | serializer_class = ProjectSerializer |
| 2209 | |
| 2210 | def get_queryset(self): |
| 2211 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2212 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2213 | def create(self, request, *args, **kwargs): |
| 2214 | #obj = Project().update(request.DATA) |
| 2215 | obj = self.get_object() |
| 2216 | obj.caller = request.user |
| 2217 | if obj.can_update(request.user): |
| 2218 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 2219 | else: |
| 2220 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2221 | |
| 2222 | class ProjectDetail(generics.RetrieveUpdateDestroyAPIView): |
| 2223 | queryset = Project.objects.select_related().all() |
| 2224 | serializer_class = ProjectSerializer |
| 2225 | |
| 2226 | def get_queryset(self): |
| 2227 | return Project.select_by_user(self.request.user) |
| 2228 | |
| 2229 | def update(self, request, *args, **kwargs): |
| 2230 | obj = self.get_object() |
| 2231 | if obj.can_update(request.user): |
| 2232 | return super(ProjectDetail, self).update(request, *args, **kwargs) |
| 2233 | else: |
| 2234 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2235 | |
| 2236 | def destroy(self, request, *args, **kwargs): |
| 2237 | obj = self.get_object() |
| 2238 | if obj.can_update(request.user): |
| 2239 | return super(ProjectDetail, self).destroy(request, *args, **kwargs) |
| 2240 | else: |
| 2241 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2242 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2243 | |
| 2244 | |
| 2245 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2246 | class SliceTagList(generics.ListCreateAPIView): |
| 2247 | queryset = SliceTag.objects.select_related().all() |
| 2248 | serializer_class = SliceTagSerializer |
| 2249 | |
| 2250 | def get_queryset(self): |
| 2251 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2252 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2253 | def create(self, request, *args, **kwargs): |
| 2254 | #obj = SliceTag().update(request.DATA) |
| 2255 | obj = self.get_object() |
| 2256 | obj.caller = request.user |
| 2257 | if obj.can_update(request.user): |
| 2258 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 2259 | else: |
| 2260 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2261 | |
| 2262 | class SliceTagDetail(generics.RetrieveUpdateDestroyAPIView): |
| 2263 | queryset = SliceTag.objects.select_related().all() |
| 2264 | serializer_class = SliceTagSerializer |
| 2265 | |
| 2266 | def get_queryset(self): |
| 2267 | return SliceTag.select_by_user(self.request.user) |
| 2268 | |
| 2269 | def update(self, request, *args, **kwargs): |
| 2270 | obj = self.get_object() |
| 2271 | if obj.can_update(request.user): |
| 2272 | return super(SliceTagDetail, self).update(request, *args, **kwargs) |
| 2273 | else: |
| 2274 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2275 | |
| 2276 | def destroy(self, request, *args, **kwargs): |
| 2277 | obj = self.get_object() |
| 2278 | if obj.can_update(request.user): |
| 2279 | return super(SliceTagDetail, self).destroy(request, *args, **kwargs) |
| 2280 | else: |
| 2281 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2282 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2283 | |
| 2284 | |
| 2285 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2286 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 2287 | queryset = NetworkTemplate.objects.select_related().all() |
| 2288 | serializer_class = NetworkTemplateSerializer |
| 2289 | |
| 2290 | def get_queryset(self): |
| 2291 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2292 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2293 | def create(self, request, *args, **kwargs): |
| 2294 | #obj = NetworkTemplate().update(request.DATA) |
| 2295 | obj = self.get_object() |
| 2296 | obj.caller = request.user |
| 2297 | if obj.can_update(request.user): |
| 2298 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 2299 | else: |
| 2300 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2301 | |
| 2302 | class NetworkTemplateDetail(generics.RetrieveUpdateDestroyAPIView): |
| 2303 | queryset = NetworkTemplate.objects.select_related().all() |
| 2304 | serializer_class = NetworkTemplateSerializer |
| 2305 | |
| 2306 | def get_queryset(self): |
| 2307 | return NetworkTemplate.select_by_user(self.request.user) |
| 2308 | |
| 2309 | def update(self, request, *args, **kwargs): |
| 2310 | obj = self.get_object() |
| 2311 | if obj.can_update(request.user): |
| 2312 | return super(NetworkTemplateDetail, self).update(request, *args, **kwargs) |
| 2313 | else: |
| 2314 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2315 | |
| 2316 | def destroy(self, request, *args, **kwargs): |
| 2317 | obj = self.get_object() |
| 2318 | if obj.can_update(request.user): |
| 2319 | return super(NetworkTemplateDetail, self).destroy(request, *args, **kwargs) |
| 2320 | else: |
| 2321 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2322 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2323 | |
| 2324 | |
| 2325 | |
| 2326 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2327 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2328 | serializer_class = RouterSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2329 | |
| 2330 | def get_queryset(self): |
| 2331 | return Router.select_by_user(self.request.user) |
| 2332 | |
| 2333 | def create(self, request, *args, **kwargs): |
| 2334 | #obj = Router().update(request.DATA) |
| 2335 | obj = self.get_object() |
| 2336 | obj.caller = request.user |
| 2337 | if obj.can_update(request.user): |
| 2338 | return super(RouterList, self).create(request, *args, **kwargs) |
| 2339 | else: |
| 2340 | return Response(status=status.HTTP_400_BAD_REQUEST) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2341 | |
| 2342 | class RouterDetail(generics.RetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2343 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2344 | serializer_class = RouterSerializer |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2345 | |
| 2346 | def get_queryset(self): |
| 2347 | return Router.select_by_user(self.request.user) |
| 2348 | |
| 2349 | def update(self, request, *args, **kwargs): |
| 2350 | obj = self.get_object() |
| 2351 | if obj.can_update(request.user): |
| 2352 | return super(RouterDetail, self).update(request, *args, **kwargs) |
| 2353 | else: |
| 2354 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2355 | |
| 2356 | def destroy(self, request, *args, **kwargs): |
| 2357 | obj = self.get_object() |
| 2358 | if obj.can_update(request.user): |
| 2359 | return super(RouterDetail, self).destroy(request, *args, **kwargs) |
| 2360 | else: |
| 2361 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2362 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2363 | |
| 2364 | |
| 2365 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2366 | class ServiceResourceList(generics.ListCreateAPIView): |
| 2367 | queryset = ServiceResource.objects.select_related().all() |
| 2368 | serializer_class = ServiceResourceSerializer |
| 2369 | |
| 2370 | def get_queryset(self): |
| 2371 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2372 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2373 | def create(self, request, *args, **kwargs): |
| 2374 | #obj = ServiceResource().update(request.DATA) |
| 2375 | obj = self.get_object() |
| 2376 | obj.caller = request.user |
| 2377 | if obj.can_update(request.user): |
| 2378 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 2379 | else: |
| 2380 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2381 | |
| 2382 | class ServiceResourceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 2383 | queryset = ServiceResource.objects.select_related().all() |
| 2384 | serializer_class = ServiceResourceSerializer |
| 2385 | |
| 2386 | def get_queryset(self): |
| 2387 | return ServiceResource.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(ServiceResourceDetail, 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(ServiceResourceDetail, self).destroy(request, *args, **kwargs) |
| 2400 | else: |
| 2401 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2402 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2403 | |
| 2404 | |
| 2405 | |