Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1 | from rest_framework.decorators import api_view |
| 2 | from rest_framework.response import Response |
| 3 | from rest_framework.reverse import reverse |
| 4 | from rest_framework import serializers |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5 | from rest_framework import generics |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 7 | from rest_framework.generics import GenericAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 8 | from core.models import * |
| 9 | from django.forms import widgets |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 10 | from rest_framework import filters |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 11 | from django.conf.urls import patterns, url |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 12 | from rest_framework.exceptions import PermissionDenied as RestFrameworkPermissionDenied |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 13 | from django.core.exceptions import PermissionDenied as DjangoPermissionDenied |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 14 | |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 15 | if hasattr(serializers, "ReadOnlyField"): |
| 16 | # rest_framework 3.x |
| 17 | IdField = serializers.ReadOnlyField |
| 18 | else: |
| 19 | # rest_framework 2.x |
| 20 | IdField = serializers.Field |
| 21 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 22 | """ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 23 | Schema of the generator object: |
| 24 | all: Set of all Model objects |
| 25 | all_if(regex): Set of Model objects that match regex |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 26 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 27 | Model object: |
| 28 | plural: English plural of object name |
| 29 | camel: CamelCase version of object name |
| 30 | refs: list of references to other Model objects |
| 31 | props: list of properties minus refs |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 32 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 33 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 34 | """ |
| 35 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 36 | def get_REST_patterns(): |
| 37 | return patterns('', |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 38 | url(r'^xos/$', api_root), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 39 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 40 | url(r'xos/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 41 | url(r'xos/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 42 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 43 | url(r'xos/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'), |
| 44 | url(r'xos/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 45 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 46 | url(r'xos/controllersiteprivileges/$', ControllerSitePrivilegeList.as_view(), name='controllersiteprivilege-list'), |
| 47 | url(r'xos/controllersiteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSitePrivilegeDetail.as_view(), name ='controllersiteprivilege-detail'), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 48 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 49 | url(r'xos/images/$', ImageList.as_view(), name='image-list'), |
| 50 | url(r'xos/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 51 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 52 | url(r'xos/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 53 | url(r'xos/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 54 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 55 | url(r'xos/sites/$', SiteList.as_view(), name='site-list'), |
| 56 | url(r'xos/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 57 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 58 | url(r'xos/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 59 | url(r'xos/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 60 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 61 | url(r'xos/tags/$', TagList.as_view(), name='tag-list'), |
| 62 | url(r'xos/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 63 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 64 | url(r'xos/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 65 | url(r'xos/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 66 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 67 | url(r'xos/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 68 | url(r'xos/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 69 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 70 | url(r'xos/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 71 | url(r'xos/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 72 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 73 | url(r'xos/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 74 | url(r'xos/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 75 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 76 | url(r'xos/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 77 | url(r'xos/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 78 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 79 | url(r'xos/controllersites/$', ControllerSiteList.as_view(), name='controllersite-list'), |
| 80 | url(r'xos/controllersites/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDetail.as_view(), name ='controllersite-detail'), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 81 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 82 | url(r'xos/projects/$', ProjectList.as_view(), name='project-list'), |
| 83 | url(r'xos/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 84 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 85 | url(r'xos/slices/$', SliceList.as_view(), name='slice-list'), |
| 86 | url(r'xos/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 87 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 88 | url(r'xos/networks/$', NetworkList.as_view(), name='network-list'), |
| 89 | url(r'xos/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 90 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 91 | url(r'xos/services/$', ServiceList.as_view(), name='service-list'), |
| 92 | url(r'xos/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 93 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 94 | url(r'xos/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 95 | url(r'xos/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 96 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 97 | url(r'xos/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 98 | url(r'xos/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 99 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 100 | url(r'xos/charges/$', ChargeList.as_view(), name='charge-list'), |
| 101 | url(r'xos/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 102 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 103 | url(r'xos/roles/$', RoleList.as_view(), name='role-list'), |
| 104 | url(r'xos/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 105 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 106 | url(r'xos/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 107 | url(r'xos/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 108 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 109 | url(r'xos/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 110 | url(r'xos/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 111 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 112 | url(r'xos/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 113 | url(r'xos/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 114 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 115 | url(r'xos/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 116 | url(r'xos/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 117 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 118 | url(r'xos/nodes/$', NodeList.as_view(), name='node-list'), |
| 119 | url(r'xos/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 120 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 121 | url(r'xos/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 122 | url(r'xos/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 123 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 124 | url(r'xos/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetwork-list'), |
| 125 | url(r'xos/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetwork-detail'), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 126 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 127 | url(r'xos/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 128 | url(r'xos/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 129 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 130 | url(r'xos/controllerusers/$', ControllerUserList.as_view(), name='controlleruser-list'), |
| 131 | url(r'xos/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controlleruser-detail'), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 132 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 133 | url(r'xos/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 134 | url(r'xos/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 135 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 136 | url(r'xos/payments/$', PaymentList.as_view(), name='payment-list'), |
| 137 | url(r'xos/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 138 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 139 | url(r'xos/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 140 | url(r'xos/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 141 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 142 | url(r'xos/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 143 | url(r'xos/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 144 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 145 | url(r'xos/controllers/$', ControllerList.as_view(), name='controller-list'), |
| 146 | url(r'xos/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 147 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 148 | url(r'xos/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 149 | url(r'xos/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 150 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 151 | url(r'xos/users/$', UserList.as_view(), name='user-list'), |
| 152 | url(r'xos/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 153 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 154 | url(r'xos/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 155 | url(r'xos/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 156 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 157 | url(r'xos/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 158 | url(r'xos/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 159 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 160 | url(r'xos/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 161 | url(r'xos/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 162 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 163 | url(r'xos/controllerslices/$', ControllerSliceList.as_view(), name='controllerslice-list'), |
| 164 | url(r'xos/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslice-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 165 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 166 | url(r'xos/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'), |
| 167 | url(r'xos/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 168 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 169 | url(r'xos/accounts/$', AccountList.as_view(), name='account-list'), |
| 170 | url(r'xos/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 171 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 172 | url(r'xos/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 173 | url(r'xos/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 174 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 175 | url(r'xos/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 176 | url(r'xos/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 177 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 178 | url(r'xos/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 179 | url(r'xos/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 180 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 181 | url(r'xos/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 182 | url(r'xos/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 183 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 184 | url(r'xos/controllersliceprivileges/$', ControllerSlicePrivilegeList.as_view(), name='controllersliceprivilege-list'), |
| 185 | url(r'xos/controllersliceprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicePrivilegeDetail.as_view(), name ='controllersliceprivilege-detail'), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 186 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 187 | url(r'xos/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployment-list'), |
| 188 | url(r'xos/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployment-detail'), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 189 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 190 | url(r'xos/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 191 | url(r'xos/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 192 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 193 | url(r'xos/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 194 | url(r'xos/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 195 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 196 | url(r'xos/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 197 | url(r'xos/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 198 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 199 | url(r'xos/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 200 | url(r'xos/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 201 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 202 | url(r'xos/routers/$', RouterList.as_view(), name='router-list'), |
| 203 | url(r'xos/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 204 | |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 205 | url(r'xos/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 206 | url(r'xos/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 207 | |
| 208 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 209 | |
| 210 | @api_view(['GET']) |
| 211 | def api_root(request, format=None): |
| 212 | return Response({ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 213 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 214 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 215 | 'controllersiteprivileges': reverse('controllersiteprivilege-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 216 | 'images': reverse('image-list', request=request, format=format), |
| 217 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 218 | 'sites': reverse('site-list', request=request, format=format), |
| 219 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 220 | 'tags': reverse('tag-list', request=request, format=format), |
| 221 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 222 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 223 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
| 224 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 225 | 'flavors': reverse('flavor-list', request=request, format=format), |
| 226 | 'controllersites': reverse('controllersite-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 227 | 'projects': reverse('project-list', request=request, format=format), |
| 228 | 'slices': reverse('slice-list', request=request, format=format), |
| 229 | 'networks': reverse('network-list', request=request, format=format), |
| 230 | 'services': reverse('service-list', request=request, format=format), |
| 231 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 232 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 233 | 'charges': reverse('charge-list', request=request, format=format), |
| 234 | 'roles': reverse('role-list', request=request, format=format), |
| 235 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
| 236 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 237 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 238 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 239 | 'nodes': reverse('node-list', request=request, format=format), |
| 240 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 241 | 'controllernetworks': reverse('controllernetwork-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 242 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 243 | 'controllerusers': reverse('controlleruser-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 244 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 245 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 246 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 247 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 248 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 249 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 250 | 'users': reverse('user-list', request=request, format=format), |
| 251 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 252 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 253 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 254 | 'controllerslices': reverse('controllerslice-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 255 | 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 256 | 'accounts': reverse('account-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 257 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 258 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 259 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 260 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 261 | 'controllersliceprivileges': reverse('controllersliceprivilege-list', request=request, format=format), |
| 262 | 'sitedeployments': reverse('sitedeployment-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 263 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 264 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 265 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 266 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 267 | 'routers': reverse('router-list', request=request, format=format), |
| 268 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
| 269 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 270 | }) |
| 271 | |
| 272 | # Based on serializers.py |
| 273 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 274 | class XOSModelSerializer(serializers.ModelSerializer): |
| 275 | def save_object(self, obj, **kwargs): |
| 276 | |
| 277 | """ rest_framework can't deal with ManyToMany relations that have a |
Scott Baker | 1faefd3 | 2015-02-02 15:53:37 -0800 | [diff] [blame] | 278 | through table. In xos, most of the through tables we have |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 279 | use defaults or blank fields, so there's no reason why we shouldn't |
| 280 | be able to save these objects. |
| 281 | |
| 282 | So, let's strip out these m2m relations, and deal with them ourself. |
| 283 | """ |
| 284 | obj._complex_m2m_data={};
|
| 285 | if getattr(obj, '_m2m_data', None):
|
| 286 | for relatedObject in obj._meta.get_all_related_many_to_many_objects():
|
| 287 | if (relatedObject.field.rel.through._meta.auto_created):
|
| 288 | # These are non-trough ManyToMany relations and
|
| 289 | # can be updated just fine
|
| 290 | continue
|
| 291 | fieldName = relatedObject.get_accessor_name()
|
| 292 | if fieldName in obj._m2m_data.keys():
|
| 293 | obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
|
| 294 | del obj._m2m_data[fieldName]
|
| 295 |
|
| 296 | serializers.ModelSerializer.save_object(self, obj, **kwargs); |
| 297 | |
| 298 | for (accessor, stuff) in obj._complex_m2m_data.items(): |
| 299 | (relatedObject, data) = stuff |
| 300 | through = relatedObject.field.rel.through |
| 301 | local_fieldName = relatedObject.field.m2m_reverse_field_name() |
| 302 | remote_fieldName = relatedObject.field.m2m_field_name() |
| 303 | |
| 304 | # get the current set of existing relations |
| 305 | existing = through.objects.filter(**{local_fieldName: obj}); |
| 306 | |
| 307 | data_ids = [item.id for item in data] |
| 308 | existing_ids = [getattr(item,remote_fieldName).id for item in existing] |
| 309 | |
| 310 | #print "data_ids", data_ids |
| 311 | #print "existing_ids", existing_ids |
| 312 | |
| 313 | # remove relations that are in 'existing' but not in 'data' |
| 314 | for item in list(existing): |
| 315 | if (getattr(item,remote_fieldName).id not in data_ids): |
| 316 | print "delete", getattr(item,remote_fieldName) |
| 317 | item.delete() #(purge=True) |
| 318 | |
| 319 | # add relations that are in 'data' but not in 'existing' |
| 320 | for item in data: |
| 321 | if (item.id not in existing_ids): |
| 322 | #print "add", item |
| 323 | newModel = through(**{local_fieldName: obj, remote_fieldName: item}) |
| 324 | newModel.save() |
| 325 | |
| 326 | |
| 327 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 328 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 329 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 330 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 331 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 332 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 333 | def getHumanReadableName(self, obj):
|
| 334 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 335 | def getValidators(self, obj): |
| 336 | try: |
| 337 | return obj.getValidators() |
| 338 | except: |
| 339 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 340 | class Meta: |
| 341 | model = ServiceAttribute |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 342 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 343 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 344 | class ServiceAttributeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 345 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 346 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 347 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 348 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 349 | def getHumanReadableName(self, obj):
|
| 350 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 351 | def getValidators(self, obj):
|
| 352 | try: |
| 353 | return obj.getValidators() |
| 354 | except: |
| 355 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 356 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 357 | model = ServiceAttribute |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 358 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 359 | |
| 360 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 361 | |
| 362 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 363 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 364 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 365 | |
| 366 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 367 | validators = serializers.SerializerMethodField("getValidators") |
| 368 | def getHumanReadableName(self, obj):
|
| 369 | return str(obj) |
| 370 | def getValidators(self, obj): |
| 371 | try: |
| 372 | return obj.getValidators() |
| 373 | except: |
| 374 | return None |
| 375 | class Meta: |
| 376 | model = ControllerImages |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 377 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 378 | |
| 379 | class ControllerImagesIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 380 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 381 | |
| 382 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 383 | validators = serializers.SerializerMethodField("getValidators") |
| 384 | def getHumanReadableName(self, obj):
|
| 385 | return str(obj)
|
| 386 | def getValidators(self, obj):
|
| 387 | try: |
| 388 | return obj.getValidators() |
| 389 | except: |
| 390 | return None
|
| 391 | class Meta:
|
| 392 | model = ControllerImages |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 393 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 394 | |
| 395 | |
| 396 | |
| 397 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 398 | class ControllerSitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 399 | id = IdField() |
| 400 | |
| 401 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 402 | validators = serializers.SerializerMethodField("getValidators") |
| 403 | def getHumanReadableName(self, obj):
|
| 404 | return str(obj) |
| 405 | def getValidators(self, obj): |
| 406 | try: |
| 407 | return obj.getValidators() |
| 408 | except: |
| 409 | return None |
| 410 | class Meta: |
| 411 | model = ControllerSitePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 412 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 413 | |
| 414 | class ControllerSitePrivilegeIdSerializer(XOSModelSerializer): |
| 415 | id = IdField() |
| 416 | |
| 417 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 418 | validators = serializers.SerializerMethodField("getValidators") |
| 419 | def getHumanReadableName(self, obj):
|
| 420 | return str(obj)
|
| 421 | def getValidators(self, obj):
|
| 422 | try: |
| 423 | return obj.getValidators() |
| 424 | except: |
| 425 | return None
|
| 426 | class Meta:
|
| 427 | model = ControllerSitePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 428 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 429 | |
| 430 | |
| 431 | |
| 432 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 433 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 434 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 435 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 436 | |
| 437 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 438 | |
| 439 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 440 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 441 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 442 | def getHumanReadableName(self, obj):
|
| 443 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 444 | def getValidators(self, obj): |
| 445 | try: |
| 446 | return obj.getValidators() |
| 447 | except: |
| 448 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 449 | class Meta: |
| 450 | model = Image |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 451 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 452 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 453 | class ImageIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 454 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 455 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 456 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 457 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 458 | |
| 459 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 460 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 461 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 462 | def getHumanReadableName(self, obj):
|
| 463 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 464 | def getValidators(self, obj):
|
| 465 | try: |
| 466 | return obj.getValidators() |
| 467 | except: |
| 468 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 469 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 470 | model = Image |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 471 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 472 | |
| 473 | |
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 NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 477 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 478 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 479 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 480 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 481 | def getHumanReadableName(self, obj):
|
| 482 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 483 | def getValidators(self, obj): |
| 484 | try: |
| 485 | return obj.getValidators() |
| 486 | except: |
| 487 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 488 | class Meta: |
| 489 | model = NetworkParameter |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 490 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 491 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 492 | class NetworkParameterIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 493 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 494 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 495 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 496 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 497 | def getHumanReadableName(self, obj):
|
| 498 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 499 | def getValidators(self, obj):
|
| 500 | try: |
| 501 | return obj.getValidators() |
| 502 | except: |
| 503 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 504 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 505 | model = NetworkParameter |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 506 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 507 | |
| 508 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 509 | |
| 510 | |
| 511 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 512 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 513 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 514 | |
| 515 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 516 | |
| 517 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 518 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 519 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 520 | def getHumanReadableName(self, obj):
|
| 521 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 522 | def getValidators(self, obj): |
| 523 | try: |
| 524 | return obj.getValidators() |
| 525 | except: |
| 526 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 527 | class Meta: |
| 528 | model = Site |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 529 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 530 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 531 | class SiteIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 532 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 533 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 534 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 535 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 536 | |
| 537 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 538 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 539 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 540 | def getHumanReadableName(self, obj):
|
| 541 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 542 | def getValidators(self, obj):
|
| 543 | try: |
| 544 | return obj.getValidators() |
| 545 | except: |
| 546 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 547 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 548 | model = Site |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 549 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 550 | |
| 551 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 552 | |
| 553 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 554 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 555 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 556 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 557 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 558 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 559 | def getHumanReadableName(self, obj):
|
| 560 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 561 | def getValidators(self, obj): |
| 562 | try: |
| 563 | return obj.getValidators() |
| 564 | except: |
| 565 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 566 | class Meta: |
| 567 | model = SliceRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 568 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 569 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 570 | class SliceRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 571 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 572 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 573 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 574 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 575 | def getHumanReadableName(self, obj):
|
| 576 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 577 | def getValidators(self, obj):
|
| 578 | try: |
| 579 | return obj.getValidators() |
| 580 | except: |
| 581 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 582 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 583 | model = SliceRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 584 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 585 | |
| 586 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 587 | |
| 588 | |
| 589 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 590 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 591 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 592 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 593 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 594 | def getHumanReadableName(self, obj):
|
| 595 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 596 | def getValidators(self, obj): |
| 597 | try: |
| 598 | return obj.getValidators() |
| 599 | except: |
| 600 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 601 | class Meta: |
| 602 | model = Tag |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 603 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 604 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 605 | class TagIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 606 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 607 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 608 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 609 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 610 | def getHumanReadableName(self, obj):
|
| 611 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 612 | def getValidators(self, obj):
|
| 613 | try: |
| 614 | return obj.getValidators() |
| 615 | except: |
| 616 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 617 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 618 | model = Tag |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 619 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 620 | |
| 621 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 622 | |
| 623 | |
| 624 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 625 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 626 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 627 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 628 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 629 | def getHumanReadableName(self, obj):
|
| 630 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 631 | def getValidators(self, obj): |
| 632 | try: |
| 633 | return obj.getValidators() |
| 634 | except: |
| 635 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 636 | class Meta: |
| 637 | model = Invoice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 638 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 639 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 640 | class InvoiceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 641 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 642 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 643 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 644 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 645 | def getHumanReadableName(self, obj):
|
| 646 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 647 | def getValidators(self, obj):
|
| 648 | try: |
| 649 | return obj.getValidators() |
| 650 | except: |
| 651 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 652 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 653 | model = Invoice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 654 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 655 | |
| 656 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 657 | |
| 658 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 659 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 660 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 661 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 662 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 663 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 664 | def getHumanReadableName(self, obj):
|
| 665 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 666 | def getValidators(self, obj): |
| 667 | try: |
| 668 | return obj.getValidators() |
| 669 | except: |
| 670 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 671 | class Meta: |
| 672 | model = SlicePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 673 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 674 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 675 | class SlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 676 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 677 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 678 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 679 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 680 | def getHumanReadableName(self, obj):
|
| 681 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 682 | def getValidators(self, obj):
|
| 683 | try: |
| 684 | return obj.getValidators() |
| 685 | except: |
| 686 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 687 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 688 | model = SlicePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 689 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 690 | |
| 691 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 692 | |
| 693 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 694 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 695 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 696 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 697 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 698 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 699 | def getHumanReadableName(self, obj):
|
| 700 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 701 | def getValidators(self, obj): |
| 702 | try: |
| 703 | return obj.getValidators() |
| 704 | except: |
| 705 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 706 | class Meta: |
| 707 | model = PlanetStackRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 708 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 709 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 710 | class PlanetStackRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 711 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 712 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 713 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 714 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 715 | def getHumanReadableName(self, obj):
|
| 716 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 717 | def getValidators(self, obj):
|
| 718 | try: |
| 719 | return obj.getValidators() |
| 720 | except: |
| 721 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 722 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 723 | model = PlanetStackRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 724 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 725 | |
| 726 | |
| 727 | |
| 728 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 729 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 730 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 731 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 732 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 733 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 734 | def getHumanReadableName(self, obj):
|
| 735 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 736 | def getValidators(self, obj): |
| 737 | try: |
| 738 | return obj.getValidators() |
| 739 | except: |
| 740 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 741 | class Meta: |
| 742 | model = NetworkSliver |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 743 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 744 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 745 | class NetworkSliverIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 746 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 747 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 748 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 749 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 750 | def getHumanReadableName(self, obj):
|
| 751 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 752 | def getValidators(self, obj):
|
| 753 | try: |
| 754 | return obj.getValidators() |
| 755 | except: |
| 756 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 757 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 758 | model = NetworkSliver |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 759 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 760 | |
| 761 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 762 | |
| 763 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 764 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
| 765 | id = IdField() |
| 766 | |
| 767 | |
| 768 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 769 | |
| 770 | |
| 771 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 772 | validators = serializers.SerializerMethodField("getValidators") |
| 773 | def getHumanReadableName(self, obj):
|
| 774 | return str(obj) |
| 775 | def getValidators(self, obj): |
| 776 | try: |
| 777 | return obj.getValidators() |
| 778 | except: |
| 779 | return None |
| 780 | class Meta: |
| 781 | model = Flavor |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 782 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 783 | |
| 784 | class FlavorIdSerializer(XOSModelSerializer): |
| 785 | id = IdField() |
| 786 | |
| 787 | |
| 788 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
| 789 | |
| 790 | |
| 791 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 792 | validators = serializers.SerializerMethodField("getValidators") |
| 793 | def getHumanReadableName(self, obj):
|
| 794 | return str(obj)
|
| 795 | def getValidators(self, obj):
|
| 796 | try: |
| 797 | return obj.getValidators() |
| 798 | except: |
| 799 | return None
|
| 800 | class Meta:
|
| 801 | model = Flavor |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 802 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | class ControllerSiteSerializer(serializers.HyperlinkedModelSerializer): |
| 808 | id = IdField() |
| 809 | |
| 810 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 811 | validators = serializers.SerializerMethodField("getValidators") |
| 812 | def getHumanReadableName(self, obj):
|
| 813 | return str(obj) |
| 814 | def getValidators(self, obj): |
| 815 | try: |
| 816 | return obj.getValidators() |
| 817 | except: |
| 818 | return None |
| 819 | class Meta: |
| 820 | model = ControllerSite |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 821 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 822 | |
| 823 | class ControllerSiteIdSerializer(XOSModelSerializer): |
| 824 | id = IdField() |
| 825 | |
| 826 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 827 | validators = serializers.SerializerMethodField("getValidators") |
| 828 | def getHumanReadableName(self, obj):
|
| 829 | return str(obj)
|
| 830 | def getValidators(self, obj):
|
| 831 | try: |
| 832 | return obj.getValidators() |
| 833 | except: |
| 834 | return None
|
| 835 | class Meta:
|
| 836 | model = ControllerSite |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 837 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 838 | |
| 839 | |
| 840 | |
| 841 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 842 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 843 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 844 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 845 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 846 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 847 | def getHumanReadableName(self, obj):
|
| 848 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 849 | def getValidators(self, obj): |
| 850 | try: |
| 851 | return obj.getValidators() |
| 852 | except: |
| 853 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 854 | class Meta: |
| 855 | model = Project |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 856 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 857 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 858 | class ProjectIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 859 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 860 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 861 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 862 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 863 | def getHumanReadableName(self, obj):
|
| 864 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 865 | def getValidators(self, obj):
|
| 866 | try: |
| 867 | return obj.getValidators() |
| 868 | except: |
| 869 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 870 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 871 | model = Project |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 872 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 873 | |
| 874 | |
| 875 | |
| 876 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 877 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 878 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 879 | |
| 880 | |
| 881 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 882 | |
| 883 | |
| 884 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 885 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 886 | |
| 887 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 888 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 889 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 890 | def getHumanReadableName(self, obj):
|
| 891 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 892 | def getValidators(self, obj): |
| 893 | try: |
| 894 | return obj.getValidators() |
| 895 | except: |
| 896 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 897 | class Meta: |
| 898 | model = Slice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 899 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 900 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 901 | class SliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 902 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 903 | |
| 904 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 905 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 906 | |
| 907 | |
| 908 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 909 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 910 | |
| 911 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 912 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 913 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 914 | def getHumanReadableName(self, obj):
|
| 915 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 916 | def getValidators(self, obj):
|
| 917 | try: |
| 918 | return obj.getValidators() |
| 919 | except: |
| 920 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 921 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 922 | model = Slice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 923 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 924 | |
| 925 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 926 | |
| 927 | |
| 928 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 929 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 930 | |
| 931 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 932 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 933 | |
| 934 | |
| 935 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 936 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 937 | |
| 938 | |
| 939 | |
| 940 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 941 | |
| 942 | |
| 943 | |
| 944 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 945 | |
| 946 | |
| 947 | |
| 948 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 949 | |
| 950 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 951 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 952 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 953 | def getHumanReadableName(self, obj):
|
| 954 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 955 | def getValidators(self, obj): |
| 956 | try: |
| 957 | return obj.getValidators() |
| 958 | except: |
| 959 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 960 | class Meta: |
| 961 | model = Network |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 962 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 963 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 964 | class NetworkIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 965 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 966 | |
| 967 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 968 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 969 | |
| 970 | |
| 971 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 972 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 973 | |
| 974 | |
| 975 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 976 | slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 977 | |
| 978 | |
| 979 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 980 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 981 | |
| 982 | |
| 983 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 984 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 985 | |
| 986 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 987 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 988 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 989 | def getHumanReadableName(self, obj):
|
| 990 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 991 | def getValidators(self, obj):
|
| 992 | try: |
| 993 | return obj.getValidators() |
| 994 | except: |
| 995 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 996 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 997 | model = Network |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 998 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 999 | |
| 1000 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1001 | |
| 1002 | |
| 1003 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1004 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1005 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1006 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1007 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1008 | def getHumanReadableName(self, obj):
|
| 1009 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1010 | def getValidators(self, obj): |
| 1011 | try: |
| 1012 | return obj.getValidators() |
| 1013 | except: |
| 1014 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1015 | class Meta: |
| 1016 | model = Service |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1017 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1018 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1019 | class ServiceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1020 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1021 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1022 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1023 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1024 | def getHumanReadableName(self, obj):
|
| 1025 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1026 | def getValidators(self, obj):
|
| 1027 | try: |
| 1028 | return obj.getValidators() |
| 1029 | except: |
| 1030 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1031 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1032 | model = Service |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1033 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1034 | |
| 1035 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1036 | |
| 1037 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1038 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1039 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1040 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1041 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1042 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1043 | def getHumanReadableName(self, obj):
|
| 1044 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1045 | def getValidators(self, obj): |
| 1046 | try: |
| 1047 | return obj.getValidators() |
| 1048 | except: |
| 1049 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1050 | class Meta: |
| 1051 | model = ServiceClass |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1052 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1053 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1054 | class ServiceClassIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1055 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1056 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1057 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1058 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1059 | def getHumanReadableName(self, obj):
|
| 1060 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1061 | def getValidators(self, obj):
|
| 1062 | try: |
| 1063 | return obj.getValidators() |
| 1064 | except: |
| 1065 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1066 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1067 | model = ServiceClass |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1068 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1069 | |
| 1070 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1071 | |
| 1072 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1073 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1074 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1075 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1076 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1077 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1078 | def getHumanReadableName(self, obj):
|
| 1079 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1080 | def getValidators(self, obj): |
| 1081 | try: |
| 1082 | return obj.getValidators() |
| 1083 | except: |
| 1084 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1085 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1086 | model = PlanetStack |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1087 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1088 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1089 | class PlanetStackIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1090 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1091 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1092 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1093 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1094 | def getHumanReadableName(self, obj):
|
| 1095 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1096 | def getValidators(self, obj):
|
| 1097 | try: |
| 1098 | return obj.getValidators() |
| 1099 | except: |
| 1100 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1101 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1102 | model = PlanetStack |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1103 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1104 | |
| 1105 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1106 | |
| 1107 | |
| 1108 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1109 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1110 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1111 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1112 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1113 | def getHumanReadableName(self, obj):
|
| 1114 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1115 | def getValidators(self, obj): |
| 1116 | try: |
| 1117 | return obj.getValidators() |
| 1118 | except: |
| 1119 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1120 | class Meta: |
| 1121 | model = Charge |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1122 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1123 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1124 | class ChargeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1125 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1126 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1127 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1128 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1129 | def getHumanReadableName(self, obj):
|
| 1130 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1131 | def getValidators(self, obj):
|
| 1132 | try: |
| 1133 | return obj.getValidators() |
| 1134 | except: |
| 1135 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1136 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1137 | model = Charge |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1138 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1139 | |
| 1140 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1141 | |
| 1142 | |
| 1143 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1144 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1145 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1146 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1147 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1148 | def getHumanReadableName(self, obj):
|
| 1149 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1150 | def getValidators(self, obj): |
| 1151 | try: |
| 1152 | return obj.getValidators() |
| 1153 | except: |
| 1154 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1155 | class Meta: |
| 1156 | model = Role |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1157 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1158 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1159 | class RoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1160 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1161 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1162 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1163 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1164 | def getHumanReadableName(self, obj):
|
| 1165 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1166 | def getValidators(self, obj):
|
| 1167 | try: |
| 1168 | return obj.getValidators() |
| 1169 | except: |
| 1170 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1171 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1172 | model = Role |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1173 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1174 | |
| 1175 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1176 | |
| 1177 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1178 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1179 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1180 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1181 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1182 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1183 | def getHumanReadableName(self, obj):
|
| 1184 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1185 | def getValidators(self, obj): |
| 1186 | try: |
| 1187 | return obj.getValidators() |
| 1188 | except: |
| 1189 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1190 | class Meta: |
| 1191 | model = UsableObject |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1192 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1193 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1194 | class UsableObjectIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1195 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1196 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1197 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1198 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1199 | def getHumanReadableName(self, obj):
|
| 1200 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1201 | def getValidators(self, obj):
|
| 1202 | try: |
| 1203 | return obj.getValidators() |
| 1204 | except: |
| 1205 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1206 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1207 | model = UsableObject |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1208 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1209 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1210 | |
| 1211 | |
| 1212 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1213 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1214 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1215 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1216 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1217 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1218 | def getHumanReadableName(self, obj):
|
| 1219 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1220 | def getValidators(self, obj): |
| 1221 | try: |
| 1222 | return obj.getValidators() |
| 1223 | except: |
| 1224 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1225 | class Meta: |
| 1226 | model = SiteRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1227 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1228 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1229 | class SiteRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1230 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1231 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1232 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1233 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1234 | def getHumanReadableName(self, obj):
|
| 1235 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1236 | def getValidators(self, obj):
|
| 1237 | try: |
| 1238 | return obj.getValidators() |
| 1239 | except: |
| 1240 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1241 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1242 | model = SiteRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1243 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1244 | |
| 1245 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1246 | |
| 1247 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1248 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1249 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1250 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1251 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1252 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1253 | def getHumanReadableName(self, obj):
|
| 1254 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1255 | def getValidators(self, obj): |
| 1256 | try: |
| 1257 | return obj.getValidators() |
| 1258 | except: |
| 1259 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1260 | class Meta: |
| 1261 | model = SliceCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1262 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1263 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1264 | class SliceCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1265 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1266 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1267 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1268 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1269 | def getHumanReadableName(self, obj):
|
| 1270 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1271 | def getValidators(self, obj):
|
| 1272 | try: |
| 1273 | return obj.getValidators() |
| 1274 | except: |
| 1275 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1276 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1277 | model = SliceCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1278 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1279 | |
| 1280 | |
| 1281 | |
| 1282 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1283 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1284 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1285 | |
| 1286 | |
| 1287 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1288 | |
| 1289 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1290 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1291 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1292 | def getHumanReadableName(self, obj):
|
| 1293 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1294 | def getValidators(self, obj): |
| 1295 | try: |
| 1296 | return obj.getValidators() |
| 1297 | except: |
| 1298 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1299 | class Meta: |
| 1300 | model = Sliver |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1301 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1302 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1303 | class SliverIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1304 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1305 | |
| 1306 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1307 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1308 | |
| 1309 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1310 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1311 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1312 | def getHumanReadableName(self, obj):
|
| 1313 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1314 | def getValidators(self, obj):
|
| 1315 | try: |
| 1316 | return obj.getValidators() |
| 1317 | except: |
| 1318 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1319 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1320 | model = Sliver |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1321 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1322 | |
| 1323 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1324 | |
| 1325 | |
| 1326 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1327 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1328 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1329 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1330 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1331 | def getHumanReadableName(self, obj):
|
| 1332 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1333 | def getValidators(self, obj): |
| 1334 | try: |
| 1335 | return obj.getValidators() |
| 1336 | except: |
| 1337 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1338 | class Meta: |
| 1339 | model = Node |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1340 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1341 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1342 | class NodeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1343 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1344 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1345 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1346 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1347 | def getHumanReadableName(self, obj):
|
| 1348 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1349 | def getValidators(self, obj):
|
| 1350 | try: |
| 1351 | return obj.getValidators() |
| 1352 | except: |
| 1353 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1354 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1355 | model = Node |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1356 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1357 | |
| 1358 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1359 | |
| 1360 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1361 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1362 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1363 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1364 | |
| 1365 | controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail') |
| 1366 | |
| 1367 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1368 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1369 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1370 | def getHumanReadableName(self, obj):
|
| 1371 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1372 | def getValidators(self, obj): |
| 1373 | try: |
| 1374 | return obj.getValidators() |
| 1375 | except: |
| 1376 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1377 | class Meta: |
| 1378 | model = DashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1379 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1380 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1381 | class DashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1382 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1383 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1384 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1385 | controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1386 | |
| 1387 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1388 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1389 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1390 | def getHumanReadableName(self, obj):
|
| 1391 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1392 | def getValidators(self, obj):
|
| 1393 | try: |
| 1394 | return obj.getValidators() |
| 1395 | except: |
| 1396 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1397 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1398 | model = DashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1399 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1400 | |
| 1401 | |
| 1402 | |
| 1403 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1404 | class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer): |
| 1405 | id = IdField() |
| 1406 | |
| 1407 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1408 | validators = serializers.SerializerMethodField("getValidators") |
| 1409 | def getHumanReadableName(self, obj):
|
| 1410 | return str(obj) |
| 1411 | def getValidators(self, obj): |
| 1412 | try: |
| 1413 | return obj.getValidators() |
| 1414 | except: |
| 1415 | return None |
| 1416 | class Meta: |
| 1417 | model = ControllerNetwork |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1418 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1419 | |
| 1420 | class ControllerNetworkIdSerializer(XOSModelSerializer): |
| 1421 | id = IdField() |
| 1422 | |
| 1423 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1424 | validators = serializers.SerializerMethodField("getValidators") |
| 1425 | def getHumanReadableName(self, obj):
|
| 1426 | return str(obj)
|
| 1427 | def getValidators(self, obj):
|
| 1428 | try: |
| 1429 | return obj.getValidators() |
| 1430 | except: |
| 1431 | return None
|
| 1432 | class Meta:
|
| 1433 | model = ControllerNetwork |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1434 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1435 | |
| 1436 | |
| 1437 | |
| 1438 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1439 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1440 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1441 | |
| 1442 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1443 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1444 | def getHumanReadableName(self, obj):
|
| 1445 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1446 | def getValidators(self, obj): |
| 1447 | try: |
| 1448 | return obj.getValidators() |
| 1449 | except: |
| 1450 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1451 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1452 | model = ImageDeployments |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1453 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1454 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1455 | class ImageDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1456 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1457 | |
| 1458 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1459 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1460 | def getHumanReadableName(self, obj):
|
| 1461 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1462 | def getValidators(self, obj):
|
| 1463 | try: |
| 1464 | return obj.getValidators() |
| 1465 | except: |
| 1466 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1467 | class Meta:
|
| 1468 | model = ImageDeployments |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1469 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1470 | |
| 1471 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1472 | |
| 1473 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1474 | class ControllerUserSerializer(serializers.HyperlinkedModelSerializer): |
| 1475 | id = IdField() |
| 1476 | |
| 1477 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1478 | validators = serializers.SerializerMethodField("getValidators") |
| 1479 | def getHumanReadableName(self, obj):
|
| 1480 | return str(obj) |
| 1481 | def getValidators(self, obj): |
| 1482 | try: |
| 1483 | return obj.getValidators() |
| 1484 | except: |
| 1485 | return None |
| 1486 | class Meta: |
| 1487 | model = ControllerUser |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1488 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1489 | |
| 1490 | class ControllerUserIdSerializer(XOSModelSerializer): |
| 1491 | id = IdField() |
| 1492 | |
| 1493 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1494 | validators = serializers.SerializerMethodField("getValidators") |
| 1495 | def getHumanReadableName(self, obj):
|
| 1496 | return str(obj)
|
| 1497 | def getValidators(self, obj):
|
| 1498 | try: |
| 1499 | return obj.getValidators() |
| 1500 | except: |
| 1501 | return None
|
| 1502 | class Meta:
|
| 1503 | model = ControllerUser |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1504 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1505 | |
| 1506 | |
| 1507 | |
| 1508 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1509 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1510 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1511 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1512 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1513 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1514 | def getHumanReadableName(self, obj):
|
| 1515 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1516 | def getValidators(self, obj): |
| 1517 | try: |
| 1518 | return obj.getValidators() |
| 1519 | except: |
| 1520 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1521 | class Meta: |
| 1522 | model = ReservedResource |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1523 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1524 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1525 | class ReservedResourceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1526 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1527 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1528 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1529 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1530 | def getHumanReadableName(self, obj):
|
| 1531 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1532 | def getValidators(self, obj):
|
| 1533 | try: |
| 1534 | return obj.getValidators() |
| 1535 | except: |
| 1536 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1537 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1538 | model = ReservedResource |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1539 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1540 | |
| 1541 | |
| 1542 | |
| 1543 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1544 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1545 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1546 | |
| 1547 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1548 | validators = serializers.SerializerMethodField("getValidators") |
| 1549 | def getHumanReadableName(self, obj):
|
| 1550 | return str(obj) |
| 1551 | def getValidators(self, obj): |
| 1552 | try: |
| 1553 | return obj.getValidators() |
| 1554 | except: |
| 1555 | return None |
| 1556 | class Meta: |
| 1557 | model = Payment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1558 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1559 | |
| 1560 | class PaymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1561 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1562 | |
| 1563 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1564 | validators = serializers.SerializerMethodField("getValidators") |
| 1565 | def getHumanReadableName(self, obj):
|
| 1566 | return str(obj)
|
| 1567 | def getValidators(self, obj):
|
| 1568 | try: |
| 1569 | return obj.getValidators() |
| 1570 | except: |
| 1571 | return None
|
| 1572 | class Meta:
|
| 1573 | model = Payment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1574 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1575 | |
| 1576 | |
| 1577 | |
| 1578 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1579 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1580 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1581 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1582 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1583 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1584 | def getHumanReadableName(self, obj):
|
| 1585 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1586 | def getValidators(self, obj): |
| 1587 | try: |
| 1588 | return obj.getValidators() |
| 1589 | except: |
| 1590 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1591 | class Meta: |
| 1592 | model = NetworkSlice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1593 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1594 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1595 | class NetworkSliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1596 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1597 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1598 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1599 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1600 | def getHumanReadableName(self, obj):
|
| 1601 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1602 | def getValidators(self, obj):
|
| 1603 | try: |
| 1604 | return obj.getValidators() |
| 1605 | except: |
| 1606 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1607 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1608 | model = NetworkSlice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1609 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1610 | |
| 1611 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1612 | |
| 1613 | |
| 1614 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1615 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1616 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1617 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1618 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1619 | def getHumanReadableName(self, obj):
|
| 1620 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1621 | def getValidators(self, obj): |
| 1622 | try: |
| 1623 | return obj.getValidators() |
| 1624 | except: |
| 1625 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1626 | class Meta: |
| 1627 | model = UserDashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1628 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1629 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1630 | class UserDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1631 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1632 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1633 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1634 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1635 | def getHumanReadableName(self, obj):
|
| 1636 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1637 | def getValidators(self, obj):
|
| 1638 | try: |
| 1639 | return obj.getValidators() |
| 1640 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1641 | return None
|
| 1642 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1643 | model = UserDashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1644 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1645 | |
| 1646 | |
| 1647 | |
| 1648 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1649 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1650 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1651 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1652 | |
| 1653 | dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail') |
| 1654 | |
| 1655 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1656 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1657 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1658 | def getHumanReadableName(self, obj):
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1659 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1660 | def getValidators(self, obj): |
| 1661 | try: |
| 1662 | return obj.getValidators() |
| 1663 | except: |
| 1664 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1665 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1666 | model = Controller |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1667 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1668 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1669 | class ControllerIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1670 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1671 | |
| 1672 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1673 | dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1674 | |
| 1675 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1676 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1677 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1678 | def getHumanReadableName(self, obj):
|
| 1679 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1680 | def getValidators(self, obj):
|
| 1681 | try: |
| 1682 | return obj.getValidators() |
| 1683 | except: |
| 1684 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1685 | class Meta:
|
| 1686 | model = Controller |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1687 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1688 | |
| 1689 | |
| 1690 | |
| 1691 | |
| 1692 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1693 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1694 | |
| 1695 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1696 | validators = serializers.SerializerMethodField("getValidators") |
| 1697 | def getHumanReadableName(self, obj):
|
| 1698 | return str(obj) |
| 1699 | def getValidators(self, obj): |
| 1700 | try: |
| 1701 | return obj.getValidators() |
| 1702 | except: |
| 1703 | return None |
| 1704 | class Meta: |
| 1705 | model = PlanetStackPrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1706 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1707 | |
| 1708 | class PlanetStackPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1709 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1710 | |
| 1711 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1712 | validators = serializers.SerializerMethodField("getValidators") |
| 1713 | def getHumanReadableName(self, obj):
|
| 1714 | return str(obj)
|
| 1715 | def getValidators(self, obj):
|
| 1716 | try: |
| 1717 | return obj.getValidators() |
| 1718 | except: |
| 1719 | return None
|
| 1720 | class Meta:
|
| 1721 | model = PlanetStackPrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1722 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1723 | |
| 1724 | |
| 1725 | |
| 1726 | |
| 1727 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1728 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1729 | |
| 1730 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1731 | validators = serializers.SerializerMethodField("getValidators") |
| 1732 | def getHumanReadableName(self, obj):
|
| 1733 | return str(obj) |
| 1734 | def getValidators(self, obj): |
| 1735 | try: |
| 1736 | return obj.getValidators() |
| 1737 | except: |
| 1738 | return None |
| 1739 | class Meta: |
| 1740 | model = User |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1741 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1742 | |
| 1743 | class UserIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1744 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1745 | |
| 1746 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1747 | validators = serializers.SerializerMethodField("getValidators") |
| 1748 | def getHumanReadableName(self, obj):
|
| 1749 | return str(obj)
|
| 1750 | def getValidators(self, obj):
|
| 1751 | try: |
| 1752 | return obj.getValidators() |
| 1753 | except: |
| 1754 | return None
|
| 1755 | class Meta:
|
| 1756 | model = User |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1757 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1758 | |
| 1759 | |
| 1760 | |
| 1761 | |
| 1762 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1763 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1764 | |
| 1765 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1766 | images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail') |
| 1767 | |
| 1768 | |
| 1769 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1770 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1771 | |
| 1772 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1773 | |
| 1774 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1775 | |
| 1776 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1777 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1778 | validators = serializers.SerializerMethodField("getValidators") |
| 1779 | def getHumanReadableName(self, obj):
|
| 1780 | return str(obj) |
| 1781 | def getValidators(self, obj): |
| 1782 | try: |
| 1783 | return obj.getValidators() |
| 1784 | except: |
| 1785 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1786 | class Meta: |
| 1787 | model = Deployment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1788 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1789 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1790 | class DeploymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1791 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1792 | |
| 1793 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1794 | images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all()) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1795 | |
| 1796 | |
| 1797 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1798 | sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1799 | |
| 1800 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1801 | |
| 1802 | flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all()) |
| 1803 | |
| 1804 | |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1805 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1806 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1807 | def getHumanReadableName(self, obj):
|
| 1808 | return str(obj)
|
| 1809 | def getValidators(self, obj):
|
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1810 | try: |
| 1811 | return obj.getValidators() |
| 1812 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1813 | return None
|
| 1814 | class Meta:
|
| 1815 | model = Deployment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1816 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1817 | |
| 1818 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1819 | |
| 1820 | |
| 1821 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1822 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1823 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1824 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1825 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1826 | def getHumanReadableName(self, obj):
|
| 1827 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1828 | def getValidators(self, obj): |
| 1829 | try: |
| 1830 | return obj.getValidators() |
| 1831 | except: |
| 1832 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1833 | class Meta: |
| 1834 | model = Reservation |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1835 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1836 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1837 | class ReservationIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1838 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1839 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1840 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1841 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1842 | def getHumanReadableName(self, obj):
|
| 1843 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1844 | def getValidators(self, obj):
|
| 1845 | try: |
| 1846 | return obj.getValidators() |
| 1847 | except: |
| 1848 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1849 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1850 | model = Reservation |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1851 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1852 | |
| 1853 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1854 | |
| 1855 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1856 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1857 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1858 | |
| 1859 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1860 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1861 | def getHumanReadableName(self, obj):
|
| 1862 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1863 | def getValidators(self, obj): |
| 1864 | try: |
| 1865 | return obj.getValidators() |
| 1866 | except: |
| 1867 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1868 | class Meta: |
| 1869 | model = SitePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1870 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1871 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1872 | class SitePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1873 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1874 | |
| 1875 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1876 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1877 | def getHumanReadableName(self, obj):
|
| 1878 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1879 | def getValidators(self, obj):
|
| 1880 | try: |
| 1881 | return obj.getValidators() |
| 1882 | except: |
| 1883 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1884 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1885 | model = SitePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1886 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1887 | |
| 1888 | |
| 1889 | |
| 1890 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1891 | class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1892 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1893 | |
| 1894 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1895 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1896 | def getHumanReadableName(self, obj):
|
| 1897 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1898 | def getValidators(self, obj): |
| 1899 | try: |
| 1900 | return obj.getValidators() |
| 1901 | except: |
| 1902 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1903 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1904 | model = ControllerSlice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1905 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1906 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1907 | class ControllerSliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1908 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1909 | |
| 1910 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1911 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1912 | def getHumanReadableName(self, obj):
|
| 1913 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1914 | def getValidators(self, obj):
|
| 1915 | try: |
| 1916 | return obj.getValidators() |
| 1917 | except: |
| 1918 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1919 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1920 | model = ControllerSlice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1921 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1922 | |
| 1923 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1924 | |
| 1925 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1926 | class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1927 | id = IdField() |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1928 | |
| 1929 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1930 | validators = serializers.SerializerMethodField("getValidators") |
| 1931 | def getHumanReadableName(self, obj):
|
| 1932 | return str(obj) |
| 1933 | def getValidators(self, obj): |
| 1934 | try: |
| 1935 | return obj.getValidators() |
| 1936 | except: |
| 1937 | return None |
| 1938 | class Meta: |
| 1939 | model = ControllerDashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1940 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1941 | |
| 1942 | class ControllerDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1943 | id = IdField() |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1944 | |
| 1945 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1946 | validators = serializers.SerializerMethodField("getValidators") |
| 1947 | def getHumanReadableName(self, obj):
|
| 1948 | return str(obj)
|
| 1949 | def getValidators(self, obj):
|
| 1950 | try: |
| 1951 | return obj.getValidators() |
| 1952 | except: |
| 1953 | return None
|
| 1954 | class Meta:
|
| 1955 | model = ControllerDashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1956 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1957 | |
| 1958 | |
| 1959 | |
| 1960 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1961 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1962 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1963 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1964 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1965 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1966 | def getHumanReadableName(self, obj):
|
| 1967 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1968 | def getValidators(self, obj): |
| 1969 | try: |
| 1970 | return obj.getValidators() |
| 1971 | except: |
| 1972 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1973 | class Meta: |
| 1974 | model = Account |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1975 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1976 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1977 | class AccountIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1978 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1979 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1980 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1981 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1982 | def getHumanReadableName(self, obj):
|
| 1983 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1984 | def getValidators(self, obj):
|
| 1985 | try: |
| 1986 | return obj.getValidators() |
| 1987 | except: |
| 1988 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1989 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1990 | model = Account |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1991 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1992 | |
| 1993 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1994 | |
| 1995 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1996 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1997 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1998 | |
| 1999 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2000 | validators = serializers.SerializerMethodField("getValidators") |
| 2001 | def getHumanReadableName(self, obj):
|
| 2002 | return str(obj) |
| 2003 | def getValidators(self, obj): |
| 2004 | try: |
| 2005 | return obj.getValidators() |
| 2006 | except: |
| 2007 | return None |
| 2008 | class Meta: |
| 2009 | model = ControllerRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2010 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2011 | |
| 2012 | class ControllerRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2013 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2014 | |
| 2015 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2016 | validators = serializers.SerializerMethodField("getValidators") |
| 2017 | def getHumanReadableName(self, obj):
|
| 2018 | return str(obj)
|
| 2019 | def getValidators(self, obj):
|
| 2020 | try: |
| 2021 | return obj.getValidators() |
| 2022 | except: |
| 2023 | return None
|
| 2024 | class Meta:
|
| 2025 | model = ControllerRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2026 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2027 | |
| 2028 | |
| 2029 | |
| 2030 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2031 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2032 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2033 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2034 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2035 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2036 | def getHumanReadableName(self, obj):
|
| 2037 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2038 | def getValidators(self, obj): |
| 2039 | try: |
| 2040 | return obj.getValidators() |
| 2041 | except: |
| 2042 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2043 | class Meta: |
| 2044 | model = NetworkParameterType |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2045 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2046 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2047 | class NetworkParameterTypeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2048 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2049 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2050 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2051 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2052 | def getHumanReadableName(self, obj):
|
| 2053 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2054 | def getValidators(self, obj):
|
| 2055 | try: |
| 2056 | return obj.getValidators() |
| 2057 | except: |
| 2058 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2059 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2060 | model = NetworkParameterType |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2061 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2062 | |
| 2063 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2064 | |
| 2065 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2066 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2067 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2068 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2069 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2070 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2071 | def getHumanReadableName(self, obj):
|
| 2072 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2073 | def getValidators(self, obj): |
| 2074 | try: |
| 2075 | return obj.getValidators() |
| 2076 | except: |
| 2077 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2078 | class Meta: |
| 2079 | model = SiteCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2080 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2081 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2082 | class SiteCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2083 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2084 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2085 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2086 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2087 | def getHumanReadableName(self, obj):
|
| 2088 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2089 | def getValidators(self, obj):
|
| 2090 | try: |
| 2091 | return obj.getValidators() |
| 2092 | except: |
| 2093 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2094 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2095 | model = SiteCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2096 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2097 | |
| 2098 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2099 | |
| 2100 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2101 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2102 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2103 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2104 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2105 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2106 | def getHumanReadableName(self, obj):
|
| 2107 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2108 | def getValidators(self, obj): |
| 2109 | try: |
| 2110 | return obj.getValidators() |
| 2111 | except: |
| 2112 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2113 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2114 | model = DeploymentPrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2115 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2116 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2117 | class DeploymentPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2118 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2119 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2120 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2121 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2122 | def getHumanReadableName(self, obj):
|
| 2123 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2124 | def getValidators(self, obj):
|
| 2125 | try: |
| 2126 | return obj.getValidators() |
| 2127 | except: |
| 2128 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2129 | class Meta:
|
| 2130 | model = DeploymentPrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2131 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2132 | |
| 2133 | |
| 2134 | |
| 2135 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2136 | class ControllerSlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2137 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2138 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2139 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2140 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2141 | def getHumanReadableName(self, obj):
|
| 2142 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2143 | def getValidators(self, obj): |
| 2144 | try: |
| 2145 | return obj.getValidators() |
| 2146 | except: |
| 2147 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2148 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2149 | model = ControllerSlicePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2150 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2151 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2152 | class ControllerSlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2153 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2154 | |
| 2155 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2156 | validators = serializers.SerializerMethodField("getValidators") |
| 2157 | def getHumanReadableName(self, obj):
|
| 2158 | return str(obj)
|
| 2159 | def getValidators(self, obj):
|
| 2160 | try: |
| 2161 | return obj.getValidators() |
| 2162 | except: |
| 2163 | return None
|
| 2164 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2165 | model = ControllerSlicePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2166 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2167 | |
| 2168 | |
| 2169 | |
| 2170 | |
| 2171 | class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer): |
| 2172 | id = IdField() |
| 2173 | |
| 2174 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2175 | validators = serializers.SerializerMethodField("getValidators") |
| 2176 | def getHumanReadableName(self, obj):
|
| 2177 | return str(obj) |
| 2178 | def getValidators(self, obj): |
| 2179 | try: |
| 2180 | return obj.getValidators() |
| 2181 | except: |
| 2182 | return None |
| 2183 | class Meta: |
| 2184 | model = SiteDeployment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2185 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2186 | |
| 2187 | class SiteDeploymentIdSerializer(XOSModelSerializer): |
| 2188 | id = IdField() |
| 2189 | |
| 2190 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2191 | validators = serializers.SerializerMethodField("getValidators") |
| 2192 | def getHumanReadableName(self, obj):
|
| 2193 | return str(obj)
|
| 2194 | def getValidators(self, obj):
|
| 2195 | try: |
| 2196 | return obj.getValidators() |
| 2197 | except: |
| 2198 | return None
|
| 2199 | class Meta:
|
| 2200 | model = SiteDeployment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2201 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2202 | |
| 2203 | |
| 2204 | |
| 2205 | |
| 2206 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2207 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2208 | |
| 2209 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2210 | validators = serializers.SerializerMethodField("getValidators") |
| 2211 | def getHumanReadableName(self, obj):
|
| 2212 | return str(obj) |
| 2213 | def getValidators(self, obj): |
| 2214 | try: |
| 2215 | return obj.getValidators() |
| 2216 | except: |
| 2217 | return None |
| 2218 | class Meta: |
| 2219 | model = DeploymentRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2220 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2221 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2222 | class DeploymentRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2223 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2224 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2225 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2226 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2227 | def getHumanReadableName(self, obj):
|
| 2228 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2229 | def getValidators(self, obj):
|
| 2230 | try: |
| 2231 | return obj.getValidators() |
| 2232 | except: |
| 2233 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2234 | class Meta:
|
| 2235 | model = DeploymentRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2236 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2237 | |
| 2238 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2239 | |
| 2240 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2241 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2242 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2243 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2244 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2245 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2246 | def getHumanReadableName(self, obj):
|
| 2247 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2248 | def getValidators(self, obj): |
| 2249 | try: |
| 2250 | return obj.getValidators() |
| 2251 | except: |
| 2252 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2253 | class Meta: |
| 2254 | model = UserCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2255 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2256 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2257 | class UserCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2258 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2259 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2260 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2261 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2262 | def getHumanReadableName(self, obj):
|
| 2263 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2264 | def getValidators(self, obj):
|
| 2265 | try: |
| 2266 | return obj.getValidators() |
| 2267 | except: |
| 2268 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2269 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2270 | model = UserCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2271 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2272 | |
| 2273 | |
| 2274 | |
| 2275 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2276 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2277 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2278 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2279 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2280 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2281 | def getHumanReadableName(self, obj):
|
| 2282 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2283 | def getValidators(self, obj): |
| 2284 | try: |
| 2285 | return obj.getValidators() |
| 2286 | except: |
| 2287 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2288 | class Meta: |
| 2289 | model = SliceTag |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2290 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2291 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2292 | class SliceTagIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2293 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2294 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2295 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2296 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2297 | def getHumanReadableName(self, obj):
|
| 2298 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2299 | def getValidators(self, obj):
|
| 2300 | try: |
| 2301 | return obj.getValidators() |
| 2302 | except: |
| 2303 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2304 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2305 | model = SliceTag |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2306 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2307 | |
| 2308 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2309 | |
| 2310 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2311 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2312 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2313 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2314 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2315 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2316 | def getHumanReadableName(self, obj):
|
| 2317 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2318 | def getValidators(self, obj): |
| 2319 | try: |
| 2320 | return obj.getValidators() |
| 2321 | except: |
| 2322 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2323 | class Meta: |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2324 | model = NetworkTemplate |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2325 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2326 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2327 | class NetworkTemplateIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2328 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2329 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2330 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2331 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2332 | def getHumanReadableName(self, obj):
|
| 2333 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2334 | def getValidators(self, obj):
|
| 2335 | try: |
| 2336 | return obj.getValidators() |
| 2337 | except: |
| 2338 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2339 | class Meta:
|
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2340 | model = NetworkTemplate |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2341 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2342 | |
| 2343 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2344 | |
| 2345 | |
| 2346 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2347 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2348 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2349 | |
| 2350 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2351 | |
| 2352 | |
| 2353 | |
| 2354 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2355 | |
| 2356 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2357 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2358 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2359 | def getHumanReadableName(self, obj):
|
| 2360 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2361 | def getValidators(self, obj): |
| 2362 | try: |
| 2363 | return obj.getValidators() |
| 2364 | except: |
| 2365 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2366 | class Meta: |
| 2367 | model = Router |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2368 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2369 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2370 | class RouterIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2371 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2372 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2373 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2374 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2375 | |
| 2376 | |
| 2377 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2378 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2379 | |
| 2380 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2381 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2382 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2383 | def getHumanReadableName(self, obj):
|
| 2384 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2385 | def getValidators(self, obj):
|
| 2386 | try: |
| 2387 | return obj.getValidators() |
| 2388 | except: |
| 2389 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2390 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2391 | model = Router |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2392 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2393 | |
| 2394 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2395 | |
| 2396 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2397 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2398 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2399 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2400 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2401 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2402 | def getHumanReadableName(self, obj):
|
| 2403 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2404 | def getValidators(self, obj): |
| 2405 | try: |
| 2406 | return obj.getValidators() |
| 2407 | except: |
| 2408 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2409 | class Meta: |
| 2410 | model = ServiceResource |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2411 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2412 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2413 | class ServiceResourceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2414 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2415 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2416 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2417 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2418 | def getHumanReadableName(self, obj):
|
| 2419 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2420 | def getValidators(self, obj):
|
| 2421 | try: |
| 2422 | return obj.getValidators() |
| 2423 | except: |
| 2424 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2425 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2426 | model = ServiceResource |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2427 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2428 | |
| 2429 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2430 | |
| 2431 | |
| 2432 | serializerLookUp = { |
| 2433 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2434 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2435 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2436 | ControllerImages: ControllerImagesSerializer, |
| 2437 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2438 | ControllerSitePrivilege: ControllerSitePrivilegeSerializer, |
| 2439 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2440 | Image: ImageSerializer, |
| 2441 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2442 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2443 | |
| 2444 | Site: SiteSerializer, |
| 2445 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2446 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2447 | |
| 2448 | Tag: TagSerializer, |
| 2449 | |
| 2450 | Invoice: InvoiceSerializer, |
| 2451 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2452 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2453 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2454 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2455 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2456 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2457 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2458 | Flavor: FlavorSerializer, |
| 2459 | |
| 2460 | ControllerSite: ControllerSiteSerializer, |
| 2461 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2462 | Project: ProjectSerializer, |
| 2463 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2464 | Slice: SliceSerializer, |
| 2465 | |
| 2466 | Network: NetworkSerializer, |
| 2467 | |
| 2468 | Service: ServiceSerializer, |
| 2469 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2470 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2471 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2472 | PlanetStack: PlanetStackSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2473 | |
| 2474 | Charge: ChargeSerializer, |
| 2475 | |
| 2476 | Role: RoleSerializer, |
| 2477 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2478 | UsableObject: UsableObjectSerializer, |
| 2479 | |
| 2480 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2481 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2482 | SliceCredential: SliceCredentialSerializer, |
| 2483 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2484 | Sliver: SliverSerializer, |
| 2485 | |
| 2486 | Node: NodeSerializer, |
| 2487 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2488 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2489 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2490 | ControllerNetwork: ControllerNetworkSerializer, |
| 2491 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2492 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2493 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2494 | ControllerUser: ControllerUserSerializer, |
| 2495 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2496 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2497 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2498 | Payment: PaymentSerializer, |
| 2499 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2500 | NetworkSlice: NetworkSliceSerializer, |
| 2501 | |
| 2502 | UserDashboardView: UserDashboardViewSerializer, |
| 2503 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2504 | Controller: ControllerSerializer, |
| 2505 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2506 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2507 | |
| 2508 | User: UserSerializer, |
| 2509 | |
| 2510 | Deployment: DeploymentSerializer, |
| 2511 | |
| 2512 | Reservation: ReservationSerializer, |
| 2513 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2514 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2515 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2516 | ControllerSlice: ControllerSliceSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2517 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2518 | ControllerDashboardView: ControllerDashboardViewSerializer, |
| 2519 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2520 | Account: AccountSerializer, |
| 2521 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2522 | ControllerRole: ControllerRoleSerializer, |
| 2523 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2524 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2525 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2526 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2527 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2528 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2529 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2530 | ControllerSlicePrivilege: ControllerSlicePrivilegeSerializer, |
| 2531 | |
| 2532 | SiteDeployment: SiteDeploymentSerializer, |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2533 | |
| 2534 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2535 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2536 | UserCredential: UserCredentialSerializer, |
| 2537 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2538 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2539 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2540 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2541 | |
| 2542 | Router: RouterSerializer, |
| 2543 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2544 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2545 | |
| 2546 | None: None, |
| 2547 | } |
| 2548 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2549 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2550 | |
| 2551 | # To handle fine-grained field permissions, we have to check can_update |
| 2552 | # the object has been updated but before it has been saved. |
| 2553 | |
| 2554 | def update(self, request, *args, **kwargs):
|
| 2555 | partial = kwargs.pop('partial', False)
|
| 2556 | self.object = self.get_object_or_none()
|
| 2557 |
|
| 2558 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2559 | files=request.FILES, partial=partial)
|
| 2560 |
|
| 2561 | if not serializer.is_valid():
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2562 | response = {"error": "validation",
|
| 2563 | "specific_error": "not serializer.is_valid()",
|
| 2564 | "reasons": serializer.errors}
|
| 2565 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2566 |
|
| 2567 | try:
|
| 2568 | self.pre_save(serializer.object)
|
| 2569 | except ValidationError as err:
|
| 2570 | # full_clean on model instance may be called in pre_save,
|
| 2571 | # so we have to handle eventual errors.
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2572 | response = {"error": "validation",
|
| 2573 | "specific_error": "ValidationError in pre_save",
|
| 2574 | "reasons": err.message_dict}
|
| 2575 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2576 |
|
| 2577 | if serializer.object is not None:
|
| 2578 | if not serializer.object.can_update(request.user):
|
| 2579 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2580 |
|
| 2581 | if self.object is None:
|
| 2582 | self.object = serializer.save(force_insert=True)
|
| 2583 | self.post_save(self.object, created=True)
|
| 2584 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2585 |
|
| 2586 | self.object = serializer.save(force_update=True)
|
| 2587 | self.post_save(self.object, created=False)
|
| 2588 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2589 | |
| 2590 | def destroy(self, request, *args, **kwargs): |
| 2591 | obj = self.get_object() |
| 2592 | if obj.can_update(request.user): |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 2593 | return super(PlanetStackRetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2594 | else: |
| 2595 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2596 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 2597 | def handle_exception(self, exc): |
| 2598 | # REST API drops the string attached to Django's PermissionDenied |
| 2599 | # exception, and replaces it with a generic "Permission Denied" |
| 2600 | if isinstance(exc, DjangoPermissionDenied): |
| 2601 | response=Response({'detail': str(exc)}, status=status.HTTP_403_FORBIDDEN) |
| 2602 | response.exception=True |
| 2603 | return response |
| 2604 | else: |
| 2605 | return super(PlanetStackRetrieveUpdateDestroyAPIView, self).handle_exception(exc) |
| 2606 | |
| 2607 | class PlanetStackListCreateAPIView(generics.ListCreateAPIView): |
| 2608 | def handle_exception(self, exc): |
| 2609 | # REST API drops the string attached to Django's PermissionDenied |
| 2610 | # exception, and replaces it with a generic "Permission Denied" |
| 2611 | if isinstance(exc, DjangoPermissionDenied): |
| 2612 | response=Response({'detail': str(exc)}, status=status.HTTP_403_FORBIDDEN) |
| 2613 | response.exception=True |
| 2614 | return response |
| 2615 | else: |
| 2616 | return super(PlanetStackListCreateAPIView, self).handle_exception(exc) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2617 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2618 | # Based on core/views/*.py |
| 2619 | |
| 2620 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 2621 | class ServiceAttributeList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2622 | queryset = ServiceAttribute.objects.select_related().all() |
| 2623 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2624 | id_serializer_class = ServiceAttributeIdSerializer |
| 2625 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2626 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2627 | |
| 2628 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2629 | no_hyperlinks=False |
| 2630 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2631 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2632 | if (no_hyperlinks): |
| 2633 | return self.id_serializer_class |
| 2634 | else: |
| 2635 | return self.serializer_class |
| 2636 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2637 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2638 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2639 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2640 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2641 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2642 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2643 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2644 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2645 | response = {"error": "validation", |
| 2646 | "specific_error": "not serializer.is_valid()",
|
| 2647 | "reasons": serializer.errors}
|
| 2648 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2649 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2650 | obj.caller = request.user |
| 2651 | if obj.can_update(request.user): |
| 2652 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2653 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2654 | raise Exception("failed obj.can_update") |
| 2655 | |
| 2656 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2657 | if (ret.status_code%100 != 200): |
| 2658 | raise Exception(ret.data) |
| 2659 | |
| 2660 | return ret |
| 2661 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2662 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2663 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2664 | queryset = ServiceAttribute.objects.select_related().all() |
| 2665 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2666 | id_serializer_class = ServiceAttributeIdSerializer |
| 2667 | |
| 2668 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2669 | no_hyperlinks=False |
| 2670 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2671 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2672 | if (no_hyperlinks): |
| 2673 | return self.id_serializer_class |
| 2674 | else: |
| 2675 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2676 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2677 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2678 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2679 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2680 | return ServiceAttribute.select_by_user(self.request.user) |
| 2681 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2682 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2683 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2684 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2685 | |
| 2686 | |
| 2687 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 2688 | class ControllerImagesList(PlanetStackListCreateAPIView): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2689 | queryset = ControllerImages.objects.select_related().all() |
| 2690 | serializer_class = ControllerImagesSerializer |
| 2691 | id_serializer_class = ControllerImagesIdSerializer |
| 2692 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2693 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2694 | |
| 2695 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2696 | no_hyperlinks=False |
| 2697 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2698 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2699 | if (no_hyperlinks): |
| 2700 | return self.id_serializer_class |
| 2701 | else: |
| 2702 | return self.serializer_class |
| 2703 | |
| 2704 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2705 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2706 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2707 | return ControllerImages.select_by_user(self.request.user) |
| 2708 | |
| 2709 | def create(self, request, *args, **kwargs): |
| 2710 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2711 | if not (serializer.is_valid()): |
| 2712 | response = {"error": "validation", |
| 2713 | "specific_error": "not serializer.is_valid()",
|
| 2714 | "reasons": serializer.errors}
|
| 2715 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2716 | obj = serializer.object |
| 2717 | obj.caller = request.user |
| 2718 | if obj.can_update(request.user): |
| 2719 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2720 | else: |
| 2721 | raise Exception("failed obj.can_update") |
| 2722 | |
| 2723 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2724 | if (ret.status_code%100 != 200): |
| 2725 | raise Exception(ret.data) |
| 2726 | |
| 2727 | return ret |
| 2728 | |
| 2729 | |
| 2730 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2731 | queryset = ControllerImages.objects.select_related().all() |
| 2732 | serializer_class = ControllerImagesSerializer |
| 2733 | id_serializer_class = ControllerImagesIdSerializer |
| 2734 | |
| 2735 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2736 | no_hyperlinks=False |
| 2737 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2738 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2739 | if (no_hyperlinks): |
| 2740 | return self.id_serializer_class |
| 2741 | else: |
| 2742 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2743 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2744 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2745 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2746 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2747 | return ControllerImages.select_by_user(self.request.user) |
| 2748 | |
| 2749 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2750 | |
| 2751 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2752 | |
| 2753 | |
| 2754 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 2755 | class ControllerSitePrivilegeList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2756 | queryset = ControllerSitePrivilege.objects.select_related().all() |
| 2757 | serializer_class = ControllerSitePrivilegeSerializer |
| 2758 | id_serializer_class = ControllerSitePrivilegeIdSerializer |
| 2759 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2760 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2761 | |
| 2762 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2763 | no_hyperlinks=False |
| 2764 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2765 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2766 | if (no_hyperlinks): |
| 2767 | return self.id_serializer_class |
| 2768 | else: |
| 2769 | return self.serializer_class |
| 2770 | |
| 2771 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2772 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2773 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2774 | return ControllerSitePrivilege.select_by_user(self.request.user) |
| 2775 | |
| 2776 | def create(self, request, *args, **kwargs): |
| 2777 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2778 | if not (serializer.is_valid()): |
| 2779 | response = {"error": "validation", |
| 2780 | "specific_error": "not serializer.is_valid()",
|
| 2781 | "reasons": serializer.errors}
|
| 2782 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2783 | obj = serializer.object |
| 2784 | obj.caller = request.user |
| 2785 | if obj.can_update(request.user): |
| 2786 | return super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs) |
| 2787 | else: |
| 2788 | raise Exception("failed obj.can_update") |
| 2789 | |
| 2790 | ret = super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs) |
| 2791 | if (ret.status_code%100 != 200): |
| 2792 | raise Exception(ret.data) |
| 2793 | |
| 2794 | return ret |
| 2795 | |
| 2796 | |
| 2797 | class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2798 | queryset = ControllerSitePrivilege.objects.select_related().all() |
| 2799 | serializer_class = ControllerSitePrivilegeSerializer |
| 2800 | id_serializer_class = ControllerSitePrivilegeIdSerializer |
| 2801 | |
| 2802 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2803 | no_hyperlinks=False |
| 2804 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2805 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2806 | if (no_hyperlinks): |
| 2807 | return self.id_serializer_class |
| 2808 | else: |
| 2809 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2810 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2811 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2812 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2813 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2814 | return ControllerSitePrivilege.select_by_user(self.request.user) |
| 2815 | |
| 2816 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2817 | |
| 2818 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2819 | |
| 2820 | |
| 2821 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 2822 | class ImageList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2823 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2824 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2825 | id_serializer_class = ImageIdSerializer |
| 2826 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2827 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2828 | |
| 2829 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2830 | no_hyperlinks=False |
| 2831 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2832 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2833 | if (no_hyperlinks): |
| 2834 | return self.id_serializer_class |
| 2835 | else: |
| 2836 | return self.serializer_class |
| 2837 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2838 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2839 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2840 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2841 | return Image.select_by_user(self.request.user) |
| 2842 | |
| 2843 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2844 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2845 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2846 | response = {"error": "validation", |
| 2847 | "specific_error": "not serializer.is_valid()",
|
| 2848 | "reasons": serializer.errors}
|
| 2849 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2850 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2851 | obj.caller = request.user |
| 2852 | if obj.can_update(request.user): |
| 2853 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2854 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2855 | raise Exception("failed obj.can_update") |
| 2856 | |
| 2857 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2858 | if (ret.status_code%100 != 200): |
| 2859 | raise Exception(ret.data) |
| 2860 | |
| 2861 | return ret |
| 2862 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2863 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2864 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2865 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2866 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2867 | id_serializer_class = ImageIdSerializer |
| 2868 | |
| 2869 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2870 | no_hyperlinks=False |
| 2871 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2872 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2873 | if (no_hyperlinks): |
| 2874 | return self.id_serializer_class |
| 2875 | else: |
| 2876 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2877 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2878 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2879 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2880 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2881 | return Image.select_by_user(self.request.user) |
| 2882 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2883 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2884 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2885 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2886 | |
| 2887 | |
| 2888 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 2889 | class NetworkParameterList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2890 | queryset = NetworkParameter.objects.select_related().all() |
| 2891 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2892 | id_serializer_class = NetworkParameterIdSerializer |
| 2893 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2894 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2895 | |
| 2896 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2897 | no_hyperlinks=False |
| 2898 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2899 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2900 | if (no_hyperlinks): |
| 2901 | return self.id_serializer_class |
| 2902 | else: |
| 2903 | return self.serializer_class |
| 2904 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2905 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2906 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2907 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2908 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2909 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2910 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2911 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2912 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2913 | response = {"error": "validation", |
| 2914 | "specific_error": "not serializer.is_valid()",
|
| 2915 | "reasons": serializer.errors}
|
| 2916 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2917 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2918 | obj.caller = request.user |
| 2919 | if obj.can_update(request.user): |
| 2920 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2921 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2922 | raise Exception("failed obj.can_update") |
| 2923 | |
| 2924 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2925 | if (ret.status_code%100 != 200): |
| 2926 | raise Exception(ret.data) |
| 2927 | |
| 2928 | return ret |
| 2929 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2930 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2931 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2932 | queryset = NetworkParameter.objects.select_related().all() |
| 2933 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2934 | id_serializer_class = NetworkParameterIdSerializer |
| 2935 | |
| 2936 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2937 | no_hyperlinks=False |
| 2938 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2939 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2940 | if (no_hyperlinks): |
| 2941 | return self.id_serializer_class |
| 2942 | else: |
| 2943 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2944 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2945 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2946 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2947 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2948 | return NetworkParameter.select_by_user(self.request.user) |
| 2949 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2950 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2951 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2952 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2953 | |
| 2954 | |
| 2955 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 2956 | class SiteList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2957 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2958 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2959 | id_serializer_class = SiteIdSerializer |
| 2960 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2961 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2962 | |
| 2963 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2964 | no_hyperlinks=False |
| 2965 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2966 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2967 | if (no_hyperlinks): |
| 2968 | return self.id_serializer_class |
| 2969 | else: |
| 2970 | return self.serializer_class |
| 2971 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2972 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2973 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 2974 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2975 | return Site.select_by_user(self.request.user) |
| 2976 | |
| 2977 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2978 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2979 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2980 | response = {"error": "validation", |
| 2981 | "specific_error": "not serializer.is_valid()",
|
| 2982 | "reasons": serializer.errors}
|
| 2983 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2984 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2985 | obj.caller = request.user |
| 2986 | if obj.can_update(request.user): |
| 2987 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2988 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2989 | raise Exception("failed obj.can_update") |
| 2990 | |
| 2991 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2992 | if (ret.status_code%100 != 200): |
| 2993 | raise Exception(ret.data) |
| 2994 | |
| 2995 | return ret |
| 2996 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2997 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2998 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2999 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3000 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3001 | id_serializer_class = SiteIdSerializer |
| 3002 | |
| 3003 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3004 | no_hyperlinks=False |
| 3005 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3006 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3007 | if (no_hyperlinks): |
| 3008 | return self.id_serializer_class |
| 3009 | else: |
| 3010 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3011 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3012 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3013 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3014 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3015 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3016 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3017 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3018 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3019 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3020 | |
| 3021 | |
| 3022 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3023 | class SliceRoleList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3024 | queryset = SliceRole.objects.select_related().all() |
| 3025 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3026 | id_serializer_class = SliceRoleIdSerializer |
| 3027 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3028 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3029 | |
| 3030 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3031 | no_hyperlinks=False |
| 3032 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3033 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3034 | if (no_hyperlinks): |
| 3035 | return self.id_serializer_class |
| 3036 | else: |
| 3037 | return self.serializer_class |
| 3038 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3039 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3040 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3041 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3042 | return SliceRole.select_by_user(self.request.user) |
| 3043 | |
| 3044 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3045 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3046 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3047 | response = {"error": "validation", |
| 3048 | "specific_error": "not serializer.is_valid()",
|
| 3049 | "reasons": serializer.errors}
|
| 3050 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3051 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3052 | obj.caller = request.user |
| 3053 | if obj.can_update(request.user): |
| 3054 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 3055 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3056 | raise Exception("failed obj.can_update") |
| 3057 | |
| 3058 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 3059 | if (ret.status_code%100 != 200): |
| 3060 | raise Exception(ret.data) |
| 3061 | |
| 3062 | return ret |
| 3063 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3064 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3065 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3066 | queryset = SliceRole.objects.select_related().all() |
| 3067 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3068 | id_serializer_class = SliceRoleIdSerializer |
| 3069 | |
| 3070 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3071 | no_hyperlinks=False |
| 3072 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3073 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3074 | if (no_hyperlinks): |
| 3075 | return self.id_serializer_class |
| 3076 | else: |
| 3077 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3078 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3079 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3080 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3081 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3082 | return SliceRole.select_by_user(self.request.user) |
| 3083 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3084 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3085 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3086 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3087 | |
| 3088 | |
| 3089 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3090 | class TagList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3091 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3092 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3093 | id_serializer_class = TagIdSerializer |
| 3094 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3095 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3096 | |
| 3097 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3098 | no_hyperlinks=False |
| 3099 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3100 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3101 | if (no_hyperlinks): |
| 3102 | return self.id_serializer_class |
| 3103 | else: |
| 3104 | return self.serializer_class |
| 3105 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3106 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3107 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3108 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3109 | return Tag.select_by_user(self.request.user) |
| 3110 | |
| 3111 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3112 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3113 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3114 | response = {"error": "validation", |
| 3115 | "specific_error": "not serializer.is_valid()",
|
| 3116 | "reasons": serializer.errors}
|
| 3117 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3118 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3119 | obj.caller = request.user |
| 3120 | if obj.can_update(request.user): |
| 3121 | return super(TagList, self).create(request, *args, **kwargs) |
| 3122 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3123 | raise Exception("failed obj.can_update") |
| 3124 | |
| 3125 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 3126 | if (ret.status_code%100 != 200): |
| 3127 | raise Exception(ret.data) |
| 3128 | |
| 3129 | return ret |
| 3130 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3131 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3132 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3133 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3134 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3135 | id_serializer_class = TagIdSerializer |
| 3136 | |
| 3137 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3138 | no_hyperlinks=False |
| 3139 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3140 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3141 | if (no_hyperlinks): |
| 3142 | return self.id_serializer_class |
| 3143 | else: |
| 3144 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3145 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3146 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3147 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3148 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3149 | return Tag.select_by_user(self.request.user) |
| 3150 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3151 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3152 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3153 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3154 | |
| 3155 | |
| 3156 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3157 | class InvoiceList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3158 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3159 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3160 | id_serializer_class = InvoiceIdSerializer |
| 3161 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3162 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3163 | |
| 3164 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3165 | no_hyperlinks=False |
| 3166 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3167 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3168 | if (no_hyperlinks): |
| 3169 | return self.id_serializer_class |
| 3170 | else: |
| 3171 | return self.serializer_class |
| 3172 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3173 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3174 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3175 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3176 | return Invoice.select_by_user(self.request.user) |
| 3177 | |
| 3178 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3179 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3180 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3181 | response = {"error": "validation", |
| 3182 | "specific_error": "not serializer.is_valid()",
|
| 3183 | "reasons": serializer.errors}
|
| 3184 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3185 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3186 | obj.caller = request.user |
| 3187 | if obj.can_update(request.user): |
| 3188 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 3189 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3190 | raise Exception("failed obj.can_update") |
| 3191 | |
| 3192 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 3193 | if (ret.status_code%100 != 200): |
| 3194 | raise Exception(ret.data) |
| 3195 | |
| 3196 | return ret |
| 3197 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3198 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3199 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3200 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3201 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3202 | id_serializer_class = InvoiceIdSerializer |
| 3203 | |
| 3204 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3205 | no_hyperlinks=False |
| 3206 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3207 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3208 | if (no_hyperlinks): |
| 3209 | return self.id_serializer_class |
| 3210 | else: |
| 3211 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3212 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3213 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3214 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3215 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3216 | return Invoice.select_by_user(self.request.user) |
| 3217 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3218 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3219 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3220 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3221 | |
| 3222 | |
| 3223 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3224 | class SlicePrivilegeList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3225 | queryset = SlicePrivilege.objects.select_related().all() |
| 3226 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3227 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3228 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3229 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3230 | |
| 3231 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3232 | no_hyperlinks=False |
| 3233 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3234 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3235 | if (no_hyperlinks): |
| 3236 | return self.id_serializer_class |
| 3237 | else: |
| 3238 | return self.serializer_class |
| 3239 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3240 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3241 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3242 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3243 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3244 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3245 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3246 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3247 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3248 | response = {"error": "validation", |
| 3249 | "specific_error": "not serializer.is_valid()",
|
| 3250 | "reasons": serializer.errors}
|
| 3251 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3252 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3253 | obj.caller = request.user |
| 3254 | if obj.can_update(request.user): |
| 3255 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3256 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3257 | raise Exception("failed obj.can_update") |
| 3258 | |
| 3259 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3260 | if (ret.status_code%100 != 200): |
| 3261 | raise Exception(ret.data) |
| 3262 | |
| 3263 | return ret |
| 3264 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3265 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3266 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3267 | queryset = SlicePrivilege.objects.select_related().all() |
| 3268 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3269 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3270 | |
| 3271 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3272 | no_hyperlinks=False |
| 3273 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3274 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3275 | if (no_hyperlinks): |
| 3276 | return self.id_serializer_class |
| 3277 | else: |
| 3278 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3279 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3280 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3281 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3282 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3283 | return SlicePrivilege.select_by_user(self.request.user) |
| 3284 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3285 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3286 | |
| 3287 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3288 | |
| 3289 | |
| 3290 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3291 | class PlanetStackRoleList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3292 | queryset = PlanetStackRole.objects.select_related().all() |
| 3293 | serializer_class = PlanetStackRoleSerializer |
| 3294 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3295 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3296 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3297 | |
| 3298 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3299 | no_hyperlinks=False |
| 3300 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3301 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3302 | if (no_hyperlinks): |
| 3303 | return self.id_serializer_class |
| 3304 | else: |
| 3305 | return self.serializer_class |
| 3306 | |
| 3307 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3308 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3309 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3310 | return PlanetStackRole.select_by_user(self.request.user) |
| 3311 | |
| 3312 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3313 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3314 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3315 | response = {"error": "validation", |
| 3316 | "specific_error": "not serializer.is_valid()",
|
| 3317 | "reasons": serializer.errors}
|
| 3318 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3319 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3320 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3321 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3322 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3323 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3324 | raise Exception("failed obj.can_update") |
| 3325 | |
| 3326 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 3327 | if (ret.status_code%100 != 200): |
| 3328 | raise Exception(ret.data) |
| 3329 | |
| 3330 | return ret |
| 3331 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3332 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3333 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3334 | queryset = PlanetStackRole.objects.select_related().all() |
| 3335 | serializer_class = PlanetStackRoleSerializer |
| 3336 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3337 | |
| 3338 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3339 | no_hyperlinks=False |
| 3340 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3341 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3342 | if (no_hyperlinks): |
| 3343 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3344 | else: |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3345 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3346 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3347 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3348 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3349 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3350 | return PlanetStackRole.select_by_user(self.request.user) |
| 3351 | |
| 3352 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3353 | |
| 3354 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3355 | |
| 3356 | |
| 3357 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3358 | class NetworkSliverList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3359 | queryset = NetworkSliver.objects.select_related().all() |
| 3360 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3361 | id_serializer_class = NetworkSliverIdSerializer |
| 3362 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3363 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3364 | |
| 3365 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3366 | no_hyperlinks=False |
| 3367 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3368 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3369 | if (no_hyperlinks): |
| 3370 | return self.id_serializer_class |
| 3371 | else: |
| 3372 | return self.serializer_class |
| 3373 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3374 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3375 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3376 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3377 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3378 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3379 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3380 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3381 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3382 | response = {"error": "validation", |
| 3383 | "specific_error": "not serializer.is_valid()",
|
| 3384 | "reasons": serializer.errors}
|
| 3385 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3386 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3387 | obj.caller = request.user |
| 3388 | if obj.can_update(request.user): |
| 3389 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3390 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3391 | raise Exception("failed obj.can_update") |
| 3392 | |
| 3393 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3394 | if (ret.status_code%100 != 200): |
| 3395 | raise Exception(ret.data) |
| 3396 | |
| 3397 | return ret |
| 3398 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3399 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3400 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3401 | queryset = NetworkSliver.objects.select_related().all() |
| 3402 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3403 | id_serializer_class = NetworkSliverIdSerializer |
| 3404 | |
| 3405 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3406 | no_hyperlinks=False |
| 3407 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3408 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3409 | if (no_hyperlinks): |
| 3410 | return self.id_serializer_class |
| 3411 | else: |
| 3412 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3413 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3414 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3415 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3416 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3417 | return NetworkSliver.select_by_user(self.request.user) |
| 3418 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3419 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3420 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3421 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3422 | |
| 3423 | |
| 3424 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3425 | class FlavorList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3426 | queryset = Flavor.objects.select_related().all() |
| 3427 | serializer_class = FlavorSerializer |
| 3428 | id_serializer_class = FlavorIdSerializer |
| 3429 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3430 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3431 | |
| 3432 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3433 | no_hyperlinks=False |
| 3434 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3435 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3436 | if (no_hyperlinks): |
| 3437 | return self.id_serializer_class |
| 3438 | else: |
| 3439 | return self.serializer_class |
| 3440 | |
| 3441 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3442 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3443 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3444 | return Flavor.select_by_user(self.request.user) |
| 3445 | |
| 3446 | def create(self, request, *args, **kwargs): |
| 3447 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3448 | if not (serializer.is_valid()): |
| 3449 | response = {"error": "validation", |
| 3450 | "specific_error": "not serializer.is_valid()",
|
| 3451 | "reasons": serializer.errors}
|
| 3452 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3453 | obj = serializer.object |
| 3454 | obj.caller = request.user |
| 3455 | if obj.can_update(request.user): |
| 3456 | return super(FlavorList, self).create(request, *args, **kwargs) |
| 3457 | else: |
| 3458 | raise Exception("failed obj.can_update") |
| 3459 | |
| 3460 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 3461 | if (ret.status_code%100 != 200): |
| 3462 | raise Exception(ret.data) |
| 3463 | |
| 3464 | return ret |
| 3465 | |
| 3466 | |
| 3467 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3468 | queryset = Flavor.objects.select_related().all() |
| 3469 | serializer_class = FlavorSerializer |
| 3470 | id_serializer_class = FlavorIdSerializer |
| 3471 | |
| 3472 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3473 | no_hyperlinks=False |
| 3474 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3475 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3476 | if (no_hyperlinks): |
| 3477 | return self.id_serializer_class |
| 3478 | else: |
| 3479 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3480 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3481 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3482 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3483 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3484 | return Flavor.select_by_user(self.request.user) |
| 3485 | |
| 3486 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3487 | |
| 3488 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3489 | |
| 3490 | |
| 3491 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3492 | class ControllerSiteList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3493 | queryset = ControllerSite.objects.select_related().all() |
| 3494 | serializer_class = ControllerSiteSerializer |
| 3495 | id_serializer_class = ControllerSiteIdSerializer |
| 3496 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3497 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3498 | |
| 3499 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3500 | no_hyperlinks=False |
| 3501 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3502 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3503 | if (no_hyperlinks): |
| 3504 | return self.id_serializer_class |
| 3505 | else: |
| 3506 | return self.serializer_class |
| 3507 | |
| 3508 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3509 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3510 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3511 | return ControllerSite.select_by_user(self.request.user) |
| 3512 | |
| 3513 | def create(self, request, *args, **kwargs): |
| 3514 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3515 | if not (serializer.is_valid()): |
| 3516 | response = {"error": "validation", |
| 3517 | "specific_error": "not serializer.is_valid()",
|
| 3518 | "reasons": serializer.errors}
|
| 3519 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3520 | obj = serializer.object |
| 3521 | obj.caller = request.user |
| 3522 | if obj.can_update(request.user): |
| 3523 | return super(ControllerSiteList, self).create(request, *args, **kwargs) |
| 3524 | else: |
| 3525 | raise Exception("failed obj.can_update") |
| 3526 | |
| 3527 | ret = super(ControllerSiteList, self).create(request, *args, **kwargs) |
| 3528 | if (ret.status_code%100 != 200): |
| 3529 | raise Exception(ret.data) |
| 3530 | |
| 3531 | return ret |
| 3532 | |
| 3533 | |
| 3534 | class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3535 | queryset = ControllerSite.objects.select_related().all() |
| 3536 | serializer_class = ControllerSiteSerializer |
| 3537 | id_serializer_class = ControllerSiteIdSerializer |
| 3538 | |
| 3539 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3540 | no_hyperlinks=False |
| 3541 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3542 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3543 | if (no_hyperlinks): |
| 3544 | return self.id_serializer_class |
| 3545 | else: |
| 3546 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3547 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3548 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3549 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3550 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3551 | return ControllerSite.select_by_user(self.request.user) |
| 3552 | |
| 3553 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3554 | |
| 3555 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3556 | |
| 3557 | |
| 3558 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3559 | class ProjectList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3560 | queryset = Project.objects.select_related().all() |
| 3561 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3562 | id_serializer_class = ProjectIdSerializer |
| 3563 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3564 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3565 | |
| 3566 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3567 | no_hyperlinks=False |
| 3568 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3569 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3570 | if (no_hyperlinks): |
| 3571 | return self.id_serializer_class |
| 3572 | else: |
| 3573 | return self.serializer_class |
| 3574 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3575 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3576 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3577 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3578 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3579 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3580 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3581 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3582 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3583 | response = {"error": "validation", |
| 3584 | "specific_error": "not serializer.is_valid()",
|
| 3585 | "reasons": serializer.errors}
|
| 3586 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3587 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3588 | obj.caller = request.user |
| 3589 | if obj.can_update(request.user): |
| 3590 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 3591 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3592 | raise Exception("failed obj.can_update") |
| 3593 | |
| 3594 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 3595 | if (ret.status_code%100 != 200): |
| 3596 | raise Exception(ret.data) |
| 3597 | |
| 3598 | return ret |
| 3599 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3600 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3601 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3602 | queryset = Project.objects.select_related().all() |
| 3603 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3604 | id_serializer_class = ProjectIdSerializer |
| 3605 | |
| 3606 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3607 | no_hyperlinks=False |
| 3608 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3609 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3610 | if (no_hyperlinks): |
| 3611 | return self.id_serializer_class |
| 3612 | else: |
| 3613 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3614 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3615 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3616 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3617 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3618 | return Project.select_by_user(self.request.user) |
| 3619 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3620 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3621 | |
| 3622 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3623 | |
| 3624 | |
| 3625 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3626 | class SliceList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3627 | queryset = Slice.objects.select_related().all() |
| 3628 | serializer_class = SliceSerializer |
| 3629 | id_serializer_class = SliceIdSerializer |
| 3630 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3631 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3632 | |
| 3633 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3634 | no_hyperlinks=False |
| 3635 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3636 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3637 | if (no_hyperlinks): |
| 3638 | return self.id_serializer_class |
| 3639 | else: |
| 3640 | return self.serializer_class |
| 3641 | |
| 3642 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3643 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3644 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3645 | return Slice.select_by_user(self.request.user) |
| 3646 | |
| 3647 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3648 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3649 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3650 | response = {"error": "validation", |
| 3651 | "specific_error": "not serializer.is_valid()",
|
| 3652 | "reasons": serializer.errors}
|
| 3653 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3654 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3655 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3656 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3657 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3658 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3659 | raise Exception("failed obj.can_update") |
| 3660 | |
| 3661 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3662 | if (ret.status_code%100 != 200): |
| 3663 | raise Exception(ret.data) |
| 3664 | |
| 3665 | return ret |
| 3666 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3667 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3668 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3669 | queryset = Slice.objects.select_related().all() |
| 3670 | serializer_class = SliceSerializer |
| 3671 | id_serializer_class = SliceIdSerializer |
| 3672 | |
| 3673 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3674 | no_hyperlinks=False |
| 3675 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3676 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3677 | if (no_hyperlinks): |
| 3678 | return self.id_serializer_class |
| 3679 | else: |
| 3680 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3681 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3682 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3683 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3684 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3685 | return Slice.select_by_user(self.request.user) |
| 3686 | |
| 3687 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3688 | |
| 3689 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3690 | |
| 3691 | |
| 3692 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3693 | class NetworkList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3694 | queryset = Network.objects.select_related().all() |
| 3695 | serializer_class = NetworkSerializer |
| 3696 | id_serializer_class = NetworkIdSerializer |
| 3697 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3698 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3699 | |
| 3700 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3701 | no_hyperlinks=False |
| 3702 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3703 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3704 | if (no_hyperlinks): |
| 3705 | return self.id_serializer_class |
| 3706 | else: |
| 3707 | return self.serializer_class |
| 3708 | |
| 3709 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3710 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3711 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3712 | return Network.select_by_user(self.request.user) |
| 3713 | |
| 3714 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3715 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3716 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3717 | response = {"error": "validation", |
| 3718 | "specific_error": "not serializer.is_valid()",
|
| 3719 | "reasons": serializer.errors}
|
| 3720 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3721 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3722 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3723 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3724 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3725 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3726 | raise Exception("failed obj.can_update") |
| 3727 | |
| 3728 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3729 | if (ret.status_code%100 != 200): |
| 3730 | raise Exception(ret.data) |
| 3731 | |
| 3732 | return ret |
| 3733 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3734 | |
| 3735 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3736 | queryset = Network.objects.select_related().all() |
| 3737 | serializer_class = NetworkSerializer |
| 3738 | id_serializer_class = NetworkIdSerializer |
| 3739 | |
| 3740 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3741 | no_hyperlinks=False |
| 3742 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3743 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3744 | if (no_hyperlinks): |
| 3745 | return self.id_serializer_class |
| 3746 | else: |
| 3747 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3748 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3749 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3750 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3751 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3752 | return Network.select_by_user(self.request.user) |
| 3753 | |
| 3754 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3755 | |
| 3756 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3757 | |
| 3758 | |
| 3759 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3760 | class ServiceList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3761 | queryset = Service.objects.select_related().all() |
| 3762 | serializer_class = ServiceSerializer |
| 3763 | id_serializer_class = ServiceIdSerializer |
| 3764 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3765 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3766 | |
| 3767 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3768 | no_hyperlinks=False |
| 3769 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3770 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3771 | if (no_hyperlinks): |
| 3772 | return self.id_serializer_class |
| 3773 | else: |
| 3774 | return self.serializer_class |
| 3775 | |
| 3776 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3777 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3778 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3779 | return Service.select_by_user(self.request.user) |
| 3780 | |
| 3781 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3782 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3783 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3784 | response = {"error": "validation", |
| 3785 | "specific_error": "not serializer.is_valid()",
|
| 3786 | "reasons": serializer.errors}
|
| 3787 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3788 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3789 | obj.caller = request.user |
| 3790 | if obj.can_update(request.user): |
| 3791 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3792 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3793 | raise Exception("failed obj.can_update") |
| 3794 | |
| 3795 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3796 | if (ret.status_code%100 != 200): |
| 3797 | raise Exception(ret.data) |
| 3798 | |
| 3799 | return ret |
| 3800 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3801 | |
| 3802 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3803 | queryset = Service.objects.select_related().all() |
| 3804 | serializer_class = ServiceSerializer |
| 3805 | id_serializer_class = ServiceIdSerializer |
| 3806 | |
| 3807 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3808 | no_hyperlinks=False |
| 3809 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3810 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3811 | if (no_hyperlinks): |
| 3812 | return self.id_serializer_class |
| 3813 | else: |
| 3814 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3815 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3816 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3817 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3818 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3819 | return Service.select_by_user(self.request.user) |
| 3820 | |
| 3821 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3822 | |
| 3823 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3824 | |
| 3825 | |
| 3826 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3827 | class ServiceClassList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3828 | queryset = ServiceClass.objects.select_related().all() |
| 3829 | serializer_class = ServiceClassSerializer |
| 3830 | id_serializer_class = ServiceClassIdSerializer |
| 3831 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3832 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3833 | |
| 3834 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3835 | no_hyperlinks=False |
| 3836 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3837 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3838 | if (no_hyperlinks): |
| 3839 | return self.id_serializer_class |
| 3840 | else: |
| 3841 | return self.serializer_class |
| 3842 | |
| 3843 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3844 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3845 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3846 | return ServiceClass.select_by_user(self.request.user) |
| 3847 | |
| 3848 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3849 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3850 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3851 | response = {"error": "validation", |
| 3852 | "specific_error": "not serializer.is_valid()",
|
| 3853 | "reasons": serializer.errors}
|
| 3854 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3855 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3856 | obj.caller = request.user |
| 3857 | if obj.can_update(request.user): |
| 3858 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3859 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3860 | raise Exception("failed obj.can_update") |
| 3861 | |
| 3862 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3863 | if (ret.status_code%100 != 200): |
| 3864 | raise Exception(ret.data) |
| 3865 | |
| 3866 | return ret |
| 3867 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3868 | |
| 3869 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3870 | queryset = ServiceClass.objects.select_related().all() |
| 3871 | serializer_class = ServiceClassSerializer |
| 3872 | id_serializer_class = ServiceClassIdSerializer |
| 3873 | |
| 3874 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3875 | no_hyperlinks=False |
| 3876 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3877 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3878 | if (no_hyperlinks): |
| 3879 | return self.id_serializer_class |
| 3880 | else: |
| 3881 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3882 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3883 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3884 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3885 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3886 | return ServiceClass.select_by_user(self.request.user) |
| 3887 | |
| 3888 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3889 | |
| 3890 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3891 | |
| 3892 | |
| 3893 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3894 | class PlanetStackList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3895 | queryset = PlanetStack.objects.select_related().all() |
| 3896 | serializer_class = PlanetStackSerializer |
| 3897 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3898 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3899 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3900 | |
| 3901 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3902 | no_hyperlinks=False |
| 3903 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3904 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3905 | if (no_hyperlinks): |
| 3906 | return self.id_serializer_class |
| 3907 | else: |
| 3908 | return self.serializer_class |
| 3909 | |
| 3910 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3911 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3912 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3913 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3914 | |
| 3915 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3916 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3917 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3918 | response = {"error": "validation", |
| 3919 | "specific_error": "not serializer.is_valid()",
|
| 3920 | "reasons": serializer.errors}
|
| 3921 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3922 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3923 | obj.caller = request.user |
| 3924 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3925 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3926 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3927 | raise Exception("failed obj.can_update") |
| 3928 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3929 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3930 | if (ret.status_code%100 != 200): |
| 3931 | raise Exception(ret.data) |
| 3932 | |
| 3933 | return ret |
| 3934 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3935 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3936 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3937 | queryset = PlanetStack.objects.select_related().all() |
| 3938 | serializer_class = PlanetStackSerializer |
| 3939 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3940 | |
| 3941 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3942 | no_hyperlinks=False |
| 3943 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3944 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3945 | if (no_hyperlinks): |
| 3946 | return self.id_serializer_class |
| 3947 | else: |
| 3948 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3949 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3950 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3951 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3952 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3953 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3954 | |
| 3955 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3956 | |
| 3957 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3958 | |
| 3959 | |
| 3960 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 3961 | class ChargeList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3962 | queryset = Charge.objects.select_related().all() |
| 3963 | serializer_class = ChargeSerializer |
| 3964 | id_serializer_class = ChargeIdSerializer |
| 3965 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3966 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3967 | |
| 3968 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3969 | no_hyperlinks=False |
| 3970 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3971 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3972 | if (no_hyperlinks): |
| 3973 | return self.id_serializer_class |
| 3974 | else: |
| 3975 | return self.serializer_class |
| 3976 | |
| 3977 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3978 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 3979 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3980 | return Charge.select_by_user(self.request.user) |
| 3981 | |
| 3982 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3983 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3984 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3985 | response = {"error": "validation", |
| 3986 | "specific_error": "not serializer.is_valid()",
|
| 3987 | "reasons": serializer.errors}
|
| 3988 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3989 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3990 | obj.caller = request.user |
| 3991 | if obj.can_update(request.user): |
| 3992 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3993 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3994 | raise Exception("failed obj.can_update") |
| 3995 | |
| 3996 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3997 | if (ret.status_code%100 != 200): |
| 3998 | raise Exception(ret.data) |
| 3999 | |
| 4000 | return ret |
| 4001 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4002 | |
| 4003 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4004 | queryset = Charge.objects.select_related().all() |
| 4005 | serializer_class = ChargeSerializer |
| 4006 | id_serializer_class = ChargeIdSerializer |
| 4007 | |
| 4008 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4009 | no_hyperlinks=False |
| 4010 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4011 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4012 | if (no_hyperlinks): |
| 4013 | return self.id_serializer_class |
| 4014 | else: |
| 4015 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4016 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4017 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4018 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4019 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4020 | return Charge.select_by_user(self.request.user) |
| 4021 | |
| 4022 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4023 | |
| 4024 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4025 | |
| 4026 | |
| 4027 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4028 | class RoleList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4029 | queryset = Role.objects.select_related().all() |
| 4030 | serializer_class = RoleSerializer |
| 4031 | id_serializer_class = RoleIdSerializer |
| 4032 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4033 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4034 | |
| 4035 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4036 | no_hyperlinks=False |
| 4037 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4038 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4039 | if (no_hyperlinks): |
| 4040 | return self.id_serializer_class |
| 4041 | else: |
| 4042 | return self.serializer_class |
| 4043 | |
| 4044 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4045 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4046 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4047 | return Role.select_by_user(self.request.user) |
| 4048 | |
| 4049 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4050 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4051 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4052 | response = {"error": "validation", |
| 4053 | "specific_error": "not serializer.is_valid()",
|
| 4054 | "reasons": serializer.errors}
|
| 4055 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4056 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4057 | obj.caller = request.user |
| 4058 | if obj.can_update(request.user): |
| 4059 | return super(RoleList, self).create(request, *args, **kwargs) |
| 4060 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4061 | raise Exception("failed obj.can_update") |
| 4062 | |
| 4063 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 4064 | if (ret.status_code%100 != 200): |
| 4065 | raise Exception(ret.data) |
| 4066 | |
| 4067 | return ret |
| 4068 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4069 | |
| 4070 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4071 | queryset = Role.objects.select_related().all() |
| 4072 | serializer_class = RoleSerializer |
| 4073 | id_serializer_class = RoleIdSerializer |
| 4074 | |
| 4075 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4076 | no_hyperlinks=False |
| 4077 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4078 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4079 | if (no_hyperlinks): |
| 4080 | return self.id_serializer_class |
| 4081 | else: |
| 4082 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4083 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4084 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4085 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4086 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4087 | return Role.select_by_user(self.request.user) |
| 4088 | |
| 4089 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4090 | |
| 4091 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4092 | |
| 4093 | |
| 4094 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4095 | class UsableObjectList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4096 | queryset = UsableObject.objects.select_related().all() |
| 4097 | serializer_class = UsableObjectSerializer |
| 4098 | id_serializer_class = UsableObjectIdSerializer |
| 4099 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4100 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4101 | |
| 4102 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4103 | no_hyperlinks=False |
| 4104 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4105 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4106 | if (no_hyperlinks): |
| 4107 | return self.id_serializer_class |
| 4108 | else: |
| 4109 | return self.serializer_class |
| 4110 | |
| 4111 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4112 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4113 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4114 | return UsableObject.select_by_user(self.request.user) |
| 4115 | |
| 4116 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4117 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4118 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4119 | response = {"error": "validation", |
| 4120 | "specific_error": "not serializer.is_valid()",
|
| 4121 | "reasons": serializer.errors}
|
| 4122 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4123 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4124 | obj.caller = request.user |
| 4125 | if obj.can_update(request.user): |
| 4126 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 4127 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4128 | raise Exception("failed obj.can_update") |
| 4129 | |
| 4130 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 4131 | if (ret.status_code%100 != 200): |
| 4132 | raise Exception(ret.data) |
| 4133 | |
| 4134 | return ret |
| 4135 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4136 | |
| 4137 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4138 | queryset = UsableObject.objects.select_related().all() |
| 4139 | serializer_class = UsableObjectSerializer |
| 4140 | id_serializer_class = UsableObjectIdSerializer |
| 4141 | |
| 4142 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4143 | no_hyperlinks=False |
| 4144 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4145 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4146 | if (no_hyperlinks): |
| 4147 | return self.id_serializer_class |
| 4148 | else: |
| 4149 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4150 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4151 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4152 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4153 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4154 | return UsableObject.select_by_user(self.request.user) |
| 4155 | |
| 4156 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4157 | |
| 4158 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4159 | |
| 4160 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4161 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4162 | class SiteRoleList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4163 | queryset = SiteRole.objects.select_related().all() |
| 4164 | serializer_class = SiteRoleSerializer |
| 4165 | id_serializer_class = SiteRoleIdSerializer |
| 4166 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4167 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4168 | |
| 4169 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4170 | no_hyperlinks=False |
| 4171 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4172 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4173 | if (no_hyperlinks): |
| 4174 | return self.id_serializer_class |
| 4175 | else: |
| 4176 | return self.serializer_class |
| 4177 | |
| 4178 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4179 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4180 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4181 | return SiteRole.select_by_user(self.request.user) |
| 4182 | |
| 4183 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4184 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4185 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4186 | response = {"error": "validation", |
| 4187 | "specific_error": "not serializer.is_valid()",
|
| 4188 | "reasons": serializer.errors}
|
| 4189 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4190 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4191 | obj.caller = request.user |
| 4192 | if obj.can_update(request.user): |
| 4193 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 4194 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4195 | raise Exception("failed obj.can_update") |
| 4196 | |
| 4197 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 4198 | if (ret.status_code%100 != 200): |
| 4199 | raise Exception(ret.data) |
| 4200 | |
| 4201 | return ret |
| 4202 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4203 | |
| 4204 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4205 | queryset = SiteRole.objects.select_related().all() |
| 4206 | serializer_class = SiteRoleSerializer |
| 4207 | id_serializer_class = SiteRoleIdSerializer |
| 4208 | |
| 4209 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4210 | no_hyperlinks=False |
| 4211 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4212 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4213 | if (no_hyperlinks): |
| 4214 | return self.id_serializer_class |
| 4215 | else: |
| 4216 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4217 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4218 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4219 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4220 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4221 | return SiteRole.select_by_user(self.request.user) |
| 4222 | |
| 4223 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4224 | |
| 4225 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4226 | |
| 4227 | |
| 4228 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4229 | class SliceCredentialList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4230 | queryset = SliceCredential.objects.select_related().all() |
| 4231 | serializer_class = SliceCredentialSerializer |
| 4232 | id_serializer_class = SliceCredentialIdSerializer |
| 4233 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4234 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4235 | |
| 4236 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4237 | no_hyperlinks=False |
| 4238 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4239 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4240 | if (no_hyperlinks): |
| 4241 | return self.id_serializer_class |
| 4242 | else: |
| 4243 | return self.serializer_class |
| 4244 | |
| 4245 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4246 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4247 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4248 | return SliceCredential.select_by_user(self.request.user) |
| 4249 | |
| 4250 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4251 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4252 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4253 | response = {"error": "validation", |
| 4254 | "specific_error": "not serializer.is_valid()",
|
| 4255 | "reasons": serializer.errors}
|
| 4256 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4257 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4258 | obj.caller = request.user |
| 4259 | if obj.can_update(request.user): |
| 4260 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 4261 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4262 | raise Exception("failed obj.can_update") |
| 4263 | |
| 4264 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 4265 | if (ret.status_code%100 != 200): |
| 4266 | raise Exception(ret.data) |
| 4267 | |
| 4268 | return ret |
| 4269 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4270 | |
| 4271 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4272 | queryset = SliceCredential.objects.select_related().all() |
| 4273 | serializer_class = SliceCredentialSerializer |
| 4274 | id_serializer_class = SliceCredentialIdSerializer |
| 4275 | |
| 4276 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4277 | no_hyperlinks=False |
| 4278 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4279 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4280 | if (no_hyperlinks): |
| 4281 | return self.id_serializer_class |
| 4282 | else: |
| 4283 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4284 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4285 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4286 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4287 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4288 | return SliceCredential.select_by_user(self.request.user) |
| 4289 | |
| 4290 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4291 | |
| 4292 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4293 | |
| 4294 | |
| 4295 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4296 | class SliverList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4297 | queryset = Sliver.objects.select_related().all() |
| 4298 | serializer_class = SliverSerializer |
| 4299 | id_serializer_class = SliverIdSerializer |
| 4300 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4301 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4302 | |
| 4303 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4304 | no_hyperlinks=False |
| 4305 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4306 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4307 | if (no_hyperlinks): |
| 4308 | return self.id_serializer_class |
| 4309 | else: |
| 4310 | return self.serializer_class |
| 4311 | |
| 4312 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4313 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4314 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4315 | return Sliver.select_by_user(self.request.user) |
| 4316 | |
| 4317 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4318 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4319 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4320 | response = {"error": "validation", |
| 4321 | "specific_error": "not serializer.is_valid()",
|
| 4322 | "reasons": serializer.errors}
|
| 4323 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4324 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4325 | obj.caller = request.user |
| 4326 | if obj.can_update(request.user): |
| 4327 | return super(SliverList, self).create(request, *args, **kwargs) |
| 4328 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4329 | raise Exception("failed obj.can_update") |
| 4330 | |
| 4331 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 4332 | if (ret.status_code%100 != 200): |
| 4333 | raise Exception(ret.data) |
| 4334 | |
| 4335 | return ret |
| 4336 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4337 | |
| 4338 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4339 | queryset = Sliver.objects.select_related().all() |
| 4340 | serializer_class = SliverSerializer |
| 4341 | id_serializer_class = SliverIdSerializer |
| 4342 | |
| 4343 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4344 | no_hyperlinks=False |
| 4345 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4346 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4347 | if (no_hyperlinks): |
| 4348 | return self.id_serializer_class |
| 4349 | else: |
| 4350 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4351 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4352 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4353 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4354 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4355 | return Sliver.select_by_user(self.request.user) |
| 4356 | |
| 4357 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4358 | |
| 4359 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4360 | |
| 4361 | |
| 4362 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4363 | class NodeList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4364 | queryset = Node.objects.select_related().all() |
| 4365 | serializer_class = NodeSerializer |
| 4366 | id_serializer_class = NodeIdSerializer |
| 4367 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4368 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4369 | |
| 4370 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4371 | no_hyperlinks=False |
| 4372 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4373 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4374 | if (no_hyperlinks): |
| 4375 | return self.id_serializer_class |
| 4376 | else: |
| 4377 | return self.serializer_class |
| 4378 | |
| 4379 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4380 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4381 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4382 | return Node.select_by_user(self.request.user) |
| 4383 | |
| 4384 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4385 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4386 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4387 | response = {"error": "validation", |
| 4388 | "specific_error": "not serializer.is_valid()",
|
| 4389 | "reasons": serializer.errors}
|
| 4390 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4391 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4392 | obj.caller = request.user |
| 4393 | if obj.can_update(request.user): |
| 4394 | return super(NodeList, self).create(request, *args, **kwargs) |
| 4395 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4396 | raise Exception("failed obj.can_update") |
| 4397 | |
| 4398 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 4399 | if (ret.status_code%100 != 200): |
| 4400 | raise Exception(ret.data) |
| 4401 | |
| 4402 | return ret |
| 4403 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4404 | |
| 4405 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4406 | queryset = Node.objects.select_related().all() |
| 4407 | serializer_class = NodeSerializer |
| 4408 | id_serializer_class = NodeIdSerializer |
| 4409 | |
| 4410 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4411 | no_hyperlinks=False |
| 4412 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4413 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4414 | if (no_hyperlinks): |
| 4415 | return self.id_serializer_class |
| 4416 | else: |
| 4417 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4418 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4419 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4420 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4421 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4422 | return Node.select_by_user(self.request.user) |
| 4423 | |
| 4424 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4425 | |
| 4426 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4427 | |
| 4428 | |
| 4429 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4430 | class DashboardViewList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4431 | queryset = DashboardView.objects.select_related().all() |
| 4432 | serializer_class = DashboardViewSerializer |
| 4433 | id_serializer_class = DashboardViewIdSerializer |
| 4434 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4435 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4436 | |
| 4437 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4438 | no_hyperlinks=False |
| 4439 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4440 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4441 | if (no_hyperlinks): |
| 4442 | return self.id_serializer_class |
| 4443 | else: |
| 4444 | return self.serializer_class |
| 4445 | |
| 4446 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4447 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4448 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4449 | return DashboardView.select_by_user(self.request.user) |
| 4450 | |
| 4451 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4452 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4453 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4454 | response = {"error": "validation", |
| 4455 | "specific_error": "not serializer.is_valid()",
|
| 4456 | "reasons": serializer.errors}
|
| 4457 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4458 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4459 | obj.caller = request.user |
| 4460 | if obj.can_update(request.user): |
| 4461 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4462 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4463 | raise Exception("failed obj.can_update") |
| 4464 | |
| 4465 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4466 | if (ret.status_code%100 != 200): |
| 4467 | raise Exception(ret.data) |
| 4468 | |
| 4469 | return ret |
| 4470 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4471 | |
| 4472 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4473 | queryset = DashboardView.objects.select_related().all() |
| 4474 | serializer_class = DashboardViewSerializer |
| 4475 | id_serializer_class = DashboardViewIdSerializer |
| 4476 | |
| 4477 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4478 | no_hyperlinks=False |
| 4479 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4480 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4481 | if (no_hyperlinks): |
| 4482 | return self.id_serializer_class |
| 4483 | else: |
| 4484 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4485 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4486 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4487 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4488 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4489 | return DashboardView.select_by_user(self.request.user) |
| 4490 | |
| 4491 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4492 | |
| 4493 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4494 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4495 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4496 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4497 | class ControllerNetworkList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4498 | queryset = ControllerNetwork.objects.select_related().all() |
| 4499 | serializer_class = ControllerNetworkSerializer |
| 4500 | id_serializer_class = ControllerNetworkIdSerializer |
| 4501 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4502 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4503 | |
| 4504 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4505 | no_hyperlinks=False |
| 4506 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4507 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4508 | if (no_hyperlinks): |
| 4509 | return self.id_serializer_class |
| 4510 | else: |
| 4511 | return self.serializer_class |
| 4512 | |
| 4513 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4514 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4515 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4516 | return ControllerNetwork.select_by_user(self.request.user) |
| 4517 | |
| 4518 | def create(self, request, *args, **kwargs): |
| 4519 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4520 | if not (serializer.is_valid()): |
| 4521 | response = {"error": "validation", |
| 4522 | "specific_error": "not serializer.is_valid()",
|
| 4523 | "reasons": serializer.errors}
|
| 4524 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4525 | obj = serializer.object |
| 4526 | obj.caller = request.user |
| 4527 | if obj.can_update(request.user): |
| 4528 | return super(ControllerNetworkList, self).create(request, *args, **kwargs) |
| 4529 | else: |
| 4530 | raise Exception("failed obj.can_update") |
| 4531 | |
| 4532 | ret = super(ControllerNetworkList, self).create(request, *args, **kwargs) |
| 4533 | if (ret.status_code%100 != 200): |
| 4534 | raise Exception(ret.data) |
| 4535 | |
| 4536 | return ret |
| 4537 | |
| 4538 | |
| 4539 | class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4540 | queryset = ControllerNetwork.objects.select_related().all() |
| 4541 | serializer_class = ControllerNetworkSerializer |
| 4542 | id_serializer_class = ControllerNetworkIdSerializer |
| 4543 | |
| 4544 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4545 | no_hyperlinks=False |
| 4546 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4547 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4548 | if (no_hyperlinks): |
| 4549 | return self.id_serializer_class |
| 4550 | else: |
| 4551 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4552 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4553 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4554 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4555 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4556 | return ControllerNetwork.select_by_user(self.request.user) |
| 4557 | |
| 4558 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4559 | |
| 4560 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4561 | |
| 4562 | |
| 4563 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4564 | class ImageDeploymentsList(PlanetStackListCreateAPIView): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4565 | queryset = ImageDeployments.objects.select_related().all() |
| 4566 | serializer_class = ImageDeploymentsSerializer |
| 4567 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4568 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4569 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4570 | |
| 4571 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4572 | no_hyperlinks=False |
| 4573 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4574 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4575 | if (no_hyperlinks): |
| 4576 | return self.id_serializer_class |
| 4577 | else: |
| 4578 | return self.serializer_class |
| 4579 | |
| 4580 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4581 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4582 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4583 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4584 | |
| 4585 | def create(self, request, *args, **kwargs): |
| 4586 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4587 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4588 | response = {"error": "validation", |
| 4589 | "specific_error": "not serializer.is_valid()",
|
| 4590 | "reasons": serializer.errors}
|
| 4591 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4592 | obj = serializer.object |
| 4593 | obj.caller = request.user |
| 4594 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4595 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4596 | else: |
| 4597 | raise Exception("failed obj.can_update") |
| 4598 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4599 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4600 | if (ret.status_code%100 != 200): |
| 4601 | raise Exception(ret.data) |
| 4602 | |
| 4603 | return ret |
| 4604 | |
| 4605 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4606 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4607 | queryset = ImageDeployments.objects.select_related().all() |
| 4608 | serializer_class = ImageDeploymentsSerializer |
| 4609 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4610 | |
| 4611 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4612 | no_hyperlinks=False |
| 4613 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4614 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4615 | if (no_hyperlinks): |
| 4616 | return self.id_serializer_class |
| 4617 | else: |
| 4618 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4619 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4620 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4621 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4622 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4623 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4624 | |
| 4625 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4626 | |
| 4627 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4628 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4629 | |
| 4630 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4631 | class ControllerUserList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4632 | queryset = ControllerUser.objects.select_related().all() |
| 4633 | serializer_class = ControllerUserSerializer |
| 4634 | id_serializer_class = ControllerUserIdSerializer |
| 4635 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4636 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4637 | |
| 4638 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4639 | no_hyperlinks=False |
| 4640 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4641 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4642 | if (no_hyperlinks): |
| 4643 | return self.id_serializer_class |
| 4644 | else: |
| 4645 | return self.serializer_class |
| 4646 | |
| 4647 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4648 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4649 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4650 | return ControllerUser.select_by_user(self.request.user) |
| 4651 | |
| 4652 | def create(self, request, *args, **kwargs): |
| 4653 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4654 | if not (serializer.is_valid()): |
| 4655 | response = {"error": "validation", |
| 4656 | "specific_error": "not serializer.is_valid()",
|
| 4657 | "reasons": serializer.errors}
|
| 4658 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4659 | obj = serializer.object |
| 4660 | obj.caller = request.user |
| 4661 | if obj.can_update(request.user): |
| 4662 | return super(ControllerUserList, self).create(request, *args, **kwargs) |
| 4663 | else: |
| 4664 | raise Exception("failed obj.can_update") |
| 4665 | |
| 4666 | ret = super(ControllerUserList, self).create(request, *args, **kwargs) |
| 4667 | if (ret.status_code%100 != 200): |
| 4668 | raise Exception(ret.data) |
| 4669 | |
| 4670 | return ret |
| 4671 | |
| 4672 | |
| 4673 | class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4674 | queryset = ControllerUser.objects.select_related().all() |
| 4675 | serializer_class = ControllerUserSerializer |
| 4676 | id_serializer_class = ControllerUserIdSerializer |
| 4677 | |
| 4678 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4679 | no_hyperlinks=False |
| 4680 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4681 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4682 | if (no_hyperlinks): |
| 4683 | return self.id_serializer_class |
| 4684 | else: |
| 4685 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4686 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4687 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4688 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4689 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4690 | return ControllerUser.select_by_user(self.request.user) |
| 4691 | |
| 4692 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4693 | |
| 4694 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4695 | |
| 4696 | |
| 4697 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4698 | class ReservedResourceList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4699 | queryset = ReservedResource.objects.select_related().all() |
| 4700 | serializer_class = ReservedResourceSerializer |
| 4701 | id_serializer_class = ReservedResourceIdSerializer |
| 4702 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4703 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4704 | |
| 4705 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4706 | no_hyperlinks=False |
| 4707 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4708 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4709 | if (no_hyperlinks): |
| 4710 | return self.id_serializer_class |
| 4711 | else: |
| 4712 | return self.serializer_class |
| 4713 | |
| 4714 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4715 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4716 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4717 | return ReservedResource.select_by_user(self.request.user) |
| 4718 | |
| 4719 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4720 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4721 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4722 | response = {"error": "validation", |
| 4723 | "specific_error": "not serializer.is_valid()",
|
| 4724 | "reasons": serializer.errors}
|
| 4725 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4726 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4727 | obj.caller = request.user |
| 4728 | if obj.can_update(request.user): |
| 4729 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4730 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4731 | raise Exception("failed obj.can_update") |
| 4732 | |
| 4733 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4734 | if (ret.status_code%100 != 200): |
| 4735 | raise Exception(ret.data) |
| 4736 | |
| 4737 | return ret |
| 4738 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4739 | |
| 4740 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4741 | queryset = ReservedResource.objects.select_related().all() |
| 4742 | serializer_class = ReservedResourceSerializer |
| 4743 | id_serializer_class = ReservedResourceIdSerializer |
| 4744 | |
| 4745 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4746 | no_hyperlinks=False |
| 4747 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4748 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4749 | if (no_hyperlinks): |
| 4750 | return self.id_serializer_class |
| 4751 | else: |
| 4752 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4753 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4754 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4755 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4756 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4757 | return ReservedResource.select_by_user(self.request.user) |
| 4758 | |
| 4759 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4760 | |
| 4761 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4762 | |
| 4763 | |
| 4764 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4765 | class PaymentList(PlanetStackListCreateAPIView): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4766 | queryset = Payment.objects.select_related().all() |
| 4767 | serializer_class = PaymentSerializer |
| 4768 | id_serializer_class = PaymentIdSerializer |
| 4769 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4770 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4771 | |
| 4772 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4773 | no_hyperlinks=False |
| 4774 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4775 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4776 | if (no_hyperlinks): |
| 4777 | return self.id_serializer_class |
| 4778 | else: |
| 4779 | return self.serializer_class |
| 4780 | |
| 4781 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4782 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4783 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4784 | return Payment.select_by_user(self.request.user) |
| 4785 | |
| 4786 | def create(self, request, *args, **kwargs): |
| 4787 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4788 | if not (serializer.is_valid()): |
| 4789 | response = {"error": "validation", |
| 4790 | "specific_error": "not serializer.is_valid()",
|
| 4791 | "reasons": serializer.errors}
|
| 4792 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4793 | obj = serializer.object |
| 4794 | obj.caller = request.user |
| 4795 | if obj.can_update(request.user): |
| 4796 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 4797 | else: |
| 4798 | raise Exception("failed obj.can_update") |
| 4799 | |
| 4800 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 4801 | if (ret.status_code%100 != 200): |
| 4802 | raise Exception(ret.data) |
| 4803 | |
| 4804 | return ret |
| 4805 | |
| 4806 | |
| 4807 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4808 | queryset = Payment.objects.select_related().all() |
| 4809 | serializer_class = PaymentSerializer |
| 4810 | id_serializer_class = PaymentIdSerializer |
| 4811 | |
| 4812 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4813 | no_hyperlinks=False |
| 4814 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4815 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4816 | if (no_hyperlinks): |
| 4817 | return self.id_serializer_class |
| 4818 | else: |
| 4819 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4820 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4821 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4822 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4823 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4824 | return Payment.select_by_user(self.request.user) |
| 4825 | |
| 4826 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4827 | |
| 4828 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4829 | |
| 4830 | |
| 4831 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4832 | class NetworkSliceList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4833 | queryset = NetworkSlice.objects.select_related().all() |
| 4834 | serializer_class = NetworkSliceSerializer |
| 4835 | id_serializer_class = NetworkSliceIdSerializer |
| 4836 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4837 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4838 | |
| 4839 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4840 | no_hyperlinks=False |
| 4841 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4842 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4843 | if (no_hyperlinks): |
| 4844 | return self.id_serializer_class |
| 4845 | else: |
| 4846 | return self.serializer_class |
| 4847 | |
| 4848 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4849 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4850 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4851 | return NetworkSlice.select_by_user(self.request.user) |
| 4852 | |
| 4853 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4854 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4855 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4856 | response = {"error": "validation", |
| 4857 | "specific_error": "not serializer.is_valid()",
|
| 4858 | "reasons": serializer.errors}
|
| 4859 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4860 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4861 | obj.caller = request.user |
| 4862 | if obj.can_update(request.user): |
| 4863 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4864 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4865 | raise Exception("failed obj.can_update") |
| 4866 | |
| 4867 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4868 | if (ret.status_code%100 != 200): |
| 4869 | raise Exception(ret.data) |
| 4870 | |
| 4871 | return ret |
| 4872 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4873 | |
| 4874 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4875 | queryset = NetworkSlice.objects.select_related().all() |
| 4876 | serializer_class = NetworkSliceSerializer |
| 4877 | id_serializer_class = NetworkSliceIdSerializer |
| 4878 | |
| 4879 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4880 | no_hyperlinks=False |
| 4881 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4882 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4883 | if (no_hyperlinks): |
| 4884 | return self.id_serializer_class |
| 4885 | else: |
| 4886 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4887 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4888 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4889 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4890 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4891 | return NetworkSlice.select_by_user(self.request.user) |
| 4892 | |
| 4893 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4894 | |
| 4895 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4896 | |
| 4897 | |
| 4898 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4899 | class UserDashboardViewList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4900 | queryset = UserDashboardView.objects.select_related().all() |
| 4901 | serializer_class = UserDashboardViewSerializer |
| 4902 | id_serializer_class = UserDashboardViewIdSerializer |
| 4903 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4904 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4905 | |
| 4906 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4907 | no_hyperlinks=False |
| 4908 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4909 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4910 | if (no_hyperlinks): |
| 4911 | return self.id_serializer_class |
| 4912 | else: |
| 4913 | return self.serializer_class |
| 4914 | |
| 4915 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4916 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4917 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4918 | return UserDashboardView.select_by_user(self.request.user) |
| 4919 | |
| 4920 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4921 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4922 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4923 | response = {"error": "validation", |
| 4924 | "specific_error": "not serializer.is_valid()",
|
| 4925 | "reasons": serializer.errors}
|
| 4926 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4927 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4928 | obj.caller = request.user |
| 4929 | if obj.can_update(request.user): |
| 4930 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4931 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4932 | raise Exception("failed obj.can_update") |
| 4933 | |
| 4934 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4935 | if (ret.status_code%100 != 200): |
| 4936 | raise Exception(ret.data) |
| 4937 | |
| 4938 | return ret |
| 4939 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4940 | |
| 4941 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4942 | queryset = UserDashboardView.objects.select_related().all() |
| 4943 | serializer_class = UserDashboardViewSerializer |
| 4944 | id_serializer_class = UserDashboardViewIdSerializer |
| 4945 | |
| 4946 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4947 | no_hyperlinks=False |
| 4948 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4949 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4950 | if (no_hyperlinks): |
| 4951 | return self.id_serializer_class |
| 4952 | else: |
| 4953 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4954 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4955 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4956 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4957 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4958 | return UserDashboardView.select_by_user(self.request.user) |
| 4959 | |
| 4960 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4961 | |
| 4962 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4963 | |
| 4964 | |
| 4965 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 4966 | class ControllerList(PlanetStackListCreateAPIView): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4967 | queryset = Controller.objects.select_related().all() |
| 4968 | serializer_class = ControllerSerializer |
| 4969 | id_serializer_class = ControllerIdSerializer |
| 4970 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4971 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4972 | |
| 4973 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4974 | no_hyperlinks=False |
| 4975 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4976 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4977 | if (no_hyperlinks): |
| 4978 | return self.id_serializer_class |
| 4979 | else: |
| 4980 | return self.serializer_class |
| 4981 | |
| 4982 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4983 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 4984 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4985 | return Controller.select_by_user(self.request.user) |
| 4986 | |
| 4987 | def create(self, request, *args, **kwargs): |
| 4988 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4989 | if not (serializer.is_valid()): |
| 4990 | response = {"error": "validation", |
| 4991 | "specific_error": "not serializer.is_valid()",
|
| 4992 | "reasons": serializer.errors}
|
| 4993 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4994 | obj = serializer.object |
| 4995 | obj.caller = request.user |
| 4996 | if obj.can_update(request.user): |
| 4997 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4998 | else: |
| 4999 | raise Exception("failed obj.can_update") |
| 5000 | |
| 5001 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 5002 | if (ret.status_code%100 != 200): |
| 5003 | raise Exception(ret.data) |
| 5004 | |
| 5005 | return ret |
| 5006 | |
| 5007 | |
| 5008 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5009 | queryset = Controller.objects.select_related().all() |
| 5010 | serializer_class = ControllerSerializer |
| 5011 | id_serializer_class = ControllerIdSerializer |
| 5012 | |
| 5013 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5014 | no_hyperlinks=False |
| 5015 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5016 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5017 | if (no_hyperlinks): |
| 5018 | return self.id_serializer_class |
| 5019 | else: |
| 5020 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5021 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5022 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5023 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5024 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5025 | return Controller.select_by_user(self.request.user) |
| 5026 | |
| 5027 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5028 | |
| 5029 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5030 | |
| 5031 | |
| 5032 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5033 | class PlanetStackPrivilegeList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5034 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 5035 | serializer_class = PlanetStackPrivilegeSerializer |
| 5036 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 5037 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5038 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5039 | |
| 5040 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5041 | no_hyperlinks=False |
| 5042 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5043 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5044 | if (no_hyperlinks): |
| 5045 | return self.id_serializer_class |
| 5046 | else: |
| 5047 | return self.serializer_class |
| 5048 | |
| 5049 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5050 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5051 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5052 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 5053 | |
| 5054 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5055 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5056 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5057 | response = {"error": "validation", |
| 5058 | "specific_error": "not serializer.is_valid()",
|
| 5059 | "reasons": serializer.errors}
|
| 5060 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5061 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5062 | obj.caller = request.user |
| 5063 | if obj.can_update(request.user): |
| 5064 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 5065 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5066 | raise Exception("failed obj.can_update") |
| 5067 | |
| 5068 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 5069 | if (ret.status_code%100 != 200): |
| 5070 | raise Exception(ret.data) |
| 5071 | |
| 5072 | return ret |
| 5073 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5074 | |
| 5075 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5076 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 5077 | serializer_class = PlanetStackPrivilegeSerializer |
| 5078 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 5079 | |
| 5080 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5081 | no_hyperlinks=False |
| 5082 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5083 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5084 | if (no_hyperlinks): |
| 5085 | return self.id_serializer_class |
| 5086 | else: |
| 5087 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5088 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5089 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5090 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5091 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5092 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 5093 | |
| 5094 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5095 | |
| 5096 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5097 | |
| 5098 | |
| 5099 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5100 | class UserList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5101 | queryset = User.objects.select_related().all() |
| 5102 | serializer_class = UserSerializer |
| 5103 | id_serializer_class = UserIdSerializer |
| 5104 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5105 | filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5106 | |
| 5107 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5108 | no_hyperlinks=False |
| 5109 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5110 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5111 | if (no_hyperlinks): |
| 5112 | return self.id_serializer_class |
| 5113 | else: |
| 5114 | return self.serializer_class |
| 5115 | |
| 5116 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5117 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5118 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5119 | return User.select_by_user(self.request.user) |
| 5120 | |
| 5121 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5122 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5123 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5124 | response = {"error": "validation", |
| 5125 | "specific_error": "not serializer.is_valid()",
|
| 5126 | "reasons": serializer.errors}
|
| 5127 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5128 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5129 | obj.caller = request.user |
| 5130 | if obj.can_update(request.user): |
| 5131 | return super(UserList, self).create(request, *args, **kwargs) |
| 5132 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5133 | raise Exception("failed obj.can_update") |
| 5134 | |
| 5135 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 5136 | if (ret.status_code%100 != 200): |
| 5137 | raise Exception(ret.data) |
| 5138 | |
| 5139 | return ret |
| 5140 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5141 | |
| 5142 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5143 | queryset = User.objects.select_related().all() |
| 5144 | serializer_class = UserSerializer |
| 5145 | id_serializer_class = UserIdSerializer |
| 5146 | |
| 5147 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5148 | no_hyperlinks=False |
| 5149 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5150 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5151 | if (no_hyperlinks): |
| 5152 | return self.id_serializer_class |
| 5153 | else: |
| 5154 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5155 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5156 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5157 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5158 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5159 | return User.select_by_user(self.request.user) |
| 5160 | |
| 5161 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5162 | |
| 5163 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5164 | |
| 5165 | |
| 5166 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5167 | class DeploymentList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5168 | queryset = Deployment.objects.select_related().all() |
| 5169 | serializer_class = DeploymentSerializer |
| 5170 | id_serializer_class = DeploymentIdSerializer |
| 5171 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5172 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5173 | |
| 5174 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5175 | no_hyperlinks=False |
| 5176 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5177 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5178 | if (no_hyperlinks): |
| 5179 | return self.id_serializer_class |
| 5180 | else: |
| 5181 | return self.serializer_class |
| 5182 | |
| 5183 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5184 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5185 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5186 | return Deployment.select_by_user(self.request.user) |
| 5187 | |
| 5188 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5189 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5190 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5191 | response = {"error": "validation", |
| 5192 | "specific_error": "not serializer.is_valid()",
|
| 5193 | "reasons": serializer.errors}
|
| 5194 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5195 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5196 | obj.caller = request.user |
| 5197 | if obj.can_update(request.user): |
| 5198 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 5199 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5200 | raise Exception("failed obj.can_update") |
| 5201 | |
| 5202 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 5203 | if (ret.status_code%100 != 200): |
| 5204 | raise Exception(ret.data) |
| 5205 | |
| 5206 | return ret |
| 5207 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5208 | |
| 5209 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5210 | queryset = Deployment.objects.select_related().all() |
| 5211 | serializer_class = DeploymentSerializer |
| 5212 | id_serializer_class = DeploymentIdSerializer |
| 5213 | |
| 5214 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5215 | no_hyperlinks=False |
| 5216 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5217 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5218 | if (no_hyperlinks): |
| 5219 | return self.id_serializer_class |
| 5220 | else: |
| 5221 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5222 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5223 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5224 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5225 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5226 | return Deployment.select_by_user(self.request.user) |
| 5227 | |
| 5228 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5229 | |
| 5230 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5231 | |
| 5232 | |
| 5233 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5234 | class ReservationList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5235 | queryset = Reservation.objects.select_related().all() |
| 5236 | serializer_class = ReservationSerializer |
| 5237 | id_serializer_class = ReservationIdSerializer |
| 5238 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5239 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5240 | |
| 5241 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5242 | no_hyperlinks=False |
| 5243 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5244 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5245 | if (no_hyperlinks): |
| 5246 | return self.id_serializer_class |
| 5247 | else: |
| 5248 | return self.serializer_class |
| 5249 | |
| 5250 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5251 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5252 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5253 | return Reservation.select_by_user(self.request.user) |
| 5254 | |
| 5255 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5256 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5257 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5258 | response = {"error": "validation", |
| 5259 | "specific_error": "not serializer.is_valid()",
|
| 5260 | "reasons": serializer.errors}
|
| 5261 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5262 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5263 | obj.caller = request.user |
| 5264 | if obj.can_update(request.user): |
| 5265 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 5266 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5267 | raise Exception("failed obj.can_update") |
| 5268 | |
| 5269 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 5270 | if (ret.status_code%100 != 200): |
| 5271 | raise Exception(ret.data) |
| 5272 | |
| 5273 | return ret |
| 5274 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5275 | |
| 5276 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5277 | queryset = Reservation.objects.select_related().all() |
| 5278 | serializer_class = ReservationSerializer |
| 5279 | id_serializer_class = ReservationIdSerializer |
| 5280 | |
| 5281 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5282 | no_hyperlinks=False |
| 5283 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5284 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5285 | if (no_hyperlinks): |
| 5286 | return self.id_serializer_class |
| 5287 | else: |
| 5288 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5289 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5290 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5291 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5292 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5293 | return Reservation.select_by_user(self.request.user) |
| 5294 | |
| 5295 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5296 | |
| 5297 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5298 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5299 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5300 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5301 | class SitePrivilegeList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5302 | queryset = SitePrivilege.objects.select_related().all() |
| 5303 | serializer_class = SitePrivilegeSerializer |
| 5304 | id_serializer_class = SitePrivilegeIdSerializer |
| 5305 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5306 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5307 | |
| 5308 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5309 | no_hyperlinks=False |
| 5310 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5311 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5312 | if (no_hyperlinks): |
| 5313 | return self.id_serializer_class |
| 5314 | else: |
| 5315 | return self.serializer_class |
| 5316 | |
| 5317 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5318 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5319 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5320 | return SitePrivilege.select_by_user(self.request.user) |
| 5321 | |
| 5322 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5323 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5324 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5325 | response = {"error": "validation", |
| 5326 | "specific_error": "not serializer.is_valid()",
|
| 5327 | "reasons": serializer.errors}
|
| 5328 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5329 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5330 | obj.caller = request.user |
| 5331 | if obj.can_update(request.user): |
| 5332 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 5333 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5334 | raise Exception("failed obj.can_update") |
| 5335 | |
| 5336 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 5337 | if (ret.status_code%100 != 200): |
| 5338 | raise Exception(ret.data) |
| 5339 | |
| 5340 | return ret |
| 5341 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5342 | |
| 5343 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5344 | queryset = SitePrivilege.objects.select_related().all() |
| 5345 | serializer_class = SitePrivilegeSerializer |
| 5346 | id_serializer_class = SitePrivilegeIdSerializer |
| 5347 | |
| 5348 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5349 | no_hyperlinks=False |
| 5350 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5351 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5352 | if (no_hyperlinks): |
| 5353 | return self.id_serializer_class |
| 5354 | else: |
| 5355 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5356 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5357 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5358 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5359 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5360 | return SitePrivilege.select_by_user(self.request.user) |
| 5361 | |
| 5362 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5363 | |
| 5364 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5365 | |
| 5366 | |
| 5367 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5368 | class ControllerSliceList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5369 | queryset = ControllerSlice.objects.select_related().all() |
| 5370 | serializer_class = ControllerSliceSerializer |
| 5371 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5372 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5373 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5374 | |
| 5375 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5376 | no_hyperlinks=False |
| 5377 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5378 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5379 | if (no_hyperlinks): |
| 5380 | return self.id_serializer_class |
| 5381 | else: |
| 5382 | return self.serializer_class |
| 5383 | |
| 5384 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5385 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5386 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5387 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5388 | |
| 5389 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5390 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5391 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5392 | response = {"error": "validation", |
| 5393 | "specific_error": "not serializer.is_valid()",
|
| 5394 | "reasons": serializer.errors}
|
| 5395 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5396 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5397 | obj.caller = request.user |
| 5398 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5399 | return super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5400 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5401 | raise Exception("failed obj.can_update") |
| 5402 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5403 | ret = super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5404 | if (ret.status_code%100 != 200): |
| 5405 | raise Exception(ret.data) |
| 5406 | |
| 5407 | return ret |
| 5408 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5409 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5410 | class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5411 | queryset = ControllerSlice.objects.select_related().all() |
| 5412 | serializer_class = ControllerSliceSerializer |
| 5413 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5414 | |
| 5415 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5416 | no_hyperlinks=False |
| 5417 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5418 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5419 | if (no_hyperlinks): |
| 5420 | return self.id_serializer_class |
| 5421 | else: |
| 5422 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5423 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5424 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5425 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5426 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5427 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5428 | |
| 5429 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5430 | |
| 5431 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5432 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5433 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5434 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5435 | class ControllerDashboardViewList(PlanetStackListCreateAPIView): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5436 | queryset = ControllerDashboardView.objects.select_related().all() |
| 5437 | serializer_class = ControllerDashboardViewSerializer |
| 5438 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 5439 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5440 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5441 | |
| 5442 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5443 | no_hyperlinks=False |
| 5444 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5445 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5446 | if (no_hyperlinks): |
| 5447 | return self.id_serializer_class |
| 5448 | else: |
| 5449 | return self.serializer_class |
| 5450 | |
| 5451 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5452 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5453 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5454 | return ControllerDashboardView.select_by_user(self.request.user) |
| 5455 | |
| 5456 | def create(self, request, *args, **kwargs): |
| 5457 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5458 | if not (serializer.is_valid()): |
| 5459 | response = {"error": "validation", |
| 5460 | "specific_error": "not serializer.is_valid()",
|
| 5461 | "reasons": serializer.errors}
|
| 5462 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5463 | obj = serializer.object |
| 5464 | obj.caller = request.user |
| 5465 | if obj.can_update(request.user): |
| 5466 | return super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 5467 | else: |
| 5468 | raise Exception("failed obj.can_update") |
| 5469 | |
| 5470 | ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 5471 | if (ret.status_code%100 != 200): |
| 5472 | raise Exception(ret.data) |
| 5473 | |
| 5474 | return ret |
| 5475 | |
| 5476 | |
| 5477 | class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5478 | queryset = ControllerDashboardView.objects.select_related().all() |
| 5479 | serializer_class = ControllerDashboardViewSerializer |
| 5480 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 5481 | |
| 5482 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5483 | no_hyperlinks=False |
| 5484 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5485 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5486 | if (no_hyperlinks): |
| 5487 | return self.id_serializer_class |
| 5488 | else: |
| 5489 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5490 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5491 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5492 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5493 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5494 | return ControllerDashboardView.select_by_user(self.request.user) |
| 5495 | |
| 5496 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5497 | |
| 5498 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5499 | |
| 5500 | |
| 5501 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5502 | class AccountList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5503 | queryset = Account.objects.select_related().all() |
| 5504 | serializer_class = AccountSerializer |
| 5505 | id_serializer_class = AccountIdSerializer |
| 5506 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5507 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5508 | |
| 5509 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5510 | no_hyperlinks=False |
| 5511 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5512 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5513 | if (no_hyperlinks): |
| 5514 | return self.id_serializer_class |
| 5515 | else: |
| 5516 | return self.serializer_class |
| 5517 | |
| 5518 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5519 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5520 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5521 | return Account.select_by_user(self.request.user) |
| 5522 | |
| 5523 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5524 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5525 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5526 | response = {"error": "validation", |
| 5527 | "specific_error": "not serializer.is_valid()",
|
| 5528 | "reasons": serializer.errors}
|
| 5529 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5530 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5531 | obj.caller = request.user |
| 5532 | if obj.can_update(request.user): |
| 5533 | return super(AccountList, self).create(request, *args, **kwargs) |
| 5534 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5535 | raise Exception("failed obj.can_update") |
| 5536 | |
| 5537 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 5538 | if (ret.status_code%100 != 200): |
| 5539 | raise Exception(ret.data) |
| 5540 | |
| 5541 | return ret |
| 5542 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5543 | |
| 5544 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5545 | queryset = Account.objects.select_related().all() |
| 5546 | serializer_class = AccountSerializer |
| 5547 | id_serializer_class = AccountIdSerializer |
| 5548 | |
| 5549 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5550 | no_hyperlinks=False |
| 5551 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5552 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5553 | if (no_hyperlinks): |
| 5554 | return self.id_serializer_class |
| 5555 | else: |
| 5556 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5557 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5558 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5559 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5560 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5561 | return Account.select_by_user(self.request.user) |
| 5562 | |
| 5563 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5564 | |
| 5565 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5566 | |
| 5567 | |
| 5568 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5569 | class ControllerRoleList(PlanetStackListCreateAPIView): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5570 | queryset = ControllerRole.objects.select_related().all() |
| 5571 | serializer_class = ControllerRoleSerializer |
| 5572 | id_serializer_class = ControllerRoleIdSerializer |
| 5573 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5574 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5575 | |
| 5576 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5577 | no_hyperlinks=False |
| 5578 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5579 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5580 | if (no_hyperlinks): |
| 5581 | return self.id_serializer_class |
| 5582 | else: |
| 5583 | return self.serializer_class |
| 5584 | |
| 5585 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5586 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5587 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5588 | return ControllerRole.select_by_user(self.request.user) |
| 5589 | |
| 5590 | def create(self, request, *args, **kwargs): |
| 5591 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5592 | if not (serializer.is_valid()): |
| 5593 | response = {"error": "validation", |
| 5594 | "specific_error": "not serializer.is_valid()",
|
| 5595 | "reasons": serializer.errors}
|
| 5596 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5597 | obj = serializer.object |
| 5598 | obj.caller = request.user |
| 5599 | if obj.can_update(request.user): |
| 5600 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5601 | else: |
| 5602 | raise Exception("failed obj.can_update") |
| 5603 | |
| 5604 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5605 | if (ret.status_code%100 != 200): |
| 5606 | raise Exception(ret.data) |
| 5607 | |
| 5608 | return ret |
| 5609 | |
| 5610 | |
| 5611 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5612 | queryset = ControllerRole.objects.select_related().all() |
| 5613 | serializer_class = ControllerRoleSerializer |
| 5614 | id_serializer_class = ControllerRoleIdSerializer |
| 5615 | |
| 5616 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5617 | no_hyperlinks=False |
| 5618 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5619 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5620 | if (no_hyperlinks): |
| 5621 | return self.id_serializer_class |
| 5622 | else: |
| 5623 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5624 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5625 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5626 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5627 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5628 | return ControllerRole.select_by_user(self.request.user) |
| 5629 | |
| 5630 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5631 | |
| 5632 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5633 | |
| 5634 | |
| 5635 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5636 | class NetworkParameterTypeList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5637 | queryset = NetworkParameterType.objects.select_related().all() |
| 5638 | serializer_class = NetworkParameterTypeSerializer |
| 5639 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5640 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5641 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5642 | |
| 5643 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5644 | no_hyperlinks=False |
| 5645 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5646 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5647 | if (no_hyperlinks): |
| 5648 | return self.id_serializer_class |
| 5649 | else: |
| 5650 | return self.serializer_class |
| 5651 | |
| 5652 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5653 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5654 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5655 | return NetworkParameterType.select_by_user(self.request.user) |
| 5656 | |
| 5657 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5658 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5659 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5660 | response = {"error": "validation", |
| 5661 | "specific_error": "not serializer.is_valid()",
|
| 5662 | "reasons": serializer.errors}
|
| 5663 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5664 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5665 | obj.caller = request.user |
| 5666 | if obj.can_update(request.user): |
| 5667 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5668 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5669 | raise Exception("failed obj.can_update") |
| 5670 | |
| 5671 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5672 | if (ret.status_code%100 != 200): |
| 5673 | raise Exception(ret.data) |
| 5674 | |
| 5675 | return ret |
| 5676 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5677 | |
| 5678 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5679 | queryset = NetworkParameterType.objects.select_related().all() |
| 5680 | serializer_class = NetworkParameterTypeSerializer |
| 5681 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5682 | |
| 5683 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5684 | no_hyperlinks=False |
| 5685 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5686 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5687 | if (no_hyperlinks): |
| 5688 | return self.id_serializer_class |
| 5689 | else: |
| 5690 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5691 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5692 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5693 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5694 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5695 | return NetworkParameterType.select_by_user(self.request.user) |
| 5696 | |
| 5697 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5698 | |
| 5699 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5700 | |
| 5701 | |
| 5702 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5703 | class SiteCredentialList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5704 | queryset = SiteCredential.objects.select_related().all() |
| 5705 | serializer_class = SiteCredentialSerializer |
| 5706 | id_serializer_class = SiteCredentialIdSerializer |
| 5707 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5708 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5709 | |
| 5710 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5711 | no_hyperlinks=False |
| 5712 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5713 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5714 | if (no_hyperlinks): |
| 5715 | return self.id_serializer_class |
| 5716 | else: |
| 5717 | return self.serializer_class |
| 5718 | |
| 5719 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5720 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5721 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5722 | return SiteCredential.select_by_user(self.request.user) |
| 5723 | |
| 5724 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5725 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5726 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5727 | response = {"error": "validation", |
| 5728 | "specific_error": "not serializer.is_valid()",
|
| 5729 | "reasons": serializer.errors}
|
| 5730 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5731 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5732 | obj.caller = request.user |
| 5733 | if obj.can_update(request.user): |
| 5734 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5735 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5736 | raise Exception("failed obj.can_update") |
| 5737 | |
| 5738 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5739 | if (ret.status_code%100 != 200): |
| 5740 | raise Exception(ret.data) |
| 5741 | |
| 5742 | return ret |
| 5743 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5744 | |
| 5745 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5746 | queryset = SiteCredential.objects.select_related().all() |
| 5747 | serializer_class = SiteCredentialSerializer |
| 5748 | id_serializer_class = SiteCredentialIdSerializer |
| 5749 | |
| 5750 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5751 | no_hyperlinks=False |
| 5752 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5753 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5754 | if (no_hyperlinks): |
| 5755 | return self.id_serializer_class |
| 5756 | else: |
| 5757 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5758 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5759 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5760 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5761 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5762 | return SiteCredential.select_by_user(self.request.user) |
| 5763 | |
| 5764 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5765 | |
| 5766 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5767 | |
| 5768 | |
| 5769 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5770 | class DeploymentPrivilegeList(PlanetStackListCreateAPIView): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5771 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5772 | serializer_class = DeploymentPrivilegeSerializer |
| 5773 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5774 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5775 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5776 | |
| 5777 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5778 | no_hyperlinks=False |
| 5779 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5780 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5781 | if (no_hyperlinks): |
| 5782 | return self.id_serializer_class |
| 5783 | else: |
| 5784 | return self.serializer_class |
| 5785 | |
| 5786 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5787 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5788 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5789 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5790 | |
| 5791 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5792 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5793 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5794 | response = {"error": "validation", |
| 5795 | "specific_error": "not serializer.is_valid()",
|
| 5796 | "reasons": serializer.errors}
|
| 5797 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5798 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5799 | obj.caller = request.user |
| 5800 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5801 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5802 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5803 | raise Exception("failed obj.can_update") |
| 5804 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5805 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5806 | if (ret.status_code%100 != 200): |
| 5807 | raise Exception(ret.data) |
| 5808 | |
| 5809 | return ret |
| 5810 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5811 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5812 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5813 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5814 | serializer_class = DeploymentPrivilegeSerializer |
| 5815 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5816 | |
| 5817 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5818 | no_hyperlinks=False |
| 5819 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5820 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5821 | if (no_hyperlinks): |
| 5822 | return self.id_serializer_class |
| 5823 | else: |
| 5824 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5825 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5826 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5827 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5828 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5829 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5830 | |
| 5831 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5832 | |
| 5833 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5834 | |
| 5835 | |
| 5836 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5837 | class ControllerSlicePrivilegeList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5838 | queryset = ControllerSlicePrivilege.objects.select_related().all() |
| 5839 | serializer_class = ControllerSlicePrivilegeSerializer |
| 5840 | id_serializer_class = ControllerSlicePrivilegeIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5841 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5842 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5843 | |
| 5844 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5845 | no_hyperlinks=False |
| 5846 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5847 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5848 | if (no_hyperlinks): |
| 5849 | return self.id_serializer_class |
| 5850 | else: |
| 5851 | return self.serializer_class |
| 5852 | |
| 5853 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5854 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5855 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5856 | return ControllerSlicePrivilege.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5857 | |
| 5858 | def create(self, request, *args, **kwargs): |
| 5859 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5860 | if not (serializer.is_valid()): |
| 5861 | response = {"error": "validation", |
| 5862 | "specific_error": "not serializer.is_valid()",
|
| 5863 | "reasons": serializer.errors}
|
| 5864 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5865 | obj = serializer.object |
| 5866 | obj.caller = request.user |
| 5867 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5868 | return super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5869 | else: |
| 5870 | raise Exception("failed obj.can_update") |
| 5871 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5872 | ret = super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5873 | if (ret.status_code%100 != 200): |
| 5874 | raise Exception(ret.data) |
| 5875 | |
| 5876 | return ret |
| 5877 | |
| 5878 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5879 | class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5880 | queryset = ControllerSlicePrivilege.objects.select_related().all() |
| 5881 | serializer_class = ControllerSlicePrivilegeSerializer |
| 5882 | id_serializer_class = ControllerSlicePrivilegeIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5883 | |
| 5884 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5885 | no_hyperlinks=False |
| 5886 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5887 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5888 | if (no_hyperlinks): |
| 5889 | return self.id_serializer_class |
| 5890 | else: |
| 5891 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5892 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5893 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5894 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5895 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5896 | return ControllerSlicePrivilege.select_by_user(self.request.user) |
| 5897 | |
| 5898 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5899 | |
| 5900 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5901 | |
| 5902 | |
| 5903 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5904 | class SiteDeploymentList(PlanetStackListCreateAPIView): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5905 | queryset = SiteDeployment.objects.select_related().all() |
| 5906 | serializer_class = SiteDeploymentSerializer |
| 5907 | id_serializer_class = SiteDeploymentIdSerializer |
| 5908 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5909 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5910 | |
| 5911 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5912 | no_hyperlinks=False |
| 5913 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5914 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5915 | if (no_hyperlinks): |
| 5916 | return self.id_serializer_class |
| 5917 | else: |
| 5918 | return self.serializer_class |
| 5919 | |
| 5920 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5921 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5922 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5923 | return SiteDeployment.select_by_user(self.request.user) |
| 5924 | |
| 5925 | def create(self, request, *args, **kwargs): |
| 5926 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5927 | if not (serializer.is_valid()): |
| 5928 | response = {"error": "validation", |
| 5929 | "specific_error": "not serializer.is_valid()",
|
| 5930 | "reasons": serializer.errors}
|
| 5931 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5932 | obj = serializer.object |
| 5933 | obj.caller = request.user |
| 5934 | if obj.can_update(request.user): |
| 5935 | return super(SiteDeploymentList, self).create(request, *args, **kwargs) |
| 5936 | else: |
| 5937 | raise Exception("failed obj.can_update") |
| 5938 | |
| 5939 | ret = super(SiteDeploymentList, self).create(request, *args, **kwargs) |
| 5940 | if (ret.status_code%100 != 200): |
| 5941 | raise Exception(ret.data) |
| 5942 | |
| 5943 | return ret |
| 5944 | |
| 5945 | |
| 5946 | class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5947 | queryset = SiteDeployment.objects.select_related().all() |
| 5948 | serializer_class = SiteDeploymentSerializer |
| 5949 | id_serializer_class = SiteDeploymentIdSerializer |
| 5950 | |
| 5951 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5952 | no_hyperlinks=False |
| 5953 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5954 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5955 | if (no_hyperlinks): |
| 5956 | return self.id_serializer_class |
| 5957 | else: |
| 5958 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5959 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5960 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5961 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5962 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5963 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5964 | |
| 5965 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5966 | |
| 5967 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5968 | |
| 5969 | |
| 5970 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 5971 | class DeploymentRoleList(PlanetStackListCreateAPIView): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5972 | queryset = DeploymentRole.objects.select_related().all() |
| 5973 | serializer_class = DeploymentRoleSerializer |
| 5974 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5975 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5976 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5977 | |
| 5978 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5979 | no_hyperlinks=False |
| 5980 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5981 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5982 | if (no_hyperlinks): |
| 5983 | return self.id_serializer_class |
| 5984 | else: |
| 5985 | return self.serializer_class |
| 5986 | |
| 5987 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5988 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 5989 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5990 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5991 | |
| 5992 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5993 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5994 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5995 | response = {"error": "validation", |
| 5996 | "specific_error": "not serializer.is_valid()",
|
| 5997 | "reasons": serializer.errors}
|
| 5998 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5999 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6000 | obj.caller = request.user |
| 6001 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 6002 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6003 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6004 | raise Exception("failed obj.can_update") |
| 6005 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 6006 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6007 | if (ret.status_code%100 != 200): |
| 6008 | raise Exception(ret.data) |
| 6009 | |
| 6010 | return ret |
| 6011 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6012 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 6013 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 6014 | queryset = DeploymentRole.objects.select_related().all() |
| 6015 | serializer_class = DeploymentRoleSerializer |
| 6016 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6017 | |
| 6018 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6019 | no_hyperlinks=False |
| 6020 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6021 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6022 | if (no_hyperlinks): |
| 6023 | return self.id_serializer_class |
| 6024 | else: |
| 6025 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6026 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6027 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6028 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6029 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 6030 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6031 | |
| 6032 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 6033 | |
| 6034 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 6035 | |
| 6036 | |
| 6037 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 6038 | class UserCredentialList(PlanetStackListCreateAPIView): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6039 | queryset = UserCredential.objects.select_related().all() |
| 6040 | serializer_class = UserCredentialSerializer |
| 6041 | id_serializer_class = UserCredentialIdSerializer |
| 6042 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6043 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6044 | |
| 6045 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6046 | no_hyperlinks=False |
| 6047 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6048 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6049 | if (no_hyperlinks): |
| 6050 | return self.id_serializer_class |
| 6051 | else: |
| 6052 | return self.serializer_class |
| 6053 | |
| 6054 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6055 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6056 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6057 | return UserCredential.select_by_user(self.request.user) |
| 6058 | |
| 6059 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6060 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6061 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6062 | response = {"error": "validation", |
| 6063 | "specific_error": "not serializer.is_valid()",
|
| 6064 | "reasons": serializer.errors}
|
| 6065 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6066 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6067 | obj.caller = request.user |
| 6068 | if obj.can_update(request.user): |
| 6069 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 6070 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6071 | raise Exception("failed obj.can_update") |
| 6072 | |
| 6073 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 6074 | if (ret.status_code%100 != 200): |
| 6075 | raise Exception(ret.data) |
| 6076 | |
| 6077 | return ret |
| 6078 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6079 | |
| 6080 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 6081 | queryset = UserCredential.objects.select_related().all() |
| 6082 | serializer_class = UserCredentialSerializer |
| 6083 | id_serializer_class = UserCredentialIdSerializer |
| 6084 | |
| 6085 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6086 | no_hyperlinks=False |
| 6087 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6088 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6089 | if (no_hyperlinks): |
| 6090 | return self.id_serializer_class |
| 6091 | else: |
| 6092 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6093 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6094 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6095 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6096 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6097 | return UserCredential.select_by_user(self.request.user) |
| 6098 | |
| 6099 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 6100 | |
| 6101 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 6102 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6103 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6104 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 6105 | class SliceTagList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6106 | queryset = SliceTag.objects.select_related().all() |
| 6107 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6108 | id_serializer_class = SliceTagIdSerializer |
| 6109 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6110 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6111 | |
| 6112 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6113 | no_hyperlinks=False |
| 6114 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6115 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6116 | if (no_hyperlinks): |
| 6117 | return self.id_serializer_class |
| 6118 | else: |
| 6119 | return self.serializer_class |
| 6120 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6121 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6122 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6123 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6124 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6125 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6126 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6127 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6128 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6129 | response = {"error": "validation", |
| 6130 | "specific_error": "not serializer.is_valid()",
|
| 6131 | "reasons": serializer.errors}
|
| 6132 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6133 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6134 | obj.caller = request.user |
| 6135 | if obj.can_update(request.user): |
| 6136 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 6137 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6138 | raise Exception("failed obj.can_update") |
| 6139 | |
| 6140 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 6141 | if (ret.status_code%100 != 200): |
| 6142 | raise Exception(ret.data) |
| 6143 | |
| 6144 | return ret |
| 6145 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6146 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6147 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6148 | queryset = SliceTag.objects.select_related().all() |
| 6149 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6150 | id_serializer_class = SliceTagIdSerializer |
| 6151 | |
| 6152 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6153 | no_hyperlinks=False |
| 6154 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6155 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6156 | if (no_hyperlinks): |
| 6157 | return self.id_serializer_class |
| 6158 | else: |
| 6159 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6160 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6161 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6162 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6163 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6164 | return SliceTag.select_by_user(self.request.user) |
| 6165 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6166 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6167 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6168 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6169 | |
| 6170 | |
| 6171 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 6172 | class NetworkTemplateList(PlanetStackListCreateAPIView): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6173 | queryset = NetworkTemplate.objects.select_related().all() |
| 6174 | serializer_class = NetworkTemplateSerializer |
| 6175 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6176 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6177 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6178 | |
| 6179 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6180 | no_hyperlinks=False |
| 6181 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6182 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6183 | if (no_hyperlinks): |
| 6184 | return self.id_serializer_class |
| 6185 | else: |
| 6186 | return self.serializer_class |
| 6187 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6188 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6189 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6190 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6191 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6192 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6193 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6194 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6195 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6196 | response = {"error": "validation", |
| 6197 | "specific_error": "not serializer.is_valid()",
|
| 6198 | "reasons": serializer.errors}
|
| 6199 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6200 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6201 | obj.caller = request.user |
| 6202 | if obj.can_update(request.user): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6203 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6204 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6205 | raise Exception("failed obj.can_update") |
| 6206 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6207 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6208 | if (ret.status_code%100 != 200): |
| 6209 | raise Exception(ret.data) |
| 6210 | |
| 6211 | return ret |
| 6212 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6213 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6214 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 6215 | queryset = NetworkTemplate.objects.select_related().all() |
| 6216 | serializer_class = NetworkTemplateSerializer |
| 6217 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6218 | |
| 6219 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6220 | no_hyperlinks=False |
| 6221 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6222 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6223 | if (no_hyperlinks): |
| 6224 | return self.id_serializer_class |
| 6225 | else: |
| 6226 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6227 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6228 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6229 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6230 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6231 | return NetworkTemplate.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6232 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6233 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6234 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6235 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6236 | |
| 6237 | |
| 6238 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 6239 | class RouterList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6240 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6241 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6242 | id_serializer_class = RouterIdSerializer |
| 6243 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6244 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6245 | |
| 6246 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6247 | no_hyperlinks=False |
| 6248 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6249 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6250 | if (no_hyperlinks): |
| 6251 | return self.id_serializer_class |
| 6252 | else: |
| 6253 | return self.serializer_class |
| 6254 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6255 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6256 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6257 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6258 | return Router.select_by_user(self.request.user) |
| 6259 | |
| 6260 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6261 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6262 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6263 | response = {"error": "validation", |
| 6264 | "specific_error": "not serializer.is_valid()",
|
| 6265 | "reasons": serializer.errors}
|
| 6266 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6267 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6268 | obj.caller = request.user |
| 6269 | if obj.can_update(request.user): |
| 6270 | return super(RouterList, self).create(request, *args, **kwargs) |
| 6271 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6272 | raise Exception("failed obj.can_update") |
| 6273 | |
| 6274 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 6275 | if (ret.status_code%100 != 200): |
| 6276 | raise Exception(ret.data) |
| 6277 | |
| 6278 | return ret |
| 6279 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6280 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6281 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6282 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6283 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6284 | id_serializer_class = RouterIdSerializer |
| 6285 | |
| 6286 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6287 | no_hyperlinks=False |
| 6288 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6289 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6290 | if (no_hyperlinks): |
| 6291 | return self.id_serializer_class |
| 6292 | else: |
| 6293 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6294 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6295 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6296 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6297 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6298 | return Router.select_by_user(self.request.user) |
| 6299 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6300 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6301 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6302 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6303 | |
| 6304 | |
| 6305 | |
Scott Baker | 15af565 | 2015-02-02 14:33:08 -0800 | [diff] [blame] | 6306 | class ServiceResourceList(PlanetStackListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6307 | queryset = ServiceResource.objects.select_related().all() |
| 6308 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6309 | id_serializer_class = ServiceResourceIdSerializer |
| 6310 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6311 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6312 | |
| 6313 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6314 | no_hyperlinks=False |
| 6315 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6316 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6317 | if (no_hyperlinks): |
| 6318 | return self.id_serializer_class |
| 6319 | else: |
| 6320 | return self.serializer_class |
| 6321 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6322 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6323 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6324 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6325 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6326 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6327 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6328 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6329 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6330 | response = {"error": "validation", |
| 6331 | "specific_error": "not serializer.is_valid()",
|
| 6332 | "reasons": serializer.errors}
|
| 6333 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6334 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6335 | obj.caller = request.user |
| 6336 | if obj.can_update(request.user): |
| 6337 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 6338 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6339 | raise Exception("failed obj.can_update") |
| 6340 | |
| 6341 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 6342 | if (ret.status_code%100 != 200): |
| 6343 | raise Exception(ret.data) |
| 6344 | |
| 6345 | return ret |
| 6346 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6347 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6348 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6349 | queryset = ServiceResource.objects.select_related().all() |
| 6350 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6351 | id_serializer_class = ServiceResourceIdSerializer |
| 6352 | |
| 6353 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6354 | no_hyperlinks=False |
| 6355 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6356 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6357 | if (no_hyperlinks): |
| 6358 | return self.id_serializer_class |
| 6359 | else: |
| 6360 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6361 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6362 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6363 | if (not self.request.user.is_authenticated()): |
Scott Baker | 4af864e | 2015-02-02 13:53:46 -0800 | [diff] [blame] | 6364 | raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6365 | return ServiceResource.select_by_user(self.request.user) |
| 6366 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6367 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6368 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6369 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6370 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6371 | |
| 6372 | |