Sapan Bhatia | 643b709 | 2014-01-28 14:31:06 -0500 | [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 |
| 5 | from core.models import * |
| 6 | from django.forms import widgets |
| 7 | |
| 8 | """ |
| 9 | Schema of the generator object: |
| 10 | all: Set of all Model objects |
| 11 | all_if(regex): Set of Model objects that match regex |
| 12 | |
| 13 | Model object: |
| 14 | plural: English plural of object name |
| 15 | camel: CamelCase version of object name |
| 16 | refs: list of references to other Model objects |
| 17 | props: list of properties minus refs |
| 18 | |
| 19 | TODO: Deal with subnets |
| 20 | """ |
| 21 | |
| 22 | # Based on api_root.py |
| 23 | |
| 24 | @api_view(['GET']) |
| 25 | def api_root(request, format=None): |
| 26 | return Response({ |
| 27 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
| 28 | 'images': reverse('image-list', request=request, format=format), |
| 29 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 30 | 'sites': reverse('site-list', request=request, format=format), |
| 31 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 32 | 'tags': reverse('tag-list', request=request, format=format), |
| 33 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 34 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 35 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
| 36 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
| 37 | 'projects': reverse('project-list', request=request, format=format), |
| 38 | 'slices': reverse('slice-list', request=request, format=format), |
| 39 | 'networks': reverse('network-list', request=request, format=format), |
| 40 | 'services': reverse('service-list', request=request, format=format), |
| 41 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
| 42 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 43 | 'charges': reverse('charge-list', request=request, format=format), |
| 44 | 'roles': reverse('role-list', request=request, format=format), |
| 45 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
| 46 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 47 | 'nodes': reverse('node-list', request=request, format=format), |
| 48 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
| 49 | 'payments': reverse('payment-list', request=request, format=format), |
| 50 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 51 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 52 | 'users': reverse('user-list', request=request, format=format), |
| 53 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 54 | 'reservations': reverse('reservation-list', request=request, format=format), |
| 55 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
| 56 | 'singletonmodels': reverse('singletonmodel-list', request=request, format=format), |
| 57 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
| 58 | 'accounts': reverse('account-list', request=request, format=format), |
| 59 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 60 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
| 61 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 62 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
| 63 | 'plcorebases': reverse('plcorebase-list', request=request, format=format), |
| 64 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
| 65 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
| 66 | 'routers': reverse('router-list', request=request, format=format), |
| 67 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
| 68 | |
| 69 | }) |
| 70 | |
| 71 | # Based on serializers.py |
| 72 | |
| 73 | |
| 74 | |
| 75 | class ServiceattributeSerializer(serializers.HyperlinkedModelSerializer): |
| 76 | id = serializers.Field() |
| 77 | |
| 78 | |
| 79 | service = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='service-detail') |
| 80 | |
| 81 | |
| 82 | class Meta: |
| 83 | model = serviceattribute |
| 84 | fields = ('id','created','updated','enacted','name','value',) |
| 85 | |
| 86 | |
| 87 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
| 88 | id = serializers.Field() |
| 89 | |
| 90 | class Meta: |
| 91 | model = image |
| 92 | fields = ('id','created','updated','enacted','image_id','name','disk_format','container_format',) |
| 93 | |
| 94 | |
| 95 | class NetworkparameterSerializer(serializers.HyperlinkedModelSerializer): |
| 96 | id = serializers.Field() |
| 97 | |
| 98 | class Meta: |
| 99 | model = networkparameter |
| 100 | fields = ('id','created','updated','enacted','parameter','value','content_type','object_id',) |
| 101 | |
| 102 | |
| 103 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
| 104 | id = serializers.Field() |
| 105 | |
| 106 | class Meta: |
| 107 | model = site |
| 108 | fields = ('id','created','updated','enacted','tenant_id','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
| 109 | |
| 110 | |
| 111 | class SliceroleSerializer(serializers.HyperlinkedModelSerializer): |
| 112 | id = serializers.Field() |
| 113 | |
| 114 | class Meta: |
| 115 | model = slicerole |
| 116 | fields = ('id','created','updated','enacted','role',) |
| 117 | |
| 118 | |
| 119 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
| 120 | id = serializers.Field() |
| 121 | |
| 122 | |
| 123 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 124 | |
| 125 | |
| 126 | |
| 127 | service = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='service-detail') |
| 128 | |
| 129 | |
| 130 | |
| 131 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 132 | |
| 133 | |
| 134 | |
| 135 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
| 136 | |
| 137 | |
| 138 | |
| 139 | nodes = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='node-detail') |
| 140 | |
| 141 | |
| 142 | class Meta: |
| 143 | model = tag |
| 144 | fields = ('id','created','updated','enacted','name','value','content_type','object_id',) |
| 145 | |
| 146 | |
| 147 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
| 148 | id = serializers.Field() |
| 149 | |
| 150 | |
| 151 | account = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='account-detail') |
| 152 | |
| 153 | |
| 154 | class Meta: |
| 155 | model = invoice |
| 156 | fields = ('id','created','updated','enacted','date',) |
| 157 | |
| 158 | |
| 159 | class SliceprivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 160 | id = serializers.Field() |
| 161 | |
| 162 | |
| 163 | user = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='user-detail') |
| 164 | |
| 165 | |
| 166 | |
| 167 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 168 | |
| 169 | |
| 170 | |
| 171 | role = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='role-detail') |
| 172 | |
| 173 | |
| 174 | class Meta: |
| 175 | model = sliceprivilege |
| 176 | fields = ('id','created','updated','enacted',) |
| 177 | |
| 178 | |
| 179 | class PlanetstackroleSerializer(serializers.HyperlinkedModelSerializer): |
| 180 | id = serializers.Field() |
| 181 | |
| 182 | class Meta: |
| 183 | model = planetstackrole |
| 184 | fields = ('id','created','updated','enacted','role',) |
| 185 | |
| 186 | |
| 187 | class NetworksliverSerializer(serializers.HyperlinkedModelSerializer): |
| 188 | id = serializers.Field() |
| 189 | |
| 190 | |
| 191 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 192 | |
| 193 | |
| 194 | |
| 195 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
| 196 | |
| 197 | |
| 198 | class Meta: |
| 199 | model = networksliver |
| 200 | fields = ('id','created','updated','enacted','ip','port_id',) |
| 201 | |
| 202 | |
| 203 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
| 204 | id = serializers.Field() |
| 205 | |
| 206 | class Meta: |
| 207 | model = project |
| 208 | fields = ('id','created','updated','enacted','name',) |
| 209 | |
| 210 | |
| 211 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
| 212 | id = serializers.Field() |
| 213 | |
| 214 | |
| 215 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 216 | |
| 217 | |
| 218 | |
| 219 | service = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='service-detail') |
| 220 | |
| 221 | |
| 222 | |
| 223 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 224 | |
| 225 | |
| 226 | |
| 227 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 228 | |
| 229 | |
| 230 | class Meta: |
| 231 | model = slice |
| 232 | fields = ('id','created','updated','enacted','tenant_id','name','enabled','omf_friendly','description','slice_url','network_id','router_id','subnet_id','serviceClass','creator',) |
| 233 | |
| 234 | |
| 235 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
| 236 | id = serializers.Field() |
| 237 | |
| 238 | |
| 239 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 240 | |
| 241 | |
| 242 | |
| 243 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 244 | |
| 245 | |
| 246 | class Meta: |
| 247 | model = network |
| 248 | fields = ('id','created','updated','enacted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id',) |
| 249 | |
| 250 | |
| 251 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
| 252 | id = serializers.Field() |
| 253 | |
| 254 | class Meta: |
| 255 | model = service |
| 256 | fields = ('id','created','updated','enacted','description','enabled','name','versionNumber','published',) |
| 257 | |
| 258 | |
| 259 | class ServiceclassSerializer(serializers.HyperlinkedModelSerializer): |
| 260 | id = serializers.Field() |
| 261 | |
| 262 | class Meta: |
| 263 | model = serviceclass |
| 264 | fields = ('id','created','updated','enacted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 265 | |
| 266 | |
| 267 | class SiteroleSerializer(serializers.HyperlinkedModelSerializer): |
| 268 | id = serializers.Field() |
| 269 | |
| 270 | class Meta: |
| 271 | model = siterole |
| 272 | fields = ('id','created','updated','enacted','role',) |
| 273 | |
| 274 | |
| 275 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
| 276 | id = serializers.Field() |
| 277 | |
| 278 | |
| 279 | account = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='account-detail') |
| 280 | |
| 281 | |
| 282 | |
| 283 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 284 | |
| 285 | |
| 286 | |
| 287 | invoice = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='invoice-detail') |
| 288 | |
| 289 | |
| 290 | class Meta: |
| 291 | model = charge |
| 292 | fields = ('id','created','updated','enacted','kind','state','date','object','amount','coreHours',) |
| 293 | |
| 294 | |
| 295 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
| 296 | id = serializers.Field() |
| 297 | |
| 298 | class Meta: |
| 299 | model = role |
| 300 | fields = ('id','created','updated','enacted','role_type','role','description','content_type',) |
| 301 | |
| 302 | |
| 303 | class UsableobjectSerializer(serializers.HyperlinkedModelSerializer): |
| 304 | id = serializers.Field() |
| 305 | |
| 306 | class Meta: |
| 307 | model = usableobject |
| 308 | fields = ('id','created','updated','enacted','name',) |
| 309 | |
| 310 | |
| 311 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
| 312 | id = serializers.Field() |
| 313 | |
| 314 | |
| 315 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 316 | |
| 317 | |
| 318 | |
| 319 | image = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail') |
| 320 | |
| 321 | |
| 322 | |
| 323 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 324 | |
| 325 | |
| 326 | |
| 327 | nodes = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='node-detail') |
| 328 | |
| 329 | |
| 330 | class Meta: |
| 331 | model = sliver |
| 332 | fields = ('id','created','updated','enacted','instance_id','name','instance_name','ip','creator','deploymentNetwork','numberCores',) |
| 333 | |
| 334 | |
| 335 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
| 336 | id = serializers.Field() |
| 337 | |
| 338 | |
| 339 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 340 | |
| 341 | |
| 342 | |
| 343 | deployment = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 344 | |
| 345 | |
| 346 | class Meta: |
| 347 | model = node |
| 348 | fields = ('id','created','updated','enacted','name',) |
| 349 | |
| 350 | |
| 351 | class ReservedresourceSerializer(serializers.HyperlinkedModelSerializer): |
| 352 | id = serializers.Field() |
| 353 | |
| 354 | |
| 355 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
| 356 | |
| 357 | |
| 358 | class Meta: |
| 359 | model = reservedresource |
| 360 | fields = ('id','created','updated','enacted','resource','quantity','reservationSet',) |
| 361 | |
| 362 | |
| 363 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
| 364 | id = serializers.Field() |
| 365 | |
| 366 | |
| 367 | account = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='account-detail') |
| 368 | |
| 369 | |
| 370 | class Meta: |
| 371 | model = payment |
| 372 | fields = ('id','created','updated','enacted','amount','date',) |
| 373 | |
| 374 | |
| 375 | class NetworksliceSerializer(serializers.HyperlinkedModelSerializer): |
| 376 | id = serializers.Field() |
| 377 | |
| 378 | |
| 379 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 380 | |
| 381 | |
| 382 | |
| 383 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 384 | |
| 385 | |
| 386 | class Meta: |
| 387 | model = networkslice |
| 388 | fields = ('id','created','updated','enacted',) |
| 389 | |
| 390 | |
| 391 | class PlanetstackprivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 392 | id = serializers.Field() |
| 393 | |
| 394 | |
| 395 | user = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='user-detail') |
| 396 | |
| 397 | |
| 398 | |
| 399 | planetstack = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='planetstack-detail') |
| 400 | |
| 401 | |
| 402 | |
| 403 | role = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='role-detail') |
| 404 | |
| 405 | |
| 406 | class Meta: |
| 407 | model = planetstackprivilege |
| 408 | fields = ('id','created','updated','enacted',) |
| 409 | |
| 410 | |
| 411 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
| 412 | id = serializers.Field() |
| 413 | |
| 414 | |
| 415 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 416 | |
| 417 | |
| 418 | class Meta: |
| 419 | model = user |
| 420 | fields = ('id','password','last_login','email','username','kuser_id','firstname','lastname','phone','user_url','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','timezone',) |
| 421 | |
| 422 | |
| 423 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
| 424 | id = serializers.Field() |
| 425 | |
| 426 | |
| 427 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 428 | |
| 429 | |
| 430 | class Meta: |
| 431 | model = deployment |
| 432 | fields = ('id','created','updated','enacted','name',) |
| 433 | |
| 434 | |
| 435 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
| 436 | id = serializers.Field() |
| 437 | |
| 438 | |
| 439 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 440 | |
| 441 | |
| 442 | class Meta: |
| 443 | model = reservation |
| 444 | fields = ('id','created','updated','enacted','startTime','duration',) |
| 445 | |
| 446 | |
| 447 | class SiteprivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 448 | id = serializers.Field() |
| 449 | |
| 450 | |
| 451 | user = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='user-detail') |
| 452 | |
| 453 | |
| 454 | |
| 455 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 456 | |
| 457 | |
| 458 | |
| 459 | role = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='role-detail') |
| 460 | |
| 461 | |
| 462 | class Meta: |
| 463 | model = siteprivilege |
| 464 | fields = ('id','created','updated','enacted',) |
| 465 | |
| 466 | |
| 467 | class SingletonmodelSerializer(serializers.HyperlinkedModelSerializer): |
| 468 | id = serializers.Field() |
| 469 | |
| 470 | class Meta: |
| 471 | model = singletonmodel |
| 472 | fields = () |
| 473 | |
| 474 | |
| 475 | class PlanetstackSerializer(serializers.HyperlinkedModelSerializer): |
| 476 | id = serializers.Field() |
| 477 | |
| 478 | class Meta: |
| 479 | model = planetstack |
| 480 | fields = ('id','created','updated','enacted','description',) |
| 481 | |
| 482 | |
| 483 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
| 484 | id = serializers.Field() |
| 485 | |
| 486 | |
| 487 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 488 | |
| 489 | |
| 490 | class Meta: |
| 491 | model = account |
| 492 | fields = ('id','created','updated','enacted',) |
| 493 | |
| 494 | |
| 495 | class NetworkparametertypeSerializer(serializers.HyperlinkedModelSerializer): |
| 496 | id = serializers.Field() |
| 497 | |
| 498 | class Meta: |
| 499 | model = networkparametertype |
| 500 | fields = ('id','created','updated','enacted','name','description',) |
| 501 | |
| 502 | |
| 503 | class SitedeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 504 | id = serializers.Field() |
| 505 | |
| 506 | |
| 507 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 508 | |
| 509 | |
| 510 | |
| 511 | deployment = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 512 | |
| 513 | |
| 514 | class Meta: |
| 515 | model = sitedeployments |
| 516 | fields = ('id','created','updated','enacted',) |
| 517 | |
| 518 | |
| 519 | class DeploymentprivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 520 | id = serializers.Field() |
| 521 | |
| 522 | |
| 523 | user = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='user-detail') |
| 524 | |
| 525 | |
| 526 | |
| 527 | deployment = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 528 | |
| 529 | |
| 530 | |
| 531 | role = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='role-detail') |
| 532 | |
| 533 | |
| 534 | class Meta: |
| 535 | model = deploymentprivilege |
| 536 | fields = ('id','created','updated','enacted',) |
| 537 | |
| 538 | |
| 539 | class DeploymentroleSerializer(serializers.HyperlinkedModelSerializer): |
| 540 | id = serializers.Field() |
| 541 | |
| 542 | class Meta: |
| 543 | model = deploymentrole |
| 544 | fields = ('id','created','updated','enacted','role',) |
| 545 | |
| 546 | |
| 547 | class PlcorebaseSerializer(serializers.HyperlinkedModelSerializer): |
| 548 | id = serializers.Field() |
| 549 | |
| 550 | class Meta: |
| 551 | model = plcorebase |
| 552 | fields = ('created','updated','enacted',) |
| 553 | |
| 554 | |
| 555 | class SlicetagSerializer(serializers.HyperlinkedModelSerializer): |
| 556 | id = serializers.Field() |
| 557 | |
| 558 | |
| 559 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 560 | |
| 561 | |
| 562 | class Meta: |
| 563 | model = slicetag |
| 564 | fields = ('id','created','updated','enacted','name','value',) |
| 565 | |
| 566 | |
| 567 | class NetworktemplateSerializer(serializers.HyperlinkedModelSerializer): |
| 568 | id = serializers.Field() |
| 569 | |
| 570 | class Meta: |
| 571 | model = networktemplate |
| 572 | fields = ('id','created','updated','enacted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',) |
| 573 | |
| 574 | |
| 575 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
| 576 | id = serializers.Field() |
| 577 | |
| 578 | class Meta: |
| 579 | model = router |
| 580 | fields = ('id','created','updated','enacted','name','owner',) |
| 581 | |
| 582 | |
| 583 | class ServiceresourceSerializer(serializers.HyperlinkedModelSerializer): |
| 584 | id = serializers.Field() |
| 585 | |
| 586 | class Meta: |
| 587 | model = serviceresource |
| 588 | fields = ('id','created','updated','enacted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 589 | |
| 590 | |
| 591 | serializerLookUp = { |
| 592 | |
| 593 | Serviceattribute: ServiceattributeSerializer, |
| 594 | |
| 595 | Image: ImageSerializer, |
| 596 | |
| 597 | Networkparameter: NetworkparameterSerializer, |
| 598 | |
| 599 | Site: SiteSerializer, |
| 600 | |
| 601 | Slicerole: SliceroleSerializer, |
| 602 | |
| 603 | Tag: TagSerializer, |
| 604 | |
| 605 | Invoice: InvoiceSerializer, |
| 606 | |
| 607 | Sliceprivilege: SliceprivilegeSerializer, |
| 608 | |
| 609 | Planetstackrole: PlanetstackroleSerializer, |
| 610 | |
| 611 | Networksliver: NetworksliverSerializer, |
| 612 | |
| 613 | Project: ProjectSerializer, |
| 614 | |
| 615 | Slice: SliceSerializer, |
| 616 | |
| 617 | Network: NetworkSerializer, |
| 618 | |
| 619 | Service: ServiceSerializer, |
| 620 | |
| 621 | Serviceclass: ServiceclassSerializer, |
| 622 | |
| 623 | Siterole: SiteroleSerializer, |
| 624 | |
| 625 | Charge: ChargeSerializer, |
| 626 | |
| 627 | Role: RoleSerializer, |
| 628 | |
| 629 | Usableobject: UsableobjectSerializer, |
| 630 | |
| 631 | Sliver: SliverSerializer, |
| 632 | |
| 633 | Node: NodeSerializer, |
| 634 | |
| 635 | Reservedresource: ReservedresourceSerializer, |
| 636 | |
| 637 | Payment: PaymentSerializer, |
| 638 | |
| 639 | Networkslice: NetworksliceSerializer, |
| 640 | |
| 641 | Planetstackprivilege: PlanetstackprivilegeSerializer, |
| 642 | |
| 643 | User: UserSerializer, |
| 644 | |
| 645 | Deployment: DeploymentSerializer, |
| 646 | |
| 647 | Reservation: ReservationSerializer, |
| 648 | |
| 649 | Siteprivilege: SiteprivilegeSerializer, |
| 650 | |
| 651 | Singletonmodel: SingletonmodelSerializer, |
| 652 | |
| 653 | Planetstack: PlanetstackSerializer, |
| 654 | |
| 655 | Account: AccountSerializer, |
| 656 | |
| 657 | Networkparametertype: NetworkparametertypeSerializer, |
| 658 | |
| 659 | Sitedeployments: SitedeploymentsSerializer, |
| 660 | |
| 661 | Deploymentprivilege: DeploymentprivilegeSerializer, |
| 662 | |
| 663 | Deploymentrole: DeploymentroleSerializer, |
| 664 | |
| 665 | Plcorebase: PlcorebaseSerializer, |
| 666 | |
| 667 | Slicetag: SlicetagSerializer, |
| 668 | |
| 669 | Networktemplate: NetworktemplateSerializer, |
| 670 | |
| 671 | Router: RouterSerializer, |
| 672 | |
| 673 | Serviceresource: ServiceresourceSerializer, |
| 674 | |
| 675 | None: None, |
| 676 | } |
| 677 | |
| 678 | # Based on core/views/*.py |
| 679 | |
| 680 | |
| 681 | class ServiceattributeList(generics.ListCreateAPIView): |
| 682 | queryset = Serviceattribute.objects.select_related.all() |
| 683 | serializer_class = ServiceattributeSerializer |
| 684 | |
| 685 | class ServiceattributeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 686 | queryset = Serviceattribute.objects.select_related.all() |
| 687 | serializer_class = ServiceattributeSerializer |
| 688 | |
| 689 | |
| 690 | |
| 691 | class ImageList(generics.ListCreateAPIView): |
| 692 | queryset = Image.objects.select_related.all() |
| 693 | serializer_class = ImageSerializer |
| 694 | |
| 695 | class ImageDetail(generics.RetrieveUpdateDestroyAPIView): |
| 696 | queryset = Image.objects.select_related.all() |
| 697 | serializer_class = ImageSerializer |
| 698 | |
| 699 | |
| 700 | |
| 701 | class NetworkparameterList(generics.ListCreateAPIView): |
| 702 | queryset = Networkparameter.objects.select_related.all() |
| 703 | serializer_class = NetworkparameterSerializer |
| 704 | |
| 705 | class NetworkparameterDetail(generics.RetrieveUpdateDestroyAPIView): |
| 706 | queryset = Networkparameter.objects.select_related.all() |
| 707 | serializer_class = NetworkparameterSerializer |
| 708 | |
| 709 | |
| 710 | |
| 711 | class SiteList(generics.ListCreateAPIView): |
| 712 | queryset = Site.objects.select_related.all() |
| 713 | serializer_class = SiteSerializer |
| 714 | |
| 715 | class SiteDetail(generics.RetrieveUpdateDestroyAPIView): |
| 716 | queryset = Site.objects.select_related.all() |
| 717 | serializer_class = SiteSerializer |
| 718 | |
| 719 | |
| 720 | |
| 721 | class SliceroleList(generics.ListCreateAPIView): |
| 722 | queryset = Slicerole.objects.select_related.all() |
| 723 | serializer_class = SliceroleSerializer |
| 724 | |
| 725 | class SliceroleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 726 | queryset = Slicerole.objects.select_related.all() |
| 727 | serializer_class = SliceroleSerializer |
| 728 | |
| 729 | |
| 730 | |
| 731 | class TagList(generics.ListCreateAPIView): |
| 732 | queryset = Tag.objects.select_related.all() |
| 733 | serializer_class = TagSerializer |
| 734 | |
| 735 | class TagDetail(generics.RetrieveUpdateDestroyAPIView): |
| 736 | queryset = Tag.objects.select_related.all() |
| 737 | serializer_class = TagSerializer |
| 738 | |
| 739 | |
| 740 | |
| 741 | class InvoiceList(generics.ListCreateAPIView): |
| 742 | queryset = Invoice.objects.select_related.all() |
| 743 | serializer_class = InvoiceSerializer |
| 744 | |
| 745 | class InvoiceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 746 | queryset = Invoice.objects.select_related.all() |
| 747 | serializer_class = InvoiceSerializer |
| 748 | |
| 749 | |
| 750 | |
| 751 | class SliceprivilegeList(generics.ListCreateAPIView): |
| 752 | queryset = Sliceprivilege.objects.select_related.all() |
| 753 | serializer_class = SliceprivilegeSerializer |
| 754 | |
| 755 | class SliceprivilegeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 756 | queryset = Sliceprivilege.objects.select_related.all() |
| 757 | serializer_class = SliceprivilegeSerializer |
| 758 | |
| 759 | |
| 760 | |
| 761 | class PlanetstackroleList(generics.ListCreateAPIView): |
| 762 | queryset = Planetstackrole.objects.select_related.all() |
| 763 | serializer_class = PlanetstackroleSerializer |
| 764 | |
| 765 | class PlanetstackroleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 766 | queryset = Planetstackrole.objects.select_related.all() |
| 767 | serializer_class = PlanetstackroleSerializer |
| 768 | |
| 769 | |
| 770 | |
| 771 | class NetworksliverList(generics.ListCreateAPIView): |
| 772 | queryset = Networksliver.objects.select_related.all() |
| 773 | serializer_class = NetworksliverSerializer |
| 774 | |
| 775 | class NetworksliverDetail(generics.RetrieveUpdateDestroyAPIView): |
| 776 | queryset = Networksliver.objects.select_related.all() |
| 777 | serializer_class = NetworksliverSerializer |
| 778 | |
| 779 | |
| 780 | |
| 781 | class ProjectList(generics.ListCreateAPIView): |
| 782 | queryset = Project.objects.select_related.all() |
| 783 | serializer_class = ProjectSerializer |
| 784 | |
| 785 | class ProjectDetail(generics.RetrieveUpdateDestroyAPIView): |
| 786 | queryset = Project.objects.select_related.all() |
| 787 | serializer_class = ProjectSerializer |
| 788 | |
| 789 | |
| 790 | |
| 791 | class SliceList(generics.ListCreateAPIView): |
| 792 | queryset = Slice.objects.select_related.all() |
| 793 | serializer_class = SliceSerializer |
| 794 | |
| 795 | class SliceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 796 | queryset = Slice.objects.select_related.all() |
| 797 | serializer_class = SliceSerializer |
| 798 | |
| 799 | |
| 800 | |
| 801 | class NetworkList(generics.ListCreateAPIView): |
| 802 | queryset = Network.objects.select_related.all() |
| 803 | serializer_class = NetworkSerializer |
| 804 | |
| 805 | class NetworkDetail(generics.RetrieveUpdateDestroyAPIView): |
| 806 | queryset = Network.objects.select_related.all() |
| 807 | serializer_class = NetworkSerializer |
| 808 | |
| 809 | |
| 810 | |
| 811 | class ServiceList(generics.ListCreateAPIView): |
| 812 | queryset = Service.objects.select_related.all() |
| 813 | serializer_class = ServiceSerializer |
| 814 | |
| 815 | class ServiceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 816 | queryset = Service.objects.select_related.all() |
| 817 | serializer_class = ServiceSerializer |
| 818 | |
| 819 | |
| 820 | |
| 821 | class ServiceclassList(generics.ListCreateAPIView): |
| 822 | queryset = Serviceclass.objects.select_related.all() |
| 823 | serializer_class = ServiceclassSerializer |
| 824 | |
| 825 | class ServiceclassDetail(generics.RetrieveUpdateDestroyAPIView): |
| 826 | queryset = Serviceclass.objects.select_related.all() |
| 827 | serializer_class = ServiceclassSerializer |
| 828 | |
| 829 | |
| 830 | |
| 831 | class SiteroleList(generics.ListCreateAPIView): |
| 832 | queryset = Siterole.objects.select_related.all() |
| 833 | serializer_class = SiteroleSerializer |
| 834 | |
| 835 | class SiteroleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 836 | queryset = Siterole.objects.select_related.all() |
| 837 | serializer_class = SiteroleSerializer |
| 838 | |
| 839 | |
| 840 | |
| 841 | class ChargeList(generics.ListCreateAPIView): |
| 842 | queryset = Charge.objects.select_related.all() |
| 843 | serializer_class = ChargeSerializer |
| 844 | |
| 845 | class ChargeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 846 | queryset = Charge.objects.select_related.all() |
| 847 | serializer_class = ChargeSerializer |
| 848 | |
| 849 | |
| 850 | |
| 851 | class RoleList(generics.ListCreateAPIView): |
| 852 | queryset = Role.objects.select_related.all() |
| 853 | serializer_class = RoleSerializer |
| 854 | |
| 855 | class RoleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 856 | queryset = Role.objects.select_related.all() |
| 857 | serializer_class = RoleSerializer |
| 858 | |
| 859 | |
| 860 | |
| 861 | class UsableobjectList(generics.ListCreateAPIView): |
| 862 | queryset = Usableobject.objects.select_related.all() |
| 863 | serializer_class = UsableobjectSerializer |
| 864 | |
| 865 | class UsableobjectDetail(generics.RetrieveUpdateDestroyAPIView): |
| 866 | queryset = Usableobject.objects.select_related.all() |
| 867 | serializer_class = UsableobjectSerializer |
| 868 | |
| 869 | |
| 870 | |
| 871 | class SliverList(generics.ListCreateAPIView): |
| 872 | queryset = Sliver.objects.select_related.all() |
| 873 | serializer_class = SliverSerializer |
| 874 | |
| 875 | class SliverDetail(generics.RetrieveUpdateDestroyAPIView): |
| 876 | queryset = Sliver.objects.select_related.all() |
| 877 | serializer_class = SliverSerializer |
| 878 | |
| 879 | |
| 880 | |
| 881 | class NodeList(generics.ListCreateAPIView): |
| 882 | queryset = Node.objects.select_related.all() |
| 883 | serializer_class = NodeSerializer |
| 884 | |
| 885 | class NodeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 886 | queryset = Node.objects.select_related.all() |
| 887 | serializer_class = NodeSerializer |
| 888 | |
| 889 | |
| 890 | |
| 891 | class ReservedresourceList(generics.ListCreateAPIView): |
| 892 | queryset = Reservedresource.objects.select_related.all() |
| 893 | serializer_class = ReservedresourceSerializer |
| 894 | |
| 895 | class ReservedresourceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 896 | queryset = Reservedresource.objects.select_related.all() |
| 897 | serializer_class = ReservedresourceSerializer |
| 898 | |
| 899 | |
| 900 | |
| 901 | class PaymentList(generics.ListCreateAPIView): |
| 902 | queryset = Payment.objects.select_related.all() |
| 903 | serializer_class = PaymentSerializer |
| 904 | |
| 905 | class PaymentDetail(generics.RetrieveUpdateDestroyAPIView): |
| 906 | queryset = Payment.objects.select_related.all() |
| 907 | serializer_class = PaymentSerializer |
| 908 | |
| 909 | |
| 910 | |
| 911 | class NetworksliceList(generics.ListCreateAPIView): |
| 912 | queryset = Networkslice.objects.select_related.all() |
| 913 | serializer_class = NetworksliceSerializer |
| 914 | |
| 915 | class NetworksliceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 916 | queryset = Networkslice.objects.select_related.all() |
| 917 | serializer_class = NetworksliceSerializer |
| 918 | |
| 919 | |
| 920 | |
| 921 | class PlanetstackprivilegeList(generics.ListCreateAPIView): |
| 922 | queryset = Planetstackprivilege.objects.select_related.all() |
| 923 | serializer_class = PlanetstackprivilegeSerializer |
| 924 | |
| 925 | class PlanetstackprivilegeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 926 | queryset = Planetstackprivilege.objects.select_related.all() |
| 927 | serializer_class = PlanetstackprivilegeSerializer |
| 928 | |
| 929 | |
| 930 | |
| 931 | class UserList(generics.ListCreateAPIView): |
| 932 | queryset = User.objects.select_related.all() |
| 933 | serializer_class = UserSerializer |
| 934 | |
| 935 | class UserDetail(generics.RetrieveUpdateDestroyAPIView): |
| 936 | queryset = User.objects.select_related.all() |
| 937 | serializer_class = UserSerializer |
| 938 | |
| 939 | |
| 940 | |
| 941 | class DeploymentList(generics.ListCreateAPIView): |
| 942 | queryset = Deployment.objects.select_related.all() |
| 943 | serializer_class = DeploymentSerializer |
| 944 | |
| 945 | class DeploymentDetail(generics.RetrieveUpdateDestroyAPIView): |
| 946 | queryset = Deployment.objects.select_related.all() |
| 947 | serializer_class = DeploymentSerializer |
| 948 | |
| 949 | |
| 950 | |
| 951 | class ReservationList(generics.ListCreateAPIView): |
| 952 | queryset = Reservation.objects.select_related.all() |
| 953 | serializer_class = ReservationSerializer |
| 954 | |
| 955 | class ReservationDetail(generics.RetrieveUpdateDestroyAPIView): |
| 956 | queryset = Reservation.objects.select_related.all() |
| 957 | serializer_class = ReservationSerializer |
| 958 | |
| 959 | |
| 960 | |
| 961 | class SiteprivilegeList(generics.ListCreateAPIView): |
| 962 | queryset = Siteprivilege.objects.select_related.all() |
| 963 | serializer_class = SiteprivilegeSerializer |
| 964 | |
| 965 | class SiteprivilegeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 966 | queryset = Siteprivilege.objects.select_related.all() |
| 967 | serializer_class = SiteprivilegeSerializer |
| 968 | |
| 969 | |
| 970 | |
| 971 | class SingletonmodelList(generics.ListCreateAPIView): |
| 972 | queryset = Singletonmodel.objects.select_related.all() |
| 973 | serializer_class = SingletonmodelSerializer |
| 974 | |
| 975 | class SingletonmodelDetail(generics.RetrieveUpdateDestroyAPIView): |
| 976 | queryset = Singletonmodel.objects.select_related.all() |
| 977 | serializer_class = SingletonmodelSerializer |
| 978 | |
| 979 | |
| 980 | |
| 981 | class PlanetstackList(generics.ListCreateAPIView): |
| 982 | queryset = Planetstack.objects.select_related.all() |
| 983 | serializer_class = PlanetstackSerializer |
| 984 | |
| 985 | class PlanetstackDetail(generics.RetrieveUpdateDestroyAPIView): |
| 986 | queryset = Planetstack.objects.select_related.all() |
| 987 | serializer_class = PlanetstackSerializer |
| 988 | |
| 989 | |
| 990 | |
| 991 | class AccountList(generics.ListCreateAPIView): |
| 992 | queryset = Account.objects.select_related.all() |
| 993 | serializer_class = AccountSerializer |
| 994 | |
| 995 | class AccountDetail(generics.RetrieveUpdateDestroyAPIView): |
| 996 | queryset = Account.objects.select_related.all() |
| 997 | serializer_class = AccountSerializer |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | class NetworkparametertypeList(generics.ListCreateAPIView): |
| 1002 | queryset = Networkparametertype.objects.select_related.all() |
| 1003 | serializer_class = NetworkparametertypeSerializer |
| 1004 | |
| 1005 | class NetworkparametertypeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1006 | queryset = Networkparametertype.objects.select_related.all() |
| 1007 | serializer_class = NetworkparametertypeSerializer |
| 1008 | |
| 1009 | |
| 1010 | |
| 1011 | class SitedeploymentsList(generics.ListCreateAPIView): |
| 1012 | queryset = Sitedeployments.objects.select_related.all() |
| 1013 | serializer_class = SitedeploymentsSerializer |
| 1014 | |
| 1015 | class SitedeploymentsDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1016 | queryset = Sitedeployments.objects.select_related.all() |
| 1017 | serializer_class = SitedeploymentsSerializer |
| 1018 | |
| 1019 | |
| 1020 | |
| 1021 | class DeploymentprivilegeList(generics.ListCreateAPIView): |
| 1022 | queryset = Deploymentprivilege.objects.select_related.all() |
| 1023 | serializer_class = DeploymentprivilegeSerializer |
| 1024 | |
| 1025 | class DeploymentprivilegeDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1026 | queryset = Deploymentprivilege.objects.select_related.all() |
| 1027 | serializer_class = DeploymentprivilegeSerializer |
| 1028 | |
| 1029 | |
| 1030 | |
| 1031 | class DeploymentroleList(generics.ListCreateAPIView): |
| 1032 | queryset = Deploymentrole.objects.select_related.all() |
| 1033 | serializer_class = DeploymentroleSerializer |
| 1034 | |
| 1035 | class DeploymentroleDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1036 | queryset = Deploymentrole.objects.select_related.all() |
| 1037 | serializer_class = DeploymentroleSerializer |
| 1038 | |
| 1039 | |
| 1040 | |
| 1041 | class PlcorebaseList(generics.ListCreateAPIView): |
| 1042 | queryset = Plcorebase.objects.select_related.all() |
| 1043 | serializer_class = PlcorebaseSerializer |
| 1044 | |
| 1045 | class PlcorebaseDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1046 | queryset = Plcorebase.objects.select_related.all() |
| 1047 | serializer_class = PlcorebaseSerializer |
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | class SlicetagList(generics.ListCreateAPIView): |
| 1052 | queryset = Slicetag.objects.select_related.all() |
| 1053 | serializer_class = SlicetagSerializer |
| 1054 | |
| 1055 | class SlicetagDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1056 | queryset = Slicetag.objects.select_related.all() |
| 1057 | serializer_class = SlicetagSerializer |
| 1058 | |
| 1059 | |
| 1060 | |
| 1061 | class NetworktemplateList(generics.ListCreateAPIView): |
| 1062 | queryset = Networktemplate.objects.select_related.all() |
| 1063 | serializer_class = NetworktemplateSerializer |
| 1064 | |
| 1065 | class NetworktemplateDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1066 | queryset = Networktemplate.objects.select_related.all() |
| 1067 | serializer_class = NetworktemplateSerializer |
| 1068 | |
| 1069 | |
| 1070 | |
| 1071 | class RouterList(generics.ListCreateAPIView): |
| 1072 | queryset = Router.objects.select_related.all() |
| 1073 | serializer_class = RouterSerializer |
| 1074 | |
| 1075 | class RouterDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1076 | queryset = Router.objects.select_related.all() |
| 1077 | serializer_class = RouterSerializer |
| 1078 | |
| 1079 | |
| 1080 | |
| 1081 | class ServiceresourceList(generics.ListCreateAPIView): |
| 1082 | queryset = Serviceresource.objects.select_related.all() |
| 1083 | serializer_class = ServiceresourceSerializer |
| 1084 | |
| 1085 | class ServiceresourceDetail(generics.RetrieveUpdateDestroyAPIView): |
| 1086 | queryset = Serviceresource.objects.select_related.all() |
| 1087 | serializer_class = ServiceresourceSerializer |
| 1088 | |
| 1089 | |
| 1090 | |