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 |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 12 | |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 13 | if hasattr(serializers, "ReadOnlyField"): |
| 14 | # rest_framework 3.x |
| 15 | IdField = serializers.ReadOnlyField |
| 16 | else: |
| 17 | # rest_framework 2.x |
| 18 | IdField = serializers.Field |
| 19 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 20 | """ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 21 | Schema of the generator object: |
| 22 | all: Set of all Model objects |
| 23 | all_if(regex): Set of Model objects that match regex |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 24 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 25 | Model object: |
| 26 | plural: English plural of object name |
| 27 | camel: CamelCase version of object name |
| 28 | refs: list of references to other Model objects |
| 29 | props: list of properties minus refs |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 30 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 31 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 32 | """ |
| 33 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 34 | def get_REST_patterns(): |
| 35 | return patterns('', |
| 36 | url(r'^plstackapi/$', api_root), |
| 37 | |
| 38 | url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 39 | url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
| 40 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 41 | url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'), |
| 42 | url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'), |
| 43 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 44 | url(r'plstackapi/controllersiteprivileges/$', ControllerSitePrivilegeList.as_view(), name='controllersiteprivilege-list'), |
| 45 | url(r'plstackapi/controllersiteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSitePrivilegeDetail.as_view(), name ='controllersiteprivilege-detail'), |
| 46 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 47 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 48 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
| 49 | |
| 50 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 51 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
| 52 | |
| 53 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 54 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
| 55 | |
| 56 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 57 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
| 58 | |
| 59 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 60 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
| 61 | |
| 62 | url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 63 | url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
| 64 | |
| 65 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 66 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
| 67 | |
| 68 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 69 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
| 70 | |
| 71 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 72 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
| 73 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 74 | url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 75 | url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
| 76 | |
| 77 | url(r'plstackapi/controllersites/$', ControllerSiteList.as_view(), name='controllersite-list'), |
| 78 | url(r'plstackapi/controllersites/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDetail.as_view(), name ='controllersite-detail'), |
| 79 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 80 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 81 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 82 | |
| 83 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 84 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 85 | |
| 86 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 87 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 88 | |
| 89 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 90 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 91 | |
| 92 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 93 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 94 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 95 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 96 | url(r'plstackapi/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] | 97 | |
| 98 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 99 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 100 | |
| 101 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 102 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 103 | |
| 104 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 105 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 106 | |
| 107 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 108 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 109 | |
| 110 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 111 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 112 | |
| 113 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 114 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 115 | |
| 116 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 117 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 118 | |
| 119 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 120 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 121 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 122 | url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetwork-list'), |
| 123 | url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetwork-detail'), |
| 124 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 125 | url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 126 | url(r'plstackapi/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] | 127 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 128 | url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controlleruser-list'), |
| 129 | url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controlleruser-detail'), |
| 130 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 131 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 132 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 133 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 134 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 135 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 136 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 137 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 138 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 139 | |
| 140 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 141 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 142 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 143 | url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'), |
| 144 | url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
| 145 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 146 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 147 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 148 | |
| 149 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 150 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 151 | |
| 152 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 153 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
| 154 | |
| 155 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 156 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 157 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 158 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 159 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 160 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 161 | url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslice-list'), |
| 162 | url(r'plstackapi/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] | 163 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 164 | url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'), |
| 165 | url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'), |
| 166 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 167 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 168 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 169 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 170 | url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 171 | url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
| 172 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 173 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 174 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 175 | |
| 176 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 177 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 178 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 179 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 180 | url(r'plstackapi/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] | 181 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 182 | url(r'plstackapi/controllersliceprivileges/$', ControllerSlicePrivilegeList.as_view(), name='controllersliceprivilege-list'), |
| 183 | url(r'plstackapi/controllersliceprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicePrivilegeDetail.as_view(), name ='controllersliceprivilege-detail'), |
| 184 | |
| 185 | url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployment-list'), |
| 186 | url(r'plstackapi/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] | 187 | |
| 188 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 189 | url(r'plstackapi/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] | 190 | |
| 191 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 192 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 193 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 194 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 195 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 196 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 197 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 198 | url(r'plstackapi/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] | 199 | |
| 200 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 201 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 202 | |
| 203 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 204 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 205 | |
| 206 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 207 | |
| 208 | @api_view(['GET']) |
| 209 | def api_root(request, format=None): |
| 210 | return Response({ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 211 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 212 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 213 | 'controllersiteprivileges': reverse('controllersiteprivilege-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 214 | 'images': reverse('image-list', request=request, format=format), |
| 215 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 216 | 'sites': reverse('site-list', request=request, format=format), |
| 217 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 218 | 'tags': reverse('tag-list', request=request, format=format), |
| 219 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 220 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 221 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
| 222 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 223 | 'flavors': reverse('flavor-list', request=request, format=format), |
| 224 | 'controllersites': reverse('controllersite-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 225 | 'projects': reverse('project-list', request=request, format=format), |
| 226 | 'slices': reverse('slice-list', request=request, format=format), |
| 227 | 'networks': reverse('network-list', request=request, format=format), |
| 228 | 'services': reverse('service-list', request=request, format=format), |
| 229 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 230 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 231 | 'charges': reverse('charge-list', request=request, format=format), |
| 232 | 'roles': reverse('role-list', request=request, format=format), |
| 233 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
| 234 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 235 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 236 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 237 | 'nodes': reverse('node-list', request=request, format=format), |
| 238 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 239 | 'controllernetworks': reverse('controllernetwork-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 240 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 241 | 'controllerusers': reverse('controlleruser-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 242 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 243 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 244 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 245 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 246 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 247 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 248 | 'users': reverse('user-list', request=request, format=format), |
| 249 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 250 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 251 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 252 | 'controllerslices': reverse('controllerslice-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 253 | 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 254 | 'accounts': reverse('account-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 255 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 256 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 257 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 258 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 259 | 'controllersliceprivileges': reverse('controllersliceprivilege-list', request=request, format=format), |
| 260 | 'sitedeployments': reverse('sitedeployment-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 261 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 262 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 263 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 264 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 265 | 'routers': reverse('router-list', request=request, format=format), |
| 266 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
| 267 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 268 | }) |
| 269 | |
| 270 | # Based on serializers.py |
| 271 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 272 | class XOSModelSerializer(serializers.ModelSerializer): |
| 273 | def save_object(self, obj, **kwargs): |
| 274 | |
| 275 | """ rest_framework can't deal with ManyToMany relations that have a |
| 276 | through table. In plstackapi, most of the through tables we have |
| 277 | use defaults or blank fields, so there's no reason why we shouldn't |
| 278 | be able to save these objects. |
| 279 | |
| 280 | So, let's strip out these m2m relations, and deal with them ourself. |
| 281 | """ |
| 282 | obj._complex_m2m_data={};
|
| 283 | if getattr(obj, '_m2m_data', None):
|
| 284 | for relatedObject in obj._meta.get_all_related_many_to_many_objects():
|
| 285 | if (relatedObject.field.rel.through._meta.auto_created):
|
| 286 | # These are non-trough ManyToMany relations and
|
| 287 | # can be updated just fine
|
| 288 | continue
|
| 289 | fieldName = relatedObject.get_accessor_name()
|
| 290 | if fieldName in obj._m2m_data.keys():
|
| 291 | obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
|
| 292 | del obj._m2m_data[fieldName]
|
| 293 |
|
| 294 | serializers.ModelSerializer.save_object(self, obj, **kwargs); |
| 295 | |
| 296 | for (accessor, stuff) in obj._complex_m2m_data.items(): |
| 297 | (relatedObject, data) = stuff |
| 298 | through = relatedObject.field.rel.through |
| 299 | local_fieldName = relatedObject.field.m2m_reverse_field_name() |
| 300 | remote_fieldName = relatedObject.field.m2m_field_name() |
| 301 | |
| 302 | # get the current set of existing relations |
| 303 | existing = through.objects.filter(**{local_fieldName: obj}); |
| 304 | |
| 305 | data_ids = [item.id for item in data] |
| 306 | existing_ids = [getattr(item,remote_fieldName).id for item in existing] |
| 307 | |
| 308 | #print "data_ids", data_ids |
| 309 | #print "existing_ids", existing_ids |
| 310 | |
| 311 | # remove relations that are in 'existing' but not in 'data' |
| 312 | for item in list(existing): |
| 313 | if (getattr(item,remote_fieldName).id not in data_ids): |
| 314 | print "delete", getattr(item,remote_fieldName) |
| 315 | item.delete() #(purge=True) |
| 316 | |
| 317 | # add relations that are in 'data' but not in 'existing' |
| 318 | for item in data: |
| 319 | if (item.id not in existing_ids): |
| 320 | #print "add", item |
| 321 | newModel = through(**{local_fieldName: obj, remote_fieldName: item}) |
| 322 | newModel.save() |
| 323 | |
| 324 | |
| 325 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 326 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 327 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 328 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 329 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 330 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 331 | def getHumanReadableName(self, obj):
|
| 332 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 333 | def getValidators(self, obj): |
| 334 | try: |
| 335 | return obj.getValidators() |
| 336 | except: |
| 337 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 338 | class Meta: |
| 339 | model = ServiceAttribute |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 340 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 341 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 342 | class ServiceAttributeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 343 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 344 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 345 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 346 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 347 | def getHumanReadableName(self, obj):
|
| 348 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 349 | def getValidators(self, obj):
|
| 350 | try: |
| 351 | return obj.getValidators() |
| 352 | except: |
| 353 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 354 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 355 | model = ServiceAttribute |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 356 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 357 | |
| 358 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 359 | |
| 360 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 361 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 362 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 363 | |
| 364 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 365 | validators = serializers.SerializerMethodField("getValidators") |
| 366 | def getHumanReadableName(self, obj):
|
| 367 | return str(obj) |
| 368 | def getValidators(self, obj): |
| 369 | try: |
| 370 | return obj.getValidators() |
| 371 | except: |
| 372 | return None |
| 373 | class Meta: |
| 374 | model = ControllerImages |
| 375 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 376 | |
| 377 | class ControllerImagesIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 378 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 379 | |
| 380 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 381 | validators = serializers.SerializerMethodField("getValidators") |
| 382 | def getHumanReadableName(self, obj):
|
| 383 | return str(obj)
|
| 384 | def getValidators(self, obj):
|
| 385 | try: |
| 386 | return obj.getValidators() |
| 387 | except: |
| 388 | return None
|
| 389 | class Meta:
|
| 390 | model = ControllerImages |
| 391 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 396 | class ControllerSitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 397 | id = IdField() |
| 398 | |
| 399 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 400 | validators = serializers.SerializerMethodField("getValidators") |
| 401 | def getHumanReadableName(self, obj):
|
| 402 | return str(obj) |
| 403 | def getValidators(self, obj): |
| 404 | try: |
| 405 | return obj.getValidators() |
| 406 | except: |
| 407 | return None |
| 408 | class Meta: |
| 409 | model = ControllerSitePrivilege |
| 410 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',) |
| 411 | |
| 412 | class ControllerSitePrivilegeIdSerializer(XOSModelSerializer): |
| 413 | id = IdField() |
| 414 | |
| 415 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 416 | validators = serializers.SerializerMethodField("getValidators") |
| 417 | def getHumanReadableName(self, obj):
|
| 418 | return str(obj)
|
| 419 | def getValidators(self, obj):
|
| 420 | try: |
| 421 | return obj.getValidators() |
| 422 | except: |
| 423 | return None
|
| 424 | class Meta:
|
| 425 | model = ControllerSitePrivilege |
| 426 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',) |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 431 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 432 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 433 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 434 | |
| 435 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 436 | |
| 437 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 438 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 439 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 440 | def getHumanReadableName(self, obj):
|
| 441 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 442 | def getValidators(self, obj): |
| 443 | try: |
| 444 | return obj.getValidators() |
| 445 | except: |
| 446 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 447 | class Meta: |
| 448 | model = Image |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 449 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 450 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 451 | class ImageIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 452 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 453 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 454 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 455 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 456 | |
| 457 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 458 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 459 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 460 | def getHumanReadableName(self, obj):
|
| 461 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 462 | def getValidators(self, obj):
|
| 463 | try: |
| 464 | return obj.getValidators() |
| 465 | except: |
| 466 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 467 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 468 | model = Image |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 469 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 470 | |
| 471 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 472 | |
| 473 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 474 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 475 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 476 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 477 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 478 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 479 | def getHumanReadableName(self, obj):
|
| 480 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 481 | def getValidators(self, obj): |
| 482 | try: |
| 483 | return obj.getValidators() |
| 484 | except: |
| 485 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 486 | class Meta: |
| 487 | model = NetworkParameter |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 488 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 489 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 490 | class NetworkParameterIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 491 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 492 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 493 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 494 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 495 | def getHumanReadableName(self, obj):
|
| 496 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 497 | def getValidators(self, obj):
|
| 498 | try: |
| 499 | return obj.getValidators() |
| 500 | except: |
| 501 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 502 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 503 | model = NetworkParameter |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 504 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 505 | |
| 506 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 507 | |
| 508 | |
| 509 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 510 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 511 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 512 | |
| 513 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 514 | |
| 515 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 516 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 517 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 518 | def getHumanReadableName(self, obj):
|
| 519 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 520 | def getValidators(self, obj): |
| 521 | try: |
| 522 | return obj.getValidators() |
| 523 | except: |
| 524 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 525 | class Meta: |
| 526 | model = Site |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 527 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','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] | 528 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 529 | class SiteIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 530 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 531 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 532 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 533 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 534 | |
| 535 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 536 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 537 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 538 | def getHumanReadableName(self, obj):
|
| 539 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 540 | def getValidators(self, obj):
|
| 541 | try: |
| 542 | return obj.getValidators() |
| 543 | except: |
| 544 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 545 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 546 | model = Site |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 547 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','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] | 548 | |
| 549 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 550 | |
| 551 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 552 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 553 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 554 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 555 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 556 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 557 | def getHumanReadableName(self, obj):
|
| 558 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 559 | def getValidators(self, obj): |
| 560 | try: |
| 561 | return obj.getValidators() |
| 562 | except: |
| 563 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 564 | class Meta: |
| 565 | model = SliceRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 566 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 567 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 568 | class SliceRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 569 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 570 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 571 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 572 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 573 | def getHumanReadableName(self, obj):
|
| 574 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 575 | def getValidators(self, obj):
|
| 576 | try: |
| 577 | return obj.getValidators() |
| 578 | except: |
| 579 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 580 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 581 | model = SliceRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 582 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 583 | |
| 584 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 585 | |
| 586 | |
| 587 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 588 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 589 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 590 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 591 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 592 | def getHumanReadableName(self, obj):
|
| 593 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 594 | def getValidators(self, obj): |
| 595 | try: |
| 596 | return obj.getValidators() |
| 597 | except: |
| 598 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 599 | class Meta: |
| 600 | model = Tag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 601 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 602 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 603 | class TagIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 604 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 605 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 606 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 607 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 608 | def getHumanReadableName(self, obj):
|
| 609 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 610 | def getValidators(self, obj):
|
| 611 | try: |
| 612 | return obj.getValidators() |
| 613 | except: |
| 614 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 615 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 616 | model = Tag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 617 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 618 | |
| 619 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 620 | |
| 621 | |
| 622 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 623 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 624 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 625 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 626 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 627 | def getHumanReadableName(self, obj):
|
| 628 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 629 | def getValidators(self, obj): |
| 630 | try: |
| 631 | return obj.getValidators() |
| 632 | except: |
| 633 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 634 | class Meta: |
| 635 | model = Invoice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 636 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 637 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 638 | class InvoiceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 639 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 640 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 641 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 642 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 643 | def getHumanReadableName(self, obj):
|
| 644 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 645 | def getValidators(self, obj):
|
| 646 | try: |
| 647 | return obj.getValidators() |
| 648 | except: |
| 649 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 650 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 651 | model = Invoice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 652 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 653 | |
| 654 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 655 | |
| 656 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 657 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 658 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 659 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 660 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 661 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 662 | def getHumanReadableName(self, obj):
|
| 663 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 664 | def getValidators(self, obj): |
| 665 | try: |
| 666 | return obj.getValidators() |
| 667 | except: |
| 668 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 669 | class Meta: |
| 670 | model = SlicePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 671 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 672 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 673 | class SlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 674 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 675 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 676 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 677 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 678 | def getHumanReadableName(self, obj):
|
| 679 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 680 | def getValidators(self, obj):
|
| 681 | try: |
| 682 | return obj.getValidators() |
| 683 | except: |
| 684 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 685 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 686 | model = SlicePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 687 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 688 | |
| 689 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 690 | |
| 691 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 692 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 693 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 694 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 695 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 696 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 697 | def getHumanReadableName(self, obj):
|
| 698 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 699 | def getValidators(self, obj): |
| 700 | try: |
| 701 | return obj.getValidators() |
| 702 | except: |
| 703 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 704 | class Meta: |
| 705 | model = PlanetStackRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 706 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 707 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 708 | class PlanetStackRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 709 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 710 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 711 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 712 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 713 | def getHumanReadableName(self, obj):
|
| 714 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 715 | def getValidators(self, obj):
|
| 716 | try: |
| 717 | return obj.getValidators() |
| 718 | except: |
| 719 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 720 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 721 | model = PlanetStackRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 722 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 723 | |
| 724 | |
| 725 | |
| 726 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 727 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 728 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 729 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 730 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 731 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 732 | def getHumanReadableName(self, obj):
|
| 733 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 734 | def getValidators(self, obj): |
| 735 | try: |
| 736 | return obj.getValidators() |
| 737 | except: |
| 738 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 739 | class Meta: |
| 740 | model = NetworkSliver |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 741 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 742 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 743 | class NetworkSliverIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 744 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 745 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 746 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 747 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 748 | def getHumanReadableName(self, obj):
|
| 749 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 750 | def getValidators(self, obj):
|
| 751 | try: |
| 752 | return obj.getValidators() |
| 753 | except: |
| 754 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 755 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 756 | model = NetworkSliver |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 757 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 758 | |
| 759 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 760 | |
| 761 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 762 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
| 763 | id = IdField() |
| 764 | |
| 765 | |
| 766 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 767 | |
| 768 | |
| 769 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 770 | validators = serializers.SerializerMethodField("getValidators") |
| 771 | def getHumanReadableName(self, obj):
|
| 772 | return str(obj) |
| 773 | def getValidators(self, obj): |
| 774 | try: |
| 775 | return obj.getValidators() |
| 776 | except: |
| 777 | return None |
| 778 | class Meta: |
| 779 | model = Flavor |
| 780 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 781 | |
| 782 | class FlavorIdSerializer(XOSModelSerializer): |
| 783 | id = IdField() |
| 784 | |
| 785 | |
| 786 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
| 787 | |
| 788 | |
| 789 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 790 | validators = serializers.SerializerMethodField("getValidators") |
| 791 | def getHumanReadableName(self, obj):
|
| 792 | return str(obj)
|
| 793 | def getValidators(self, obj):
|
| 794 | try: |
| 795 | return obj.getValidators() |
| 796 | except: |
| 797 | return None
|
| 798 | class Meta:
|
| 799 | model = Flavor |
| 800 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | class ControllerSiteSerializer(serializers.HyperlinkedModelSerializer): |
| 806 | id = IdField() |
| 807 | |
| 808 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 809 | validators = serializers.SerializerMethodField("getValidators") |
| 810 | def getHumanReadableName(self, obj):
|
| 811 | return str(obj) |
| 812 | def getValidators(self, obj): |
| 813 | try: |
| 814 | return obj.getValidators() |
| 815 | except: |
| 816 | return None |
| 817 | class Meta: |
| 818 | model = ControllerSite |
| 819 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',) |
| 820 | |
| 821 | class ControllerSiteIdSerializer(XOSModelSerializer): |
| 822 | id = IdField() |
| 823 | |
| 824 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 825 | validators = serializers.SerializerMethodField("getValidators") |
| 826 | def getHumanReadableName(self, obj):
|
| 827 | return str(obj)
|
| 828 | def getValidators(self, obj):
|
| 829 | try: |
| 830 | return obj.getValidators() |
| 831 | except: |
| 832 | return None
|
| 833 | class Meta:
|
| 834 | model = ControllerSite |
| 835 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',) |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 840 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 841 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 842 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 843 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 844 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 845 | def getHumanReadableName(self, obj):
|
| 846 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 847 | def getValidators(self, obj): |
| 848 | try: |
| 849 | return obj.getValidators() |
| 850 | except: |
| 851 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 852 | class Meta: |
| 853 | model = Project |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 854 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 855 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 856 | class ProjectIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 857 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 858 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 859 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 860 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 861 | def getHumanReadableName(self, obj):
|
| 862 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 863 | def getValidators(self, obj):
|
| 864 | try: |
| 865 | return obj.getValidators() |
| 866 | except: |
| 867 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 868 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 869 | model = Project |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 870 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 871 | |
| 872 | |
| 873 | |
| 874 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 875 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 876 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 877 | |
| 878 | |
| 879 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 880 | |
| 881 | |
| 882 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 883 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 884 | |
| 885 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 886 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 887 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 888 | def getHumanReadableName(self, obj):
|
| 889 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 890 | def getValidators(self, obj): |
| 891 | try: |
| 892 | return obj.getValidators() |
| 893 | except: |
| 894 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 895 | class Meta: |
| 896 | model = Slice |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 897 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','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] | 898 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 899 | class SliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 900 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 901 | |
| 902 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 903 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 904 | |
| 905 | |
| 906 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 907 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 908 | |
| 909 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 910 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 911 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 912 | def getHumanReadableName(self, obj):
|
| 913 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 914 | def getValidators(self, obj):
|
| 915 | try: |
| 916 | return obj.getValidators() |
| 917 | except: |
| 918 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 919 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 920 | model = Slice |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 921 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','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] | 922 | |
| 923 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 924 | |
| 925 | |
| 926 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 927 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 928 | |
| 929 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 930 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 931 | |
| 932 | |
| 933 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 934 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 935 | |
| 936 | |
| 937 | |
| 938 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 939 | |
| 940 | |
| 941 | |
| 942 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 943 | |
| 944 | |
| 945 | |
| 946 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 947 | |
| 948 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 949 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 950 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 951 | def getHumanReadableName(self, obj):
|
| 952 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 953 | def getValidators(self, obj): |
| 954 | try: |
| 955 | return obj.getValidators() |
| 956 | except: |
| 957 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 958 | class Meta: |
| 959 | model = Network |
Scott Baker | d188c01 | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 960 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','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] | 961 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 962 | class NetworkIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 963 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 964 | |
| 965 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 966 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 967 | |
| 968 | |
| 969 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 970 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 971 | |
| 972 | |
| 973 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 974 | slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 975 | |
| 976 | |
| 977 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 978 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 979 | |
| 980 | |
| 981 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 982 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 983 | |
| 984 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 985 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 986 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 987 | def getHumanReadableName(self, obj):
|
| 988 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 989 | def getValidators(self, obj):
|
| 990 | try: |
| 991 | return obj.getValidators() |
| 992 | except: |
| 993 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 994 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 995 | model = Network |
Scott Baker | d188c01 | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 996 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','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] | 997 | |
| 998 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 999 | |
| 1000 | |
| 1001 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1002 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1003 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1004 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1005 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1006 | def getHumanReadableName(self, obj):
|
| 1007 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1008 | def getValidators(self, obj): |
| 1009 | try: |
| 1010 | return obj.getValidators() |
| 1011 | except: |
| 1012 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1013 | class Meta: |
| 1014 | model = Service |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1015 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1016 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1017 | class ServiceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1018 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1019 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1020 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1021 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1022 | def getHumanReadableName(self, obj):
|
| 1023 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1024 | def getValidators(self, obj):
|
| 1025 | try: |
| 1026 | return obj.getValidators() |
| 1027 | except: |
| 1028 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1029 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1030 | model = Service |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1031 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1032 | |
| 1033 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1034 | |
| 1035 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1036 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1037 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1038 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1039 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1040 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1041 | def getHumanReadableName(self, obj):
|
| 1042 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1043 | def getValidators(self, obj): |
| 1044 | try: |
| 1045 | return obj.getValidators() |
| 1046 | except: |
| 1047 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1048 | class Meta: |
| 1049 | model = ServiceClass |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1050 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1051 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1052 | class ServiceClassIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1053 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1054 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1055 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1056 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1057 | def getHumanReadableName(self, obj):
|
| 1058 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1059 | def getValidators(self, obj):
|
| 1060 | try: |
| 1061 | return obj.getValidators() |
| 1062 | except: |
| 1063 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1064 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1065 | model = ServiceClass |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1066 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1067 | |
| 1068 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1069 | |
| 1070 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1071 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1072 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1073 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1074 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1075 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1076 | def getHumanReadableName(self, obj):
|
| 1077 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1078 | def getValidators(self, obj): |
| 1079 | try: |
| 1080 | return obj.getValidators() |
| 1081 | except: |
| 1082 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1083 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1084 | model = PlanetStack |
| 1085 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1086 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1087 | class PlanetStackIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1088 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1089 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1090 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1091 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1092 | def getHumanReadableName(self, obj):
|
| 1093 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1094 | def getValidators(self, obj):
|
| 1095 | try: |
| 1096 | return obj.getValidators() |
| 1097 | except: |
| 1098 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1099 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1100 | model = PlanetStack |
| 1101 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1102 | |
| 1103 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1104 | |
| 1105 | |
| 1106 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1107 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1108 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1109 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1110 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1111 | def getHumanReadableName(self, obj):
|
| 1112 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1113 | def getValidators(self, obj): |
| 1114 | try: |
| 1115 | return obj.getValidators() |
| 1116 | except: |
| 1117 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1118 | class Meta: |
| 1119 | model = Charge |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1120 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1121 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1122 | class ChargeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1123 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1124 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1125 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1126 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1127 | def getHumanReadableName(self, obj):
|
| 1128 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1129 | def getValidators(self, obj):
|
| 1130 | try: |
| 1131 | return obj.getValidators() |
| 1132 | except: |
| 1133 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1134 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1135 | model = Charge |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1136 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1137 | |
| 1138 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1139 | |
| 1140 | |
| 1141 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1142 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1143 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1144 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1145 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1146 | def getHumanReadableName(self, obj):
|
| 1147 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1148 | def getValidators(self, obj): |
| 1149 | try: |
| 1150 | return obj.getValidators() |
| 1151 | except: |
| 1152 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1153 | class Meta: |
| 1154 | model = Role |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1155 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1156 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1157 | class RoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1158 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1159 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1160 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1161 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1162 | def getHumanReadableName(self, obj):
|
| 1163 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1164 | def getValidators(self, obj):
|
| 1165 | try: |
| 1166 | return obj.getValidators() |
| 1167 | except: |
| 1168 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1169 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1170 | model = Role |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1171 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1172 | |
| 1173 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1174 | |
| 1175 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1176 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1177 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1178 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1179 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1180 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1181 | def getHumanReadableName(self, obj):
|
| 1182 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1183 | def getValidators(self, obj): |
| 1184 | try: |
| 1185 | return obj.getValidators() |
| 1186 | except: |
| 1187 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1188 | class Meta: |
| 1189 | model = UsableObject |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1190 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1191 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1192 | class UsableObjectIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1193 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1194 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1195 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1196 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1197 | def getHumanReadableName(self, obj):
|
| 1198 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1199 | def getValidators(self, obj):
|
| 1200 | try: |
| 1201 | return obj.getValidators() |
| 1202 | except: |
| 1203 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1204 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1205 | model = UsableObject |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1206 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1207 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1208 | |
| 1209 | |
| 1210 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1211 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1212 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1213 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1214 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1215 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1216 | def getHumanReadableName(self, obj):
|
| 1217 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1218 | def getValidators(self, obj): |
| 1219 | try: |
| 1220 | return obj.getValidators() |
| 1221 | except: |
| 1222 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1223 | class Meta: |
| 1224 | model = SiteRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1225 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1226 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1227 | class SiteRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1228 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1229 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1230 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1231 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1232 | def getHumanReadableName(self, obj):
|
| 1233 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1234 | def getValidators(self, obj):
|
| 1235 | try: |
| 1236 | return obj.getValidators() |
| 1237 | except: |
| 1238 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1239 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1240 | model = SiteRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1241 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1242 | |
| 1243 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1244 | |
| 1245 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1246 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1247 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1248 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1249 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1250 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1251 | def getHumanReadableName(self, obj):
|
| 1252 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1253 | def getValidators(self, obj): |
| 1254 | try: |
| 1255 | return obj.getValidators() |
| 1256 | except: |
| 1257 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1258 | class Meta: |
| 1259 | model = SliceCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1260 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1261 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1262 | class SliceCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1263 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1264 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1265 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1266 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1267 | def getHumanReadableName(self, obj):
|
| 1268 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1269 | def getValidators(self, obj):
|
| 1270 | try: |
| 1271 | return obj.getValidators() |
| 1272 | except: |
| 1273 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1274 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1275 | model = SliceCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1276 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1277 | |
| 1278 | |
| 1279 | |
| 1280 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1281 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1282 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1283 | |
| 1284 | |
| 1285 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1286 | |
| 1287 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1288 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1289 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1290 | def getHumanReadableName(self, obj):
|
| 1291 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1292 | def getValidators(self, obj): |
| 1293 | try: |
| 1294 | return obj.getValidators() |
| 1295 | except: |
| 1296 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1297 | class Meta: |
| 1298 | model = Sliver |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 1299 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','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] | 1300 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1301 | class SliverIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1302 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1303 | |
| 1304 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1305 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1306 | |
| 1307 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1308 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1309 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1310 | def getHumanReadableName(self, obj):
|
| 1311 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1312 | def getValidators(self, obj):
|
| 1313 | try: |
| 1314 | return obj.getValidators() |
| 1315 | except: |
| 1316 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1317 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1318 | model = Sliver |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 1319 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','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] | 1320 | |
| 1321 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1322 | |
| 1323 | |
| 1324 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1325 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1326 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1327 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1328 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1329 | def getHumanReadableName(self, obj):
|
| 1330 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1331 | def getValidators(self, obj): |
| 1332 | try: |
| 1333 | return obj.getValidators() |
| 1334 | except: |
| 1335 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1336 | class Meta: |
| 1337 | model = Node |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1338 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1339 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1340 | class NodeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1341 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1342 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1343 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1344 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1345 | def getHumanReadableName(self, obj):
|
| 1346 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1347 | def getValidators(self, obj):
|
| 1348 | try: |
| 1349 | return obj.getValidators() |
| 1350 | except: |
| 1351 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1352 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1353 | model = Node |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1354 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1355 | |
| 1356 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1357 | |
| 1358 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1359 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1360 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1361 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1362 | |
| 1363 | controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail') |
| 1364 | |
| 1365 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1366 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1367 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1368 | def getHumanReadableName(self, obj):
|
| 1369 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1370 | def getValidators(self, obj): |
| 1371 | try: |
| 1372 | return obj.getValidators() |
| 1373 | except: |
| 1374 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1375 | class Meta: |
| 1376 | model = DashboardView |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1377 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1378 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1379 | class DashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1380 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1381 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1382 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1383 | controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1384 | |
| 1385 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1386 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1387 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1388 | def getHumanReadableName(self, obj):
|
| 1389 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1390 | def getValidators(self, obj):
|
| 1391 | try: |
| 1392 | return obj.getValidators() |
| 1393 | except: |
| 1394 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1395 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1396 | model = DashboardView |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1397 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1398 | |
| 1399 | |
| 1400 | |
| 1401 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1402 | class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer): |
| 1403 | id = IdField() |
| 1404 | |
| 1405 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1406 | validators = serializers.SerializerMethodField("getValidators") |
| 1407 | def getHumanReadableName(self, obj):
|
| 1408 | return str(obj) |
| 1409 | def getValidators(self, obj): |
| 1410 | try: |
| 1411 | return obj.getValidators() |
| 1412 | except: |
| 1413 | return None |
| 1414 | class Meta: |
| 1415 | model = ControllerNetwork |
| 1416 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
| 1417 | |
| 1418 | class ControllerNetworkIdSerializer(XOSModelSerializer): |
| 1419 | id = IdField() |
| 1420 | |
| 1421 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1422 | validators = serializers.SerializerMethodField("getValidators") |
| 1423 | def getHumanReadableName(self, obj):
|
| 1424 | return str(obj)
|
| 1425 | def getValidators(self, obj):
|
| 1426 | try: |
| 1427 | return obj.getValidators() |
| 1428 | except: |
| 1429 | return None
|
| 1430 | class Meta:
|
| 1431 | model = ControllerNetwork |
| 1432 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
| 1433 | |
| 1434 | |
| 1435 | |
| 1436 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1437 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1438 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1439 | |
| 1440 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1441 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1442 | def getHumanReadableName(self, obj):
|
| 1443 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1444 | def getValidators(self, obj): |
| 1445 | try: |
| 1446 | return obj.getValidators() |
| 1447 | except: |
| 1448 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1449 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1450 | model = ImageDeployments |
| 1451 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1452 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1453 | class ImageDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1454 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1455 | |
| 1456 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1457 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1458 | def getHumanReadableName(self, obj):
|
| 1459 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1460 | def getValidators(self, obj):
|
| 1461 | try: |
| 1462 | return obj.getValidators() |
| 1463 | except: |
| 1464 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1465 | class Meta:
|
| 1466 | model = ImageDeployments |
| 1467 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1468 | |
| 1469 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1470 | |
| 1471 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1472 | class ControllerUserSerializer(serializers.HyperlinkedModelSerializer): |
| 1473 | id = IdField() |
| 1474 | |
| 1475 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1476 | validators = serializers.SerializerMethodField("getValidators") |
| 1477 | def getHumanReadableName(self, obj):
|
| 1478 | return str(obj) |
| 1479 | def getValidators(self, obj): |
| 1480 | try: |
| 1481 | return obj.getValidators() |
| 1482 | except: |
| 1483 | return None |
| 1484 | class Meta: |
| 1485 | model = ControllerUser |
| 1486 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 1487 | |
| 1488 | class ControllerUserIdSerializer(XOSModelSerializer): |
| 1489 | id = IdField() |
| 1490 | |
| 1491 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1492 | validators = serializers.SerializerMethodField("getValidators") |
| 1493 | def getHumanReadableName(self, obj):
|
| 1494 | return str(obj)
|
| 1495 | def getValidators(self, obj):
|
| 1496 | try: |
| 1497 | return obj.getValidators() |
| 1498 | except: |
| 1499 | return None
|
| 1500 | class Meta:
|
| 1501 | model = ControllerUser |
| 1502 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 1503 | |
| 1504 | |
| 1505 | |
| 1506 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1507 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1508 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1509 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1510 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1511 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1512 | def getHumanReadableName(self, obj):
|
| 1513 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1514 | def getValidators(self, obj): |
| 1515 | try: |
| 1516 | return obj.getValidators() |
| 1517 | except: |
| 1518 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1519 | class Meta: |
| 1520 | model = ReservedResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1521 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1522 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1523 | class ReservedResourceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1524 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1525 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1526 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1527 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1528 | def getHumanReadableName(self, obj):
|
| 1529 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1530 | def getValidators(self, obj):
|
| 1531 | try: |
| 1532 | return obj.getValidators() |
| 1533 | except: |
| 1534 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1535 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1536 | model = ReservedResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1537 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1538 | |
| 1539 | |
| 1540 | |
| 1541 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1542 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1543 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1544 | |
| 1545 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1546 | validators = serializers.SerializerMethodField("getValidators") |
| 1547 | def getHumanReadableName(self, obj):
|
| 1548 | return str(obj) |
| 1549 | def getValidators(self, obj): |
| 1550 | try: |
| 1551 | return obj.getValidators() |
| 1552 | except: |
| 1553 | return None |
| 1554 | class Meta: |
| 1555 | model = Payment |
| 1556 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1557 | |
| 1558 | class PaymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1559 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1560 | |
| 1561 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1562 | validators = serializers.SerializerMethodField("getValidators") |
| 1563 | def getHumanReadableName(self, obj):
|
| 1564 | return str(obj)
|
| 1565 | def getValidators(self, obj):
|
| 1566 | try: |
| 1567 | return obj.getValidators() |
| 1568 | except: |
| 1569 | return None
|
| 1570 | class Meta:
|
| 1571 | model = Payment |
| 1572 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1573 | |
| 1574 | |
| 1575 | |
| 1576 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1577 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1578 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1579 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1580 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1581 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1582 | def getHumanReadableName(self, obj):
|
| 1583 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1584 | def getValidators(self, obj): |
| 1585 | try: |
| 1586 | return obj.getValidators() |
| 1587 | except: |
| 1588 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1589 | class Meta: |
| 1590 | model = NetworkSlice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1591 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1592 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1593 | class NetworkSliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1594 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1595 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1596 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1597 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1598 | def getHumanReadableName(self, obj):
|
| 1599 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1600 | def getValidators(self, obj):
|
| 1601 | try: |
| 1602 | return obj.getValidators() |
| 1603 | except: |
| 1604 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1605 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1606 | model = NetworkSlice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1607 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1608 | |
| 1609 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1610 | |
| 1611 | |
| 1612 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1613 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1614 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1615 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1616 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1617 | def getHumanReadableName(self, obj):
|
| 1618 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1619 | def getValidators(self, obj): |
| 1620 | try: |
| 1621 | return obj.getValidators() |
| 1622 | except: |
| 1623 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1624 | class Meta: |
| 1625 | model = UserDashboardView |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1626 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1627 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1628 | class UserDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1629 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1630 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1631 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1632 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1633 | def getHumanReadableName(self, obj):
|
| 1634 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1635 | def getValidators(self, obj):
|
| 1636 | try: |
| 1637 | return obj.getValidators() |
| 1638 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1639 | return None
|
| 1640 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1641 | model = UserDashboardView |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1642 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1643 | |
| 1644 | |
| 1645 | |
| 1646 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1647 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1648 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1649 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1650 | |
| 1651 | dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail') |
| 1652 | |
| 1653 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1654 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1655 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1656 | def getHumanReadableName(self, obj):
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1657 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1658 | def getValidators(self, obj): |
| 1659 | try: |
| 1660 | return obj.getValidators() |
| 1661 | except: |
| 1662 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1663 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1664 | model = Controller |
| 1665 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1666 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1667 | class ControllerIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1668 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1669 | |
| 1670 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1671 | dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1672 | |
| 1673 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1674 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1675 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1676 | def getHumanReadableName(self, obj):
|
| 1677 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1678 | def getValidators(self, obj):
|
| 1679 | try: |
| 1680 | return obj.getValidators() |
| 1681 | except: |
| 1682 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1683 | class Meta:
|
| 1684 | model = Controller |
| 1685 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 1686 | |
| 1687 | |
| 1688 | |
| 1689 | |
| 1690 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1691 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1692 | |
| 1693 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1694 | validators = serializers.SerializerMethodField("getValidators") |
| 1695 | def getHumanReadableName(self, obj):
|
| 1696 | return str(obj) |
| 1697 | def getValidators(self, obj): |
| 1698 | try: |
| 1699 | return obj.getValidators() |
| 1700 | except: |
| 1701 | return None |
| 1702 | class Meta: |
| 1703 | model = PlanetStackPrivilege |
| 1704 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1705 | |
| 1706 | class PlanetStackPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1707 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1708 | |
| 1709 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1710 | validators = serializers.SerializerMethodField("getValidators") |
| 1711 | def getHumanReadableName(self, obj):
|
| 1712 | return str(obj)
|
| 1713 | def getValidators(self, obj):
|
| 1714 | try: |
| 1715 | return obj.getValidators() |
| 1716 | except: |
| 1717 | return None
|
| 1718 | class Meta:
|
| 1719 | model = PlanetStackPrivilege |
| 1720 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1721 | |
| 1722 | |
| 1723 | |
| 1724 | |
| 1725 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1726 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1727 | |
| 1728 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1729 | validators = serializers.SerializerMethodField("getValidators") |
| 1730 | def getHumanReadableName(self, obj):
|
| 1731 | return str(obj) |
| 1732 | def getValidators(self, obj): |
| 1733 | try: |
| 1734 | return obj.getValidators() |
| 1735 | except: |
| 1736 | return None |
| 1737 | class Meta: |
| 1738 | model = User |
| 1739 | 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','created','updated','enacted','backend_status','deleted','timezone',) |
| 1740 | |
| 1741 | class UserIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1742 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1743 | |
| 1744 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1745 | validators = serializers.SerializerMethodField("getValidators") |
| 1746 | def getHumanReadableName(self, obj):
|
| 1747 | return str(obj)
|
| 1748 | def getValidators(self, obj):
|
| 1749 | try: |
| 1750 | return obj.getValidators() |
| 1751 | except: |
| 1752 | return None
|
| 1753 | class Meta:
|
| 1754 | model = User |
| 1755 | 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','created','updated','enacted','backend_status','deleted','timezone',) |
| 1756 | |
| 1757 | |
| 1758 | |
| 1759 | |
| 1760 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1761 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1762 | |
| 1763 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1764 | images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail') |
| 1765 | |
| 1766 | |
| 1767 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1768 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1769 | |
| 1770 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1771 | |
| 1772 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1773 | |
| 1774 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1775 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1776 | validators = serializers.SerializerMethodField("getValidators") |
| 1777 | def getHumanReadableName(self, obj):
|
| 1778 | return str(obj) |
| 1779 | def getValidators(self, obj): |
| 1780 | try: |
| 1781 | return obj.getValidators() |
| 1782 | except: |
| 1783 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1784 | class Meta: |
| 1785 | model = Deployment |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1786 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1787 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1788 | class DeploymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1789 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1790 | |
| 1791 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1792 | images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all()) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1793 | |
| 1794 | |
| 1795 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1796 | sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1797 | |
| 1798 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1799 | |
| 1800 | flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all()) |
| 1801 | |
| 1802 | |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1803 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1804 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1805 | def getHumanReadableName(self, obj):
|
| 1806 | return str(obj)
|
| 1807 | def getValidators(self, obj):
|
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1808 | try: |
| 1809 | return obj.getValidators() |
| 1810 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1811 | return None
|
| 1812 | class Meta:
|
| 1813 | model = Deployment |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1814 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1815 | |
| 1816 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1817 | |
| 1818 | |
| 1819 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1820 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1821 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1822 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1823 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1824 | def getHumanReadableName(self, obj):
|
| 1825 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1826 | def getValidators(self, obj): |
| 1827 | try: |
| 1828 | return obj.getValidators() |
| 1829 | except: |
| 1830 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1831 | class Meta: |
| 1832 | model = Reservation |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1833 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1834 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1835 | class ReservationIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1836 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1837 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1838 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1839 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1840 | def getHumanReadableName(self, obj):
|
| 1841 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1842 | def getValidators(self, obj):
|
| 1843 | try: |
| 1844 | return obj.getValidators() |
| 1845 | except: |
| 1846 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1847 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1848 | model = Reservation |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1849 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1850 | |
| 1851 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1852 | |
| 1853 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1854 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1855 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1856 | |
| 1857 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1858 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1859 | def getHumanReadableName(self, obj):
|
| 1860 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1861 | def getValidators(self, obj): |
| 1862 | try: |
| 1863 | return obj.getValidators() |
| 1864 | except: |
| 1865 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1866 | class Meta: |
| 1867 | model = SitePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1868 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1869 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1870 | class SitePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1871 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1872 | |
| 1873 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1874 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1875 | def getHumanReadableName(self, obj):
|
| 1876 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1877 | def getValidators(self, obj):
|
| 1878 | try: |
| 1879 | return obj.getValidators() |
| 1880 | except: |
| 1881 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1882 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1883 | model = SitePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1884 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1885 | |
| 1886 | |
| 1887 | |
| 1888 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1889 | class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1890 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1891 | |
| 1892 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1893 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1894 | def getHumanReadableName(self, obj):
|
| 1895 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1896 | def getValidators(self, obj): |
| 1897 | try: |
| 1898 | return obj.getValidators() |
| 1899 | except: |
| 1900 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1901 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1902 | model = ControllerSlice |
| 1903 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1904 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1905 | class ControllerSliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1906 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1907 | |
| 1908 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1909 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1910 | def getHumanReadableName(self, obj):
|
| 1911 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1912 | def getValidators(self, obj):
|
| 1913 | try: |
| 1914 | return obj.getValidators() |
| 1915 | except: |
| 1916 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1917 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1918 | model = ControllerSlice |
| 1919 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1920 | |
| 1921 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1922 | |
| 1923 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1924 | class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1925 | id = IdField() |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1926 | |
| 1927 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1928 | validators = serializers.SerializerMethodField("getValidators") |
| 1929 | def getHumanReadableName(self, obj):
|
| 1930 | return str(obj) |
| 1931 | def getValidators(self, obj): |
| 1932 | try: |
| 1933 | return obj.getValidators() |
| 1934 | except: |
| 1935 | return None |
| 1936 | class Meta: |
| 1937 | model = ControllerDashboardView |
| 1938 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1939 | |
| 1940 | class ControllerDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1941 | id = IdField() |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1942 | |
| 1943 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1944 | validators = serializers.SerializerMethodField("getValidators") |
| 1945 | def getHumanReadableName(self, obj):
|
| 1946 | return str(obj)
|
| 1947 | def getValidators(self, obj):
|
| 1948 | try: |
| 1949 | return obj.getValidators() |
| 1950 | except: |
| 1951 | return None
|
| 1952 | class Meta:
|
| 1953 | model = ControllerDashboardView |
| 1954 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1955 | |
| 1956 | |
| 1957 | |
| 1958 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1959 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1960 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1961 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1962 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1963 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1964 | def getHumanReadableName(self, obj):
|
| 1965 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1966 | def getValidators(self, obj): |
| 1967 | try: |
| 1968 | return obj.getValidators() |
| 1969 | except: |
| 1970 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1971 | class Meta: |
| 1972 | model = Account |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1973 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1974 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1975 | class AccountIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1976 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1977 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1978 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1979 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1980 | def getHumanReadableName(self, obj):
|
| 1981 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1982 | def getValidators(self, obj):
|
| 1983 | try: |
| 1984 | return obj.getValidators() |
| 1985 | except: |
| 1986 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1987 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1988 | model = Account |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1989 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1990 | |
| 1991 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1992 | |
| 1993 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1994 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1995 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1996 | |
| 1997 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1998 | validators = serializers.SerializerMethodField("getValidators") |
| 1999 | def getHumanReadableName(self, obj):
|
| 2000 | return str(obj) |
| 2001 | def getValidators(self, obj): |
| 2002 | try: |
| 2003 | return obj.getValidators() |
| 2004 | except: |
| 2005 | return None |
| 2006 | class Meta: |
| 2007 | model = ControllerRole |
| 2008 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 2009 | |
| 2010 | class ControllerRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2011 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2012 | |
| 2013 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2014 | validators = serializers.SerializerMethodField("getValidators") |
| 2015 | def getHumanReadableName(self, obj):
|
| 2016 | return str(obj)
|
| 2017 | def getValidators(self, obj):
|
| 2018 | try: |
| 2019 | return obj.getValidators() |
| 2020 | except: |
| 2021 | return None
|
| 2022 | class Meta:
|
| 2023 | model = ControllerRole |
| 2024 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 2025 | |
| 2026 | |
| 2027 | |
| 2028 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2029 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2030 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2031 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2032 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2033 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2034 | def getHumanReadableName(self, obj):
|
| 2035 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2036 | def getValidators(self, obj): |
| 2037 | try: |
| 2038 | return obj.getValidators() |
| 2039 | except: |
| 2040 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2041 | class Meta: |
| 2042 | model = NetworkParameterType |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2043 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2044 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2045 | class NetworkParameterTypeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2046 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2047 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2048 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2049 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2050 | def getHumanReadableName(self, obj):
|
| 2051 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2052 | def getValidators(self, obj):
|
| 2053 | try: |
| 2054 | return obj.getValidators() |
| 2055 | except: |
| 2056 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2057 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2058 | model = NetworkParameterType |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2059 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2060 | |
| 2061 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2062 | |
| 2063 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2064 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2065 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2066 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2067 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2068 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2069 | def getHumanReadableName(self, obj):
|
| 2070 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2071 | def getValidators(self, obj): |
| 2072 | try: |
| 2073 | return obj.getValidators() |
| 2074 | except: |
| 2075 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2076 | class Meta: |
| 2077 | model = SiteCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2078 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2079 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2080 | class SiteCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2081 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2082 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2083 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2084 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2085 | def getHumanReadableName(self, obj):
|
| 2086 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2087 | def getValidators(self, obj):
|
| 2088 | try: |
| 2089 | return obj.getValidators() |
| 2090 | except: |
| 2091 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2092 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2093 | model = SiteCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2094 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2095 | |
| 2096 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2097 | |
| 2098 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2099 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2100 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2101 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2102 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2103 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2104 | def getHumanReadableName(self, obj):
|
| 2105 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2106 | def getValidators(self, obj): |
| 2107 | try: |
| 2108 | return obj.getValidators() |
| 2109 | except: |
| 2110 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2111 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2112 | model = DeploymentPrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2113 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2114 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2115 | class DeploymentPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2116 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2117 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2118 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2119 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2120 | def getHumanReadableName(self, obj):
|
| 2121 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2122 | def getValidators(self, obj):
|
| 2123 | try: |
| 2124 | return obj.getValidators() |
| 2125 | except: |
| 2126 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2127 | class Meta:
|
| 2128 | model = DeploymentPrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2129 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2130 | |
| 2131 | |
| 2132 | |
| 2133 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2134 | class ControllerSlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2135 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2136 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2137 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2138 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2139 | def getHumanReadableName(self, obj):
|
| 2140 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2141 | def getValidators(self, obj): |
| 2142 | try: |
| 2143 | return obj.getValidators() |
| 2144 | except: |
| 2145 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2146 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2147 | model = ControllerSlicePrivilege |
| 2148 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2149 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2150 | class ControllerSlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2151 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2152 | |
| 2153 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2154 | validators = serializers.SerializerMethodField("getValidators") |
| 2155 | def getHumanReadableName(self, obj):
|
| 2156 | return str(obj)
|
| 2157 | def getValidators(self, obj):
|
| 2158 | try: |
| 2159 | return obj.getValidators() |
| 2160 | except: |
| 2161 | return None
|
| 2162 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2163 | model = ControllerSlicePrivilege |
| 2164 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',) |
| 2165 | |
| 2166 | |
| 2167 | |
| 2168 | |
| 2169 | class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer): |
| 2170 | id = IdField() |
| 2171 | |
| 2172 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2173 | validators = serializers.SerializerMethodField("getValidators") |
| 2174 | def getHumanReadableName(self, obj):
|
| 2175 | return str(obj) |
| 2176 | def getValidators(self, obj): |
| 2177 | try: |
| 2178 | return obj.getValidators() |
| 2179 | except: |
| 2180 | return None |
| 2181 | class Meta: |
| 2182 | model = SiteDeployment |
| 2183 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
| 2184 | |
| 2185 | class SiteDeploymentIdSerializer(XOSModelSerializer): |
| 2186 | id = IdField() |
| 2187 | |
| 2188 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2189 | validators = serializers.SerializerMethodField("getValidators") |
| 2190 | def getHumanReadableName(self, obj):
|
| 2191 | return str(obj)
|
| 2192 | def getValidators(self, obj):
|
| 2193 | try: |
| 2194 | return obj.getValidators() |
| 2195 | except: |
| 2196 | return None
|
| 2197 | class Meta:
|
| 2198 | model = SiteDeployment |
| 2199 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2200 | |
| 2201 | |
| 2202 | |
| 2203 | |
| 2204 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2205 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2206 | |
| 2207 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2208 | validators = serializers.SerializerMethodField("getValidators") |
| 2209 | def getHumanReadableName(self, obj):
|
| 2210 | return str(obj) |
| 2211 | def getValidators(self, obj): |
| 2212 | try: |
| 2213 | return obj.getValidators() |
| 2214 | except: |
| 2215 | return None |
| 2216 | class Meta: |
| 2217 | model = DeploymentRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2218 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2219 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2220 | class DeploymentRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2221 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2222 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2223 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2224 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2225 | def getHumanReadableName(self, obj):
|
| 2226 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2227 | def getValidators(self, obj):
|
| 2228 | try: |
| 2229 | return obj.getValidators() |
| 2230 | except: |
| 2231 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2232 | class Meta:
|
| 2233 | model = DeploymentRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2234 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2235 | |
| 2236 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2237 | |
| 2238 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2239 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2240 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2241 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2242 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2243 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2244 | def getHumanReadableName(self, obj):
|
| 2245 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2246 | def getValidators(self, obj): |
| 2247 | try: |
| 2248 | return obj.getValidators() |
| 2249 | except: |
| 2250 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2251 | class Meta: |
| 2252 | model = UserCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2253 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2254 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2255 | class UserCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2256 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2257 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2258 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2259 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2260 | def getHumanReadableName(self, obj):
|
| 2261 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2262 | def getValidators(self, obj):
|
| 2263 | try: |
| 2264 | return obj.getValidators() |
| 2265 | except: |
| 2266 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2267 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2268 | model = UserCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2269 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2270 | |
| 2271 | |
| 2272 | |
| 2273 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2274 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2275 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2276 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2277 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2278 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2279 | def getHumanReadableName(self, obj):
|
| 2280 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2281 | def getValidators(self, obj): |
| 2282 | try: |
| 2283 | return obj.getValidators() |
| 2284 | except: |
| 2285 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2286 | class Meta: |
| 2287 | model = SliceTag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2288 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2289 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2290 | class SliceTagIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2291 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2292 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2293 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2294 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2295 | def getHumanReadableName(self, obj):
|
| 2296 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2297 | def getValidators(self, obj):
|
| 2298 | try: |
| 2299 | return obj.getValidators() |
| 2300 | except: |
| 2301 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2302 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2303 | model = SliceTag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2304 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2305 | |
| 2306 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2307 | |
| 2308 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2309 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2310 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2311 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2312 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2313 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2314 | def getHumanReadableName(self, obj):
|
| 2315 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2316 | def getValidators(self, obj): |
| 2317 | try: |
| 2318 | return obj.getValidators() |
| 2319 | except: |
| 2320 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2321 | class Meta: |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2322 | model = NetworkTemplate |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 2323 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','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] | 2324 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2325 | class NetworkTemplateIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2326 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2327 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2328 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2329 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2330 | def getHumanReadableName(self, obj):
|
| 2331 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2332 | def getValidators(self, obj):
|
| 2333 | try: |
| 2334 | return obj.getValidators() |
| 2335 | except: |
| 2336 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2337 | class Meta:
|
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2338 | model = NetworkTemplate |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 2339 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','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] | 2340 | |
| 2341 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2342 | |
| 2343 | |
| 2344 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2345 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2346 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2347 | |
| 2348 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2349 | |
| 2350 | |
| 2351 | |
| 2352 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2353 | |
| 2354 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2355 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2356 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2357 | def getHumanReadableName(self, obj):
|
| 2358 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2359 | def getValidators(self, obj): |
| 2360 | try: |
| 2361 | return obj.getValidators() |
| 2362 | except: |
| 2363 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2364 | class Meta: |
| 2365 | model = Router |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2366 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2367 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2368 | class RouterIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2369 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2370 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2371 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2372 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2373 | |
| 2374 | |
| 2375 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2376 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2377 | |
| 2378 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2379 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2380 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2381 | def getHumanReadableName(self, obj):
|
| 2382 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2383 | def getValidators(self, obj):
|
| 2384 | try: |
| 2385 | return obj.getValidators() |
| 2386 | except: |
| 2387 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2388 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2389 | model = Router |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2390 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2391 | |
| 2392 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2393 | |
| 2394 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2395 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2396 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2397 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2398 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2399 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2400 | def getHumanReadableName(self, obj):
|
| 2401 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2402 | def getValidators(self, obj): |
| 2403 | try: |
| 2404 | return obj.getValidators() |
| 2405 | except: |
| 2406 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2407 | class Meta: |
| 2408 | model = ServiceResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2409 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2410 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2411 | class ServiceResourceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2412 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2413 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2414 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2415 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2416 | def getHumanReadableName(self, obj):
|
| 2417 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2418 | def getValidators(self, obj):
|
| 2419 | try: |
| 2420 | return obj.getValidators() |
| 2421 | except: |
| 2422 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2423 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2424 | model = ServiceResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2425 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2426 | |
| 2427 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2428 | |
| 2429 | |
| 2430 | serializerLookUp = { |
| 2431 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2432 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2433 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2434 | ControllerImages: ControllerImagesSerializer, |
| 2435 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2436 | ControllerSitePrivilege: ControllerSitePrivilegeSerializer, |
| 2437 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2438 | Image: ImageSerializer, |
| 2439 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2440 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2441 | |
| 2442 | Site: SiteSerializer, |
| 2443 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2444 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2445 | |
| 2446 | Tag: TagSerializer, |
| 2447 | |
| 2448 | Invoice: InvoiceSerializer, |
| 2449 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2450 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2451 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2452 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2453 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2454 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2455 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2456 | Flavor: FlavorSerializer, |
| 2457 | |
| 2458 | ControllerSite: ControllerSiteSerializer, |
| 2459 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2460 | Project: ProjectSerializer, |
| 2461 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2462 | Slice: SliceSerializer, |
| 2463 | |
| 2464 | Network: NetworkSerializer, |
| 2465 | |
| 2466 | Service: ServiceSerializer, |
| 2467 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2468 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2469 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2470 | PlanetStack: PlanetStackSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2471 | |
| 2472 | Charge: ChargeSerializer, |
| 2473 | |
| 2474 | Role: RoleSerializer, |
| 2475 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2476 | UsableObject: UsableObjectSerializer, |
| 2477 | |
| 2478 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2479 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2480 | SliceCredential: SliceCredentialSerializer, |
| 2481 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2482 | Sliver: SliverSerializer, |
| 2483 | |
| 2484 | Node: NodeSerializer, |
| 2485 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2486 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2487 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2488 | ControllerNetwork: ControllerNetworkSerializer, |
| 2489 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2490 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2491 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2492 | ControllerUser: ControllerUserSerializer, |
| 2493 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2494 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2495 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2496 | Payment: PaymentSerializer, |
| 2497 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2498 | NetworkSlice: NetworkSliceSerializer, |
| 2499 | |
| 2500 | UserDashboardView: UserDashboardViewSerializer, |
| 2501 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2502 | Controller: ControllerSerializer, |
| 2503 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2504 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2505 | |
| 2506 | User: UserSerializer, |
| 2507 | |
| 2508 | Deployment: DeploymentSerializer, |
| 2509 | |
| 2510 | Reservation: ReservationSerializer, |
| 2511 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2512 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2513 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2514 | ControllerSlice: ControllerSliceSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2515 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2516 | ControllerDashboardView: ControllerDashboardViewSerializer, |
| 2517 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2518 | Account: AccountSerializer, |
| 2519 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2520 | ControllerRole: ControllerRoleSerializer, |
| 2521 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2522 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2523 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2524 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2525 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2526 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2527 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2528 | ControllerSlicePrivilege: ControllerSlicePrivilegeSerializer, |
| 2529 | |
| 2530 | SiteDeployment: SiteDeploymentSerializer, |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2531 | |
| 2532 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2533 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2534 | UserCredential: UserCredentialSerializer, |
| 2535 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2536 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2537 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2538 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2539 | |
| 2540 | Router: RouterSerializer, |
| 2541 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2542 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2543 | |
| 2544 | None: None, |
| 2545 | } |
| 2546 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2547 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2548 | |
| 2549 | # To handle fine-grained field permissions, we have to check can_update |
| 2550 | # the object has been updated but before it has been saved. |
| 2551 | |
| 2552 | def update(self, request, *args, **kwargs):
|
| 2553 | partial = kwargs.pop('partial', False)
|
| 2554 | self.object = self.get_object_or_none()
|
| 2555 |
|
| 2556 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2557 | files=request.FILES, partial=partial)
|
| 2558 |
|
| 2559 | if not serializer.is_valid():
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2560 | response = {"error": "validation",
|
| 2561 | "specific_error": "not serializer.is_valid()",
|
| 2562 | "reasons": serializer.errors}
|
| 2563 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2564 |
|
| 2565 | try:
|
| 2566 | self.pre_save(serializer.object)
|
| 2567 | except ValidationError as err:
|
| 2568 | # full_clean on model instance may be called in pre_save,
|
| 2569 | # so we have to handle eventual errors.
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2570 | response = {"error": "validation",
|
| 2571 | "specific_error": "ValidationError in pre_save",
|
| 2572 | "reasons": err.message_dict}
|
| 2573 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2574 |
|
| 2575 | if serializer.object is not None:
|
| 2576 | if not serializer.object.can_update(request.user):
|
| 2577 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2578 |
|
| 2579 | if self.object is None:
|
| 2580 | self.object = serializer.save(force_insert=True)
|
| 2581 | self.post_save(self.object, created=True)
|
| 2582 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2583 |
|
| 2584 | self.object = serializer.save(force_update=True)
|
| 2585 | self.post_save(self.object, created=False)
|
| 2586 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2587 | |
| 2588 | def destroy(self, request, *args, **kwargs): |
| 2589 | obj = self.get_object() |
| 2590 | if obj.can_update(request.user): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2591 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2592 | else: |
| 2593 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2594 | |
| 2595 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2596 | # Based on core/views/*.py |
| 2597 | |
| 2598 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2599 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 2600 | queryset = ServiceAttribute.objects.select_related().all() |
| 2601 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2602 | id_serializer_class = ServiceAttributeIdSerializer |
| 2603 | filter_backends = (filters.DjangoFilterBackend,) |
| 2604 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 2605 | |
| 2606 | def get_serializer_class(self): |
| 2607 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2608 | if (no_hyperlinks): |
| 2609 | return self.id_serializer_class |
| 2610 | else: |
| 2611 | return self.serializer_class |
| 2612 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2613 | def get_queryset(self): |
| 2614 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2615 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2616 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2617 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2618 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2619 | response = {"error": "validation", |
| 2620 | "specific_error": "not serializer.is_valid()",
|
| 2621 | "reasons": serializer.errors}
|
| 2622 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2623 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2624 | obj.caller = request.user |
| 2625 | if obj.can_update(request.user): |
| 2626 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2627 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2628 | raise Exception("failed obj.can_update") |
| 2629 | |
| 2630 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2631 | if (ret.status_code%100 != 200): |
| 2632 | raise Exception(ret.data) |
| 2633 | |
| 2634 | return ret |
| 2635 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2636 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2637 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2638 | queryset = ServiceAttribute.objects.select_related().all() |
| 2639 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2640 | id_serializer_class = ServiceAttributeIdSerializer |
| 2641 | |
| 2642 | def get_serializer_class(self): |
| 2643 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2644 | if (no_hyperlinks): |
| 2645 | return self.id_serializer_class |
| 2646 | else: |
| 2647 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2648 | |
| 2649 | def get_queryset(self): |
| 2650 | return ServiceAttribute.select_by_user(self.request.user) |
| 2651 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2652 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2653 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2654 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2655 | |
| 2656 | |
| 2657 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2658 | class ControllerImagesList(generics.ListCreateAPIView): |
| 2659 | queryset = ControllerImages.objects.select_related().all() |
| 2660 | serializer_class = ControllerImagesSerializer |
| 2661 | id_serializer_class = ControllerImagesIdSerializer |
| 2662 | filter_backends = (filters.DjangoFilterBackend,) |
| 2663 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 2664 | |
| 2665 | def get_serializer_class(self): |
| 2666 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2667 | if (no_hyperlinks): |
| 2668 | return self.id_serializer_class |
| 2669 | else: |
| 2670 | return self.serializer_class |
| 2671 | |
| 2672 | def get_queryset(self): |
| 2673 | return ControllerImages.select_by_user(self.request.user) |
| 2674 | |
| 2675 | def create(self, request, *args, **kwargs): |
| 2676 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2677 | if not (serializer.is_valid()): |
| 2678 | response = {"error": "validation", |
| 2679 | "specific_error": "not serializer.is_valid()",
|
| 2680 | "reasons": serializer.errors}
|
| 2681 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2682 | obj = serializer.object |
| 2683 | obj.caller = request.user |
| 2684 | if obj.can_update(request.user): |
| 2685 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2686 | else: |
| 2687 | raise Exception("failed obj.can_update") |
| 2688 | |
| 2689 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2690 | if (ret.status_code%100 != 200): |
| 2691 | raise Exception(ret.data) |
| 2692 | |
| 2693 | return ret |
| 2694 | |
| 2695 | |
| 2696 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2697 | queryset = ControllerImages.objects.select_related().all() |
| 2698 | serializer_class = ControllerImagesSerializer |
| 2699 | id_serializer_class = ControllerImagesIdSerializer |
| 2700 | |
| 2701 | def get_serializer_class(self): |
| 2702 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2703 | if (no_hyperlinks): |
| 2704 | return self.id_serializer_class |
| 2705 | else: |
| 2706 | return self.serializer_class |
| 2707 | |
| 2708 | def get_queryset(self): |
| 2709 | return ControllerImages.select_by_user(self.request.user) |
| 2710 | |
| 2711 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2712 | |
| 2713 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2714 | |
| 2715 | |
| 2716 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2717 | class ControllerSitePrivilegeList(generics.ListCreateAPIView): |
| 2718 | queryset = ControllerSitePrivilege.objects.select_related().all() |
| 2719 | serializer_class = ControllerSitePrivilegeSerializer |
| 2720 | id_serializer_class = ControllerSitePrivilegeIdSerializer |
| 2721 | filter_backends = (filters.DjangoFilterBackend,) |
| 2722 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',) |
| 2723 | |
| 2724 | def get_serializer_class(self): |
| 2725 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2726 | if (no_hyperlinks): |
| 2727 | return self.id_serializer_class |
| 2728 | else: |
| 2729 | return self.serializer_class |
| 2730 | |
| 2731 | def get_queryset(self): |
| 2732 | return ControllerSitePrivilege.select_by_user(self.request.user) |
| 2733 | |
| 2734 | def create(self, request, *args, **kwargs): |
| 2735 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2736 | if not (serializer.is_valid()): |
| 2737 | response = {"error": "validation", |
| 2738 | "specific_error": "not serializer.is_valid()",
|
| 2739 | "reasons": serializer.errors}
|
| 2740 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2741 | obj = serializer.object |
| 2742 | obj.caller = request.user |
| 2743 | if obj.can_update(request.user): |
| 2744 | return super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs) |
| 2745 | else: |
| 2746 | raise Exception("failed obj.can_update") |
| 2747 | |
| 2748 | ret = super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs) |
| 2749 | if (ret.status_code%100 != 200): |
| 2750 | raise Exception(ret.data) |
| 2751 | |
| 2752 | return ret |
| 2753 | |
| 2754 | |
| 2755 | class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2756 | queryset = ControllerSitePrivilege.objects.select_related().all() |
| 2757 | serializer_class = ControllerSitePrivilegeSerializer |
| 2758 | id_serializer_class = ControllerSitePrivilegeIdSerializer |
| 2759 | |
| 2760 | def get_serializer_class(self): |
| 2761 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2762 | if (no_hyperlinks): |
| 2763 | return self.id_serializer_class |
| 2764 | else: |
| 2765 | return self.serializer_class |
| 2766 | |
| 2767 | def get_queryset(self): |
| 2768 | return ControllerSitePrivilege.select_by_user(self.request.user) |
| 2769 | |
| 2770 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2771 | |
| 2772 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2773 | |
| 2774 | |
| 2775 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2776 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2777 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2778 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2779 | id_serializer_class = ImageIdSerializer |
| 2780 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 2781 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2782 | |
| 2783 | def get_serializer_class(self): |
| 2784 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2785 | if (no_hyperlinks): |
| 2786 | return self.id_serializer_class |
| 2787 | else: |
| 2788 | return self.serializer_class |
| 2789 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2790 | def get_queryset(self): |
| 2791 | return Image.select_by_user(self.request.user) |
| 2792 | |
| 2793 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2794 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2795 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2796 | response = {"error": "validation", |
| 2797 | "specific_error": "not serializer.is_valid()",
|
| 2798 | "reasons": serializer.errors}
|
| 2799 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2800 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2801 | obj.caller = request.user |
| 2802 | if obj.can_update(request.user): |
| 2803 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2804 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2805 | raise Exception("failed obj.can_update") |
| 2806 | |
| 2807 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2808 | if (ret.status_code%100 != 200): |
| 2809 | raise Exception(ret.data) |
| 2810 | |
| 2811 | return ret |
| 2812 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2813 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2814 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2815 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2816 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2817 | id_serializer_class = ImageIdSerializer |
| 2818 | |
| 2819 | def get_serializer_class(self): |
| 2820 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2821 | if (no_hyperlinks): |
| 2822 | return self.id_serializer_class |
| 2823 | else: |
| 2824 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2825 | |
| 2826 | def get_queryset(self): |
| 2827 | return Image.select_by_user(self.request.user) |
| 2828 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2829 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2830 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2831 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2832 | |
| 2833 | |
| 2834 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2835 | class NetworkParameterList(generics.ListCreateAPIView): |
| 2836 | queryset = NetworkParameter.objects.select_related().all() |
| 2837 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2838 | id_serializer_class = NetworkParameterIdSerializer |
| 2839 | filter_backends = (filters.DjangoFilterBackend,) |
| 2840 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 2841 | |
| 2842 | def get_serializer_class(self): |
| 2843 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2844 | if (no_hyperlinks): |
| 2845 | return self.id_serializer_class |
| 2846 | else: |
| 2847 | return self.serializer_class |
| 2848 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2849 | def get_queryset(self): |
| 2850 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2851 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2852 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2853 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2854 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2855 | response = {"error": "validation", |
| 2856 | "specific_error": "not serializer.is_valid()",
|
| 2857 | "reasons": serializer.errors}
|
| 2858 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2859 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2860 | obj.caller = request.user |
| 2861 | if obj.can_update(request.user): |
| 2862 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2863 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2864 | raise Exception("failed obj.can_update") |
| 2865 | |
| 2866 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2867 | if (ret.status_code%100 != 200): |
| 2868 | raise Exception(ret.data) |
| 2869 | |
| 2870 | return ret |
| 2871 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2872 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2873 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2874 | queryset = NetworkParameter.objects.select_related().all() |
| 2875 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2876 | id_serializer_class = NetworkParameterIdSerializer |
| 2877 | |
| 2878 | def get_serializer_class(self): |
| 2879 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2880 | if (no_hyperlinks): |
| 2881 | return self.id_serializer_class |
| 2882 | else: |
| 2883 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2884 | |
| 2885 | def get_queryset(self): |
| 2886 | return NetworkParameter.select_by_user(self.request.user) |
| 2887 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2888 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2889 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2890 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2891 | |
| 2892 | |
| 2893 | |
| 2894 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2895 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2896 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2897 | id_serializer_class = SiteIdSerializer |
| 2898 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2899 | filter_fields = ('id','created','updated','enacted','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] | 2900 | |
| 2901 | def get_serializer_class(self): |
| 2902 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2903 | if (no_hyperlinks): |
| 2904 | return self.id_serializer_class |
| 2905 | else: |
| 2906 | return self.serializer_class |
| 2907 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2908 | def get_queryset(self): |
| 2909 | return Site.select_by_user(self.request.user) |
| 2910 | |
| 2911 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2912 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2913 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2914 | response = {"error": "validation", |
| 2915 | "specific_error": "not serializer.is_valid()",
|
| 2916 | "reasons": serializer.errors}
|
| 2917 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2918 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2919 | obj.caller = request.user |
| 2920 | if obj.can_update(request.user): |
| 2921 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2922 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2923 | raise Exception("failed obj.can_update") |
| 2924 | |
| 2925 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2926 | if (ret.status_code%100 != 200): |
| 2927 | raise Exception(ret.data) |
| 2928 | |
| 2929 | return ret |
| 2930 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2931 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2932 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2933 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2934 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2935 | id_serializer_class = SiteIdSerializer |
| 2936 | |
| 2937 | def get_serializer_class(self): |
| 2938 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2939 | if (no_hyperlinks): |
| 2940 | return self.id_serializer_class |
| 2941 | else: |
| 2942 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2943 | |
| 2944 | def get_queryset(self): |
| 2945 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2946 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2947 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2948 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2949 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2950 | |
| 2951 | |
| 2952 | |
| 2953 | class SliceRoleList(generics.ListCreateAPIView): |
| 2954 | queryset = SliceRole.objects.select_related().all() |
| 2955 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2956 | id_serializer_class = SliceRoleIdSerializer |
| 2957 | filter_backends = (filters.DjangoFilterBackend,) |
| 2958 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2959 | |
| 2960 | def get_serializer_class(self): |
| 2961 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2962 | if (no_hyperlinks): |
| 2963 | return self.id_serializer_class |
| 2964 | else: |
| 2965 | return self.serializer_class |
| 2966 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2967 | def get_queryset(self): |
| 2968 | return SliceRole.select_by_user(self.request.user) |
| 2969 | |
| 2970 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2971 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2972 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2973 | response = {"error": "validation", |
| 2974 | "specific_error": "not serializer.is_valid()",
|
| 2975 | "reasons": serializer.errors}
|
| 2976 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2977 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2978 | obj.caller = request.user |
| 2979 | if obj.can_update(request.user): |
| 2980 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2981 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2982 | raise Exception("failed obj.can_update") |
| 2983 | |
| 2984 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2985 | if (ret.status_code%100 != 200): |
| 2986 | raise Exception(ret.data) |
| 2987 | |
| 2988 | return ret |
| 2989 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2990 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2991 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2992 | queryset = SliceRole.objects.select_related().all() |
| 2993 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2994 | id_serializer_class = SliceRoleIdSerializer |
| 2995 | |
| 2996 | def get_serializer_class(self): |
| 2997 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2998 | if (no_hyperlinks): |
| 2999 | return self.id_serializer_class |
| 3000 | else: |
| 3001 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3002 | |
| 3003 | def get_queryset(self): |
| 3004 | return SliceRole.select_by_user(self.request.user) |
| 3005 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3006 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3007 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3008 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3009 | |
| 3010 | |
| 3011 | |
| 3012 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3013 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3014 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3015 | id_serializer_class = TagIdSerializer |
| 3016 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3017 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3018 | |
| 3019 | def get_serializer_class(self): |
| 3020 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3021 | if (no_hyperlinks): |
| 3022 | return self.id_serializer_class |
| 3023 | else: |
| 3024 | return self.serializer_class |
| 3025 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3026 | def get_queryset(self): |
| 3027 | return Tag.select_by_user(self.request.user) |
| 3028 | |
| 3029 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3030 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3031 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3032 | response = {"error": "validation", |
| 3033 | "specific_error": "not serializer.is_valid()",
|
| 3034 | "reasons": serializer.errors}
|
| 3035 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3036 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3037 | obj.caller = request.user |
| 3038 | if obj.can_update(request.user): |
| 3039 | return super(TagList, self).create(request, *args, **kwargs) |
| 3040 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3041 | raise Exception("failed obj.can_update") |
| 3042 | |
| 3043 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 3044 | if (ret.status_code%100 != 200): |
| 3045 | raise Exception(ret.data) |
| 3046 | |
| 3047 | return ret |
| 3048 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3049 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3050 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3051 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3052 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3053 | id_serializer_class = TagIdSerializer |
| 3054 | |
| 3055 | def get_serializer_class(self): |
| 3056 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3057 | if (no_hyperlinks): |
| 3058 | return self.id_serializer_class |
| 3059 | else: |
| 3060 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3061 | |
| 3062 | def get_queryset(self): |
| 3063 | return Tag.select_by_user(self.request.user) |
| 3064 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3065 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3066 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3067 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3068 | |
| 3069 | |
| 3070 | |
| 3071 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3072 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3073 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3074 | id_serializer_class = InvoiceIdSerializer |
| 3075 | filter_backends = (filters.DjangoFilterBackend,) |
| 3076 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 3077 | |
| 3078 | def get_serializer_class(self): |
| 3079 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3080 | if (no_hyperlinks): |
| 3081 | return self.id_serializer_class |
| 3082 | else: |
| 3083 | return self.serializer_class |
| 3084 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3085 | def get_queryset(self): |
| 3086 | return Invoice.select_by_user(self.request.user) |
| 3087 | |
| 3088 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3089 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3090 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3091 | response = {"error": "validation", |
| 3092 | "specific_error": "not serializer.is_valid()",
|
| 3093 | "reasons": serializer.errors}
|
| 3094 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3095 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3096 | obj.caller = request.user |
| 3097 | if obj.can_update(request.user): |
| 3098 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 3099 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3100 | raise Exception("failed obj.can_update") |
| 3101 | |
| 3102 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 3103 | if (ret.status_code%100 != 200): |
| 3104 | raise Exception(ret.data) |
| 3105 | |
| 3106 | return ret |
| 3107 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3108 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3109 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3110 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3111 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3112 | id_serializer_class = InvoiceIdSerializer |
| 3113 | |
| 3114 | def get_serializer_class(self): |
| 3115 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3116 | if (no_hyperlinks): |
| 3117 | return self.id_serializer_class |
| 3118 | else: |
| 3119 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3120 | |
| 3121 | def get_queryset(self): |
| 3122 | return Invoice.select_by_user(self.request.user) |
| 3123 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3124 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3125 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3126 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3127 | |
| 3128 | |
| 3129 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3130 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 3131 | queryset = SlicePrivilege.objects.select_related().all() |
| 3132 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3133 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3134 | filter_backends = (filters.DjangoFilterBackend,) |
| 3135 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 3136 | |
| 3137 | def get_serializer_class(self): |
| 3138 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3139 | if (no_hyperlinks): |
| 3140 | return self.id_serializer_class |
| 3141 | else: |
| 3142 | return self.serializer_class |
| 3143 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3144 | def get_queryset(self): |
| 3145 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3146 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3147 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3148 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3149 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3150 | response = {"error": "validation", |
| 3151 | "specific_error": "not serializer.is_valid()",
|
| 3152 | "reasons": serializer.errors}
|
| 3153 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3154 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3155 | obj.caller = request.user |
| 3156 | if obj.can_update(request.user): |
| 3157 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3158 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3159 | raise Exception("failed obj.can_update") |
| 3160 | |
| 3161 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3162 | if (ret.status_code%100 != 200): |
| 3163 | raise Exception(ret.data) |
| 3164 | |
| 3165 | return ret |
| 3166 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3167 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3168 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3169 | queryset = SlicePrivilege.objects.select_related().all() |
| 3170 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3171 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3172 | |
| 3173 | def get_serializer_class(self): |
| 3174 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3175 | if (no_hyperlinks): |
| 3176 | return self.id_serializer_class |
| 3177 | else: |
| 3178 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3179 | |
| 3180 | def get_queryset(self): |
| 3181 | return SlicePrivilege.select_by_user(self.request.user) |
| 3182 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3183 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3184 | |
| 3185 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3186 | |
| 3187 | |
| 3188 | |
| 3189 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 3190 | queryset = PlanetStackRole.objects.select_related().all() |
| 3191 | serializer_class = PlanetStackRoleSerializer |
| 3192 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3193 | filter_backends = (filters.DjangoFilterBackend,) |
| 3194 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3195 | |
| 3196 | def get_serializer_class(self): |
| 3197 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3198 | if (no_hyperlinks): |
| 3199 | return self.id_serializer_class |
| 3200 | else: |
| 3201 | return self.serializer_class |
| 3202 | |
| 3203 | def get_queryset(self): |
| 3204 | return PlanetStackRole.select_by_user(self.request.user) |
| 3205 | |
| 3206 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3207 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3208 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3209 | response = {"error": "validation", |
| 3210 | "specific_error": "not serializer.is_valid()",
|
| 3211 | "reasons": serializer.errors}
|
| 3212 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3213 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3214 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3215 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3216 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3217 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3218 | raise Exception("failed obj.can_update") |
| 3219 | |
| 3220 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 3221 | if (ret.status_code%100 != 200): |
| 3222 | raise Exception(ret.data) |
| 3223 | |
| 3224 | return ret |
| 3225 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3226 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3227 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3228 | queryset = PlanetStackRole.objects.select_related().all() |
| 3229 | serializer_class = PlanetStackRoleSerializer |
| 3230 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3231 | |
| 3232 | def get_serializer_class(self): |
| 3233 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3234 | if (no_hyperlinks): |
| 3235 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3236 | else: |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3237 | return self.serializer_class |
| 3238 | |
| 3239 | def get_queryset(self): |
| 3240 | return PlanetStackRole.select_by_user(self.request.user) |
| 3241 | |
| 3242 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3243 | |
| 3244 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3245 | |
| 3246 | |
| 3247 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3248 | class NetworkSliverList(generics.ListCreateAPIView): |
| 3249 | queryset = NetworkSliver.objects.select_related().all() |
| 3250 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3251 | id_serializer_class = NetworkSliverIdSerializer |
| 3252 | filter_backends = (filters.DjangoFilterBackend,) |
| 3253 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 3254 | |
| 3255 | def get_serializer_class(self): |
| 3256 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3257 | if (no_hyperlinks): |
| 3258 | return self.id_serializer_class |
| 3259 | else: |
| 3260 | return self.serializer_class |
| 3261 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3262 | def get_queryset(self): |
| 3263 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3264 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3265 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3266 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3267 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3268 | response = {"error": "validation", |
| 3269 | "specific_error": "not serializer.is_valid()",
|
| 3270 | "reasons": serializer.errors}
|
| 3271 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3272 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3273 | obj.caller = request.user |
| 3274 | if obj.can_update(request.user): |
| 3275 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3276 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3277 | raise Exception("failed obj.can_update") |
| 3278 | |
| 3279 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3280 | if (ret.status_code%100 != 200): |
| 3281 | raise Exception(ret.data) |
| 3282 | |
| 3283 | return ret |
| 3284 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3285 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3286 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3287 | queryset = NetworkSliver.objects.select_related().all() |
| 3288 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3289 | id_serializer_class = NetworkSliverIdSerializer |
| 3290 | |
| 3291 | def get_serializer_class(self): |
| 3292 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3293 | if (no_hyperlinks): |
| 3294 | return self.id_serializer_class |
| 3295 | else: |
| 3296 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3297 | |
| 3298 | def get_queryset(self): |
| 3299 | return NetworkSliver.select_by_user(self.request.user) |
| 3300 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3301 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3302 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3303 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3304 | |
| 3305 | |
| 3306 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3307 | class FlavorList(generics.ListCreateAPIView): |
| 3308 | queryset = Flavor.objects.select_related().all() |
| 3309 | serializer_class = FlavorSerializer |
| 3310 | id_serializer_class = FlavorIdSerializer |
| 3311 | filter_backends = (filters.DjangoFilterBackend,) |
| 3312 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 3313 | |
| 3314 | def get_serializer_class(self): |
| 3315 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3316 | if (no_hyperlinks): |
| 3317 | return self.id_serializer_class |
| 3318 | else: |
| 3319 | return self.serializer_class |
| 3320 | |
| 3321 | def get_queryset(self): |
| 3322 | return Flavor.select_by_user(self.request.user) |
| 3323 | |
| 3324 | def create(self, request, *args, **kwargs): |
| 3325 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3326 | if not (serializer.is_valid()): |
| 3327 | response = {"error": "validation", |
| 3328 | "specific_error": "not serializer.is_valid()",
|
| 3329 | "reasons": serializer.errors}
|
| 3330 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3331 | obj = serializer.object |
| 3332 | obj.caller = request.user |
| 3333 | if obj.can_update(request.user): |
| 3334 | return super(FlavorList, self).create(request, *args, **kwargs) |
| 3335 | else: |
| 3336 | raise Exception("failed obj.can_update") |
| 3337 | |
| 3338 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 3339 | if (ret.status_code%100 != 200): |
| 3340 | raise Exception(ret.data) |
| 3341 | |
| 3342 | return ret |
| 3343 | |
| 3344 | |
| 3345 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3346 | queryset = Flavor.objects.select_related().all() |
| 3347 | serializer_class = FlavorSerializer |
| 3348 | id_serializer_class = FlavorIdSerializer |
| 3349 | |
| 3350 | def get_serializer_class(self): |
| 3351 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3352 | if (no_hyperlinks): |
| 3353 | return self.id_serializer_class |
| 3354 | else: |
| 3355 | return self.serializer_class |
| 3356 | |
| 3357 | def get_queryset(self): |
| 3358 | return Flavor.select_by_user(self.request.user) |
| 3359 | |
| 3360 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3361 | |
| 3362 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3363 | |
| 3364 | |
| 3365 | |
| 3366 | class ControllerSiteList(generics.ListCreateAPIView): |
| 3367 | queryset = ControllerSite.objects.select_related().all() |
| 3368 | serializer_class = ControllerSiteSerializer |
| 3369 | id_serializer_class = ControllerSiteIdSerializer |
| 3370 | filter_backends = (filters.DjangoFilterBackend,) |
| 3371 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',) |
| 3372 | |
| 3373 | def get_serializer_class(self): |
| 3374 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3375 | if (no_hyperlinks): |
| 3376 | return self.id_serializer_class |
| 3377 | else: |
| 3378 | return self.serializer_class |
| 3379 | |
| 3380 | def get_queryset(self): |
| 3381 | return ControllerSite.select_by_user(self.request.user) |
| 3382 | |
| 3383 | def create(self, request, *args, **kwargs): |
| 3384 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3385 | if not (serializer.is_valid()): |
| 3386 | response = {"error": "validation", |
| 3387 | "specific_error": "not serializer.is_valid()",
|
| 3388 | "reasons": serializer.errors}
|
| 3389 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3390 | obj = serializer.object |
| 3391 | obj.caller = request.user |
| 3392 | if obj.can_update(request.user): |
| 3393 | return super(ControllerSiteList, self).create(request, *args, **kwargs) |
| 3394 | else: |
| 3395 | raise Exception("failed obj.can_update") |
| 3396 | |
| 3397 | ret = super(ControllerSiteList, self).create(request, *args, **kwargs) |
| 3398 | if (ret.status_code%100 != 200): |
| 3399 | raise Exception(ret.data) |
| 3400 | |
| 3401 | return ret |
| 3402 | |
| 3403 | |
| 3404 | class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3405 | queryset = ControllerSite.objects.select_related().all() |
| 3406 | serializer_class = ControllerSiteSerializer |
| 3407 | id_serializer_class = ControllerSiteIdSerializer |
| 3408 | |
| 3409 | def get_serializer_class(self): |
| 3410 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3411 | if (no_hyperlinks): |
| 3412 | return self.id_serializer_class |
| 3413 | else: |
| 3414 | return self.serializer_class |
| 3415 | |
| 3416 | def get_queryset(self): |
| 3417 | return ControllerSite.select_by_user(self.request.user) |
| 3418 | |
| 3419 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3420 | |
| 3421 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3422 | |
| 3423 | |
| 3424 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3425 | class ProjectList(generics.ListCreateAPIView): |
| 3426 | queryset = Project.objects.select_related().all() |
| 3427 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3428 | id_serializer_class = ProjectIdSerializer |
| 3429 | filter_backends = (filters.DjangoFilterBackend,) |
| 3430 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3431 | |
| 3432 | def get_serializer_class(self): |
| 3433 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3434 | if (no_hyperlinks): |
| 3435 | return self.id_serializer_class |
| 3436 | else: |
| 3437 | return self.serializer_class |
| 3438 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3439 | def get_queryset(self): |
| 3440 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3441 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3442 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3443 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3444 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3445 | response = {"error": "validation", |
| 3446 | "specific_error": "not serializer.is_valid()",
|
| 3447 | "reasons": serializer.errors}
|
| 3448 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3449 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3450 | obj.caller = request.user |
| 3451 | if obj.can_update(request.user): |
| 3452 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 3453 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3454 | raise Exception("failed obj.can_update") |
| 3455 | |
| 3456 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 3457 | if (ret.status_code%100 != 200): |
| 3458 | raise Exception(ret.data) |
| 3459 | |
| 3460 | return ret |
| 3461 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3462 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3463 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3464 | queryset = Project.objects.select_related().all() |
| 3465 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3466 | id_serializer_class = ProjectIdSerializer |
| 3467 | |
| 3468 | def get_serializer_class(self): |
| 3469 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3470 | if (no_hyperlinks): |
| 3471 | return self.id_serializer_class |
| 3472 | else: |
| 3473 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3474 | |
| 3475 | def get_queryset(self): |
| 3476 | return Project.select_by_user(self.request.user) |
| 3477 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3478 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3479 | |
| 3480 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3481 | |
| 3482 | |
| 3483 | |
| 3484 | class SliceList(generics.ListCreateAPIView): |
| 3485 | queryset = Slice.objects.select_related().all() |
| 3486 | serializer_class = SliceSerializer |
| 3487 | id_serializer_class = SliceIdSerializer |
| 3488 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3489 | filter_fields = ('id','created','updated','enacted','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] | 3490 | |
| 3491 | def get_serializer_class(self): |
| 3492 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3493 | if (no_hyperlinks): |
| 3494 | return self.id_serializer_class |
| 3495 | else: |
| 3496 | return self.serializer_class |
| 3497 | |
| 3498 | def get_queryset(self): |
| 3499 | return Slice.select_by_user(self.request.user) |
| 3500 | |
| 3501 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3502 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3503 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3504 | response = {"error": "validation", |
| 3505 | "specific_error": "not serializer.is_valid()",
|
| 3506 | "reasons": serializer.errors}
|
| 3507 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3508 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3509 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3510 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3511 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3512 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3513 | raise Exception("failed obj.can_update") |
| 3514 | |
| 3515 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3516 | if (ret.status_code%100 != 200): |
| 3517 | raise Exception(ret.data) |
| 3518 | |
| 3519 | return ret |
| 3520 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3521 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3522 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3523 | queryset = Slice.objects.select_related().all() |
| 3524 | serializer_class = SliceSerializer |
| 3525 | id_serializer_class = SliceIdSerializer |
| 3526 | |
| 3527 | def get_serializer_class(self): |
| 3528 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3529 | if (no_hyperlinks): |
| 3530 | return self.id_serializer_class |
| 3531 | else: |
| 3532 | return self.serializer_class |
| 3533 | |
| 3534 | def get_queryset(self): |
| 3535 | return Slice.select_by_user(self.request.user) |
| 3536 | |
| 3537 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3538 | |
| 3539 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3540 | |
| 3541 | |
| 3542 | |
| 3543 | class NetworkList(generics.ListCreateAPIView): |
| 3544 | queryset = Network.objects.select_related().all() |
| 3545 | serializer_class = NetworkSerializer |
| 3546 | id_serializer_class = NetworkIdSerializer |
| 3547 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | d188c01 | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 3548 | filter_fields = ('id','created','updated','enacted','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] | 3549 | |
| 3550 | def get_serializer_class(self): |
| 3551 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3552 | if (no_hyperlinks): |
| 3553 | return self.id_serializer_class |
| 3554 | else: |
| 3555 | return self.serializer_class |
| 3556 | |
| 3557 | def get_queryset(self): |
| 3558 | return Network.select_by_user(self.request.user) |
| 3559 | |
| 3560 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3561 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3562 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3563 | response = {"error": "validation", |
| 3564 | "specific_error": "not serializer.is_valid()",
|
| 3565 | "reasons": serializer.errors}
|
| 3566 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3567 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3568 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3569 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3570 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3571 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3572 | raise Exception("failed obj.can_update") |
| 3573 | |
| 3574 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3575 | if (ret.status_code%100 != 200): |
| 3576 | raise Exception(ret.data) |
| 3577 | |
| 3578 | return ret |
| 3579 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3580 | |
| 3581 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3582 | queryset = Network.objects.select_related().all() |
| 3583 | serializer_class = NetworkSerializer |
| 3584 | id_serializer_class = NetworkIdSerializer |
| 3585 | |
| 3586 | def get_serializer_class(self): |
| 3587 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3588 | if (no_hyperlinks): |
| 3589 | return self.id_serializer_class |
| 3590 | else: |
| 3591 | return self.serializer_class |
| 3592 | |
| 3593 | def get_queryset(self): |
| 3594 | return Network.select_by_user(self.request.user) |
| 3595 | |
| 3596 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3597 | |
| 3598 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3599 | |
| 3600 | |
| 3601 | |
| 3602 | class ServiceList(generics.ListCreateAPIView): |
| 3603 | queryset = Service.objects.select_related().all() |
| 3604 | serializer_class = ServiceSerializer |
| 3605 | id_serializer_class = ServiceIdSerializer |
| 3606 | filter_backends = (filters.DjangoFilterBackend,) |
| 3607 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 3608 | |
| 3609 | def get_serializer_class(self): |
| 3610 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3611 | if (no_hyperlinks): |
| 3612 | return self.id_serializer_class |
| 3613 | else: |
| 3614 | return self.serializer_class |
| 3615 | |
| 3616 | def get_queryset(self): |
| 3617 | return Service.select_by_user(self.request.user) |
| 3618 | |
| 3619 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3620 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3621 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3622 | response = {"error": "validation", |
| 3623 | "specific_error": "not serializer.is_valid()",
|
| 3624 | "reasons": serializer.errors}
|
| 3625 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3626 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3627 | obj.caller = request.user |
| 3628 | if obj.can_update(request.user): |
| 3629 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3630 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3631 | raise Exception("failed obj.can_update") |
| 3632 | |
| 3633 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3634 | if (ret.status_code%100 != 200): |
| 3635 | raise Exception(ret.data) |
| 3636 | |
| 3637 | return ret |
| 3638 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3639 | |
| 3640 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3641 | queryset = Service.objects.select_related().all() |
| 3642 | serializer_class = ServiceSerializer |
| 3643 | id_serializer_class = ServiceIdSerializer |
| 3644 | |
| 3645 | def get_serializer_class(self): |
| 3646 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3647 | if (no_hyperlinks): |
| 3648 | return self.id_serializer_class |
| 3649 | else: |
| 3650 | return self.serializer_class |
| 3651 | |
| 3652 | def get_queryset(self): |
| 3653 | return Service.select_by_user(self.request.user) |
| 3654 | |
| 3655 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3656 | |
| 3657 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3658 | |
| 3659 | |
| 3660 | |
| 3661 | class ServiceClassList(generics.ListCreateAPIView): |
| 3662 | queryset = ServiceClass.objects.select_related().all() |
| 3663 | serializer_class = ServiceClassSerializer |
| 3664 | id_serializer_class = ServiceClassIdSerializer |
| 3665 | filter_backends = (filters.DjangoFilterBackend,) |
| 3666 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 3667 | |
| 3668 | def get_serializer_class(self): |
| 3669 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3670 | if (no_hyperlinks): |
| 3671 | return self.id_serializer_class |
| 3672 | else: |
| 3673 | return self.serializer_class |
| 3674 | |
| 3675 | def get_queryset(self): |
| 3676 | return ServiceClass.select_by_user(self.request.user) |
| 3677 | |
| 3678 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3679 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3680 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3681 | response = {"error": "validation", |
| 3682 | "specific_error": "not serializer.is_valid()",
|
| 3683 | "reasons": serializer.errors}
|
| 3684 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3685 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3686 | obj.caller = request.user |
| 3687 | if obj.can_update(request.user): |
| 3688 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3689 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3690 | raise Exception("failed obj.can_update") |
| 3691 | |
| 3692 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3693 | if (ret.status_code%100 != 200): |
| 3694 | raise Exception(ret.data) |
| 3695 | |
| 3696 | return ret |
| 3697 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3698 | |
| 3699 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3700 | queryset = ServiceClass.objects.select_related().all() |
| 3701 | serializer_class = ServiceClassSerializer |
| 3702 | id_serializer_class = ServiceClassIdSerializer |
| 3703 | |
| 3704 | def get_serializer_class(self): |
| 3705 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3706 | if (no_hyperlinks): |
| 3707 | return self.id_serializer_class |
| 3708 | else: |
| 3709 | return self.serializer_class |
| 3710 | |
| 3711 | def get_queryset(self): |
| 3712 | return ServiceClass.select_by_user(self.request.user) |
| 3713 | |
| 3714 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3715 | |
| 3716 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3717 | |
| 3718 | |
| 3719 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3720 | class PlanetStackList(generics.ListCreateAPIView): |
| 3721 | queryset = PlanetStack.objects.select_related().all() |
| 3722 | serializer_class = PlanetStackSerializer |
| 3723 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3724 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3725 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3726 | |
| 3727 | def get_serializer_class(self): |
| 3728 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3729 | if (no_hyperlinks): |
| 3730 | return self.id_serializer_class |
| 3731 | else: |
| 3732 | return self.serializer_class |
| 3733 | |
| 3734 | def get_queryset(self): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3735 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3736 | |
| 3737 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3738 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3739 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3740 | response = {"error": "validation", |
| 3741 | "specific_error": "not serializer.is_valid()",
|
| 3742 | "reasons": serializer.errors}
|
| 3743 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3744 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3745 | obj.caller = request.user |
| 3746 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3747 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3748 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3749 | raise Exception("failed obj.can_update") |
| 3750 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3751 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3752 | if (ret.status_code%100 != 200): |
| 3753 | raise Exception(ret.data) |
| 3754 | |
| 3755 | return ret |
| 3756 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3757 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3758 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3759 | queryset = PlanetStack.objects.select_related().all() |
| 3760 | serializer_class = PlanetStackSerializer |
| 3761 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3762 | |
| 3763 | def get_serializer_class(self): |
| 3764 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3765 | if (no_hyperlinks): |
| 3766 | return self.id_serializer_class |
| 3767 | else: |
| 3768 | return self.serializer_class |
| 3769 | |
| 3770 | def get_queryset(self): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3771 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3772 | |
| 3773 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3774 | |
| 3775 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3776 | |
| 3777 | |
| 3778 | |
| 3779 | class ChargeList(generics.ListCreateAPIView): |
| 3780 | queryset = Charge.objects.select_related().all() |
| 3781 | serializer_class = ChargeSerializer |
| 3782 | id_serializer_class = ChargeIdSerializer |
| 3783 | filter_backends = (filters.DjangoFilterBackend,) |
| 3784 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 3785 | |
| 3786 | def get_serializer_class(self): |
| 3787 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3788 | if (no_hyperlinks): |
| 3789 | return self.id_serializer_class |
| 3790 | else: |
| 3791 | return self.serializer_class |
| 3792 | |
| 3793 | def get_queryset(self): |
| 3794 | return Charge.select_by_user(self.request.user) |
| 3795 | |
| 3796 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3797 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3798 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3799 | response = {"error": "validation", |
| 3800 | "specific_error": "not serializer.is_valid()",
|
| 3801 | "reasons": serializer.errors}
|
| 3802 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3803 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3804 | obj.caller = request.user |
| 3805 | if obj.can_update(request.user): |
| 3806 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3807 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3808 | raise Exception("failed obj.can_update") |
| 3809 | |
| 3810 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3811 | if (ret.status_code%100 != 200): |
| 3812 | raise Exception(ret.data) |
| 3813 | |
| 3814 | return ret |
| 3815 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3816 | |
| 3817 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3818 | queryset = Charge.objects.select_related().all() |
| 3819 | serializer_class = ChargeSerializer |
| 3820 | id_serializer_class = ChargeIdSerializer |
| 3821 | |
| 3822 | def get_serializer_class(self): |
| 3823 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3824 | if (no_hyperlinks): |
| 3825 | return self.id_serializer_class |
| 3826 | else: |
| 3827 | return self.serializer_class |
| 3828 | |
| 3829 | def get_queryset(self): |
| 3830 | return Charge.select_by_user(self.request.user) |
| 3831 | |
| 3832 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3833 | |
| 3834 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3835 | |
| 3836 | |
| 3837 | |
| 3838 | class RoleList(generics.ListCreateAPIView): |
| 3839 | queryset = Role.objects.select_related().all() |
| 3840 | serializer_class = RoleSerializer |
| 3841 | id_serializer_class = RoleIdSerializer |
| 3842 | filter_backends = (filters.DjangoFilterBackend,) |
| 3843 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 3844 | |
| 3845 | def get_serializer_class(self): |
| 3846 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3847 | if (no_hyperlinks): |
| 3848 | return self.id_serializer_class |
| 3849 | else: |
| 3850 | return self.serializer_class |
| 3851 | |
| 3852 | def get_queryset(self): |
| 3853 | return Role.select_by_user(self.request.user) |
| 3854 | |
| 3855 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3856 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3857 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3858 | response = {"error": "validation", |
| 3859 | "specific_error": "not serializer.is_valid()",
|
| 3860 | "reasons": serializer.errors}
|
| 3861 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3862 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3863 | obj.caller = request.user |
| 3864 | if obj.can_update(request.user): |
| 3865 | return super(RoleList, self).create(request, *args, **kwargs) |
| 3866 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3867 | raise Exception("failed obj.can_update") |
| 3868 | |
| 3869 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 3870 | if (ret.status_code%100 != 200): |
| 3871 | raise Exception(ret.data) |
| 3872 | |
| 3873 | return ret |
| 3874 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3875 | |
| 3876 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3877 | queryset = Role.objects.select_related().all() |
| 3878 | serializer_class = RoleSerializer |
| 3879 | id_serializer_class = RoleIdSerializer |
| 3880 | |
| 3881 | def get_serializer_class(self): |
| 3882 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3883 | if (no_hyperlinks): |
| 3884 | return self.id_serializer_class |
| 3885 | else: |
| 3886 | return self.serializer_class |
| 3887 | |
| 3888 | def get_queryset(self): |
| 3889 | return Role.select_by_user(self.request.user) |
| 3890 | |
| 3891 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3892 | |
| 3893 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3894 | |
| 3895 | |
| 3896 | |
| 3897 | class UsableObjectList(generics.ListCreateAPIView): |
| 3898 | queryset = UsableObject.objects.select_related().all() |
| 3899 | serializer_class = UsableObjectSerializer |
| 3900 | id_serializer_class = UsableObjectIdSerializer |
| 3901 | filter_backends = (filters.DjangoFilterBackend,) |
| 3902 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3903 | |
| 3904 | def get_serializer_class(self): |
| 3905 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3906 | if (no_hyperlinks): |
| 3907 | return self.id_serializer_class |
| 3908 | else: |
| 3909 | return self.serializer_class |
| 3910 | |
| 3911 | def get_queryset(self): |
| 3912 | return UsableObject.select_by_user(self.request.user) |
| 3913 | |
| 3914 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3915 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3916 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3917 | response = {"error": "validation", |
| 3918 | "specific_error": "not serializer.is_valid()",
|
| 3919 | "reasons": serializer.errors}
|
| 3920 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3921 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3922 | obj.caller = request.user |
| 3923 | if obj.can_update(request.user): |
| 3924 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3925 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3926 | raise Exception("failed obj.can_update") |
| 3927 | |
| 3928 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3929 | if (ret.status_code%100 != 200): |
| 3930 | raise Exception(ret.data) |
| 3931 | |
| 3932 | return ret |
| 3933 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3934 | |
| 3935 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3936 | queryset = UsableObject.objects.select_related().all() |
| 3937 | serializer_class = UsableObjectSerializer |
| 3938 | id_serializer_class = UsableObjectIdSerializer |
| 3939 | |
| 3940 | def get_serializer_class(self): |
| 3941 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3942 | if (no_hyperlinks): |
| 3943 | return self.id_serializer_class |
| 3944 | else: |
| 3945 | return self.serializer_class |
| 3946 | |
| 3947 | def get_queryset(self): |
| 3948 | return UsableObject.select_by_user(self.request.user) |
| 3949 | |
| 3950 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3951 | |
| 3952 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3953 | |
| 3954 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3955 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3956 | class SiteRoleList(generics.ListCreateAPIView): |
| 3957 | queryset = SiteRole.objects.select_related().all() |
| 3958 | serializer_class = SiteRoleSerializer |
| 3959 | id_serializer_class = SiteRoleIdSerializer |
| 3960 | filter_backends = (filters.DjangoFilterBackend,) |
| 3961 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3962 | |
| 3963 | def get_serializer_class(self): |
| 3964 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3965 | if (no_hyperlinks): |
| 3966 | return self.id_serializer_class |
| 3967 | else: |
| 3968 | return self.serializer_class |
| 3969 | |
| 3970 | def get_queryset(self): |
| 3971 | return SiteRole.select_by_user(self.request.user) |
| 3972 | |
| 3973 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3974 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3975 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3976 | response = {"error": "validation", |
| 3977 | "specific_error": "not serializer.is_valid()",
|
| 3978 | "reasons": serializer.errors}
|
| 3979 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3980 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3981 | obj.caller = request.user |
| 3982 | if obj.can_update(request.user): |
| 3983 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3984 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3985 | raise Exception("failed obj.can_update") |
| 3986 | |
| 3987 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3988 | if (ret.status_code%100 != 200): |
| 3989 | raise Exception(ret.data) |
| 3990 | |
| 3991 | return ret |
| 3992 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3993 | |
| 3994 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3995 | queryset = SiteRole.objects.select_related().all() |
| 3996 | serializer_class = SiteRoleSerializer |
| 3997 | id_serializer_class = SiteRoleIdSerializer |
| 3998 | |
| 3999 | def get_serializer_class(self): |
| 4000 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4001 | if (no_hyperlinks): |
| 4002 | return self.id_serializer_class |
| 4003 | else: |
| 4004 | return self.serializer_class |
| 4005 | |
| 4006 | def get_queryset(self): |
| 4007 | return SiteRole.select_by_user(self.request.user) |
| 4008 | |
| 4009 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4010 | |
| 4011 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4012 | |
| 4013 | |
| 4014 | |
| 4015 | class SliceCredentialList(generics.ListCreateAPIView): |
| 4016 | queryset = SliceCredential.objects.select_related().all() |
| 4017 | serializer_class = SliceCredentialSerializer |
| 4018 | id_serializer_class = SliceCredentialIdSerializer |
| 4019 | filter_backends = (filters.DjangoFilterBackend,) |
| 4020 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 4021 | |
| 4022 | def get_serializer_class(self): |
| 4023 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4024 | if (no_hyperlinks): |
| 4025 | return self.id_serializer_class |
| 4026 | else: |
| 4027 | return self.serializer_class |
| 4028 | |
| 4029 | def get_queryset(self): |
| 4030 | return SliceCredential.select_by_user(self.request.user) |
| 4031 | |
| 4032 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4033 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4034 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4035 | response = {"error": "validation", |
| 4036 | "specific_error": "not serializer.is_valid()",
|
| 4037 | "reasons": serializer.errors}
|
| 4038 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4039 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4040 | obj.caller = request.user |
| 4041 | if obj.can_update(request.user): |
| 4042 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 4043 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4044 | raise Exception("failed obj.can_update") |
| 4045 | |
| 4046 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 4047 | if (ret.status_code%100 != 200): |
| 4048 | raise Exception(ret.data) |
| 4049 | |
| 4050 | return ret |
| 4051 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4052 | |
| 4053 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4054 | queryset = SliceCredential.objects.select_related().all() |
| 4055 | serializer_class = SliceCredentialSerializer |
| 4056 | id_serializer_class = SliceCredentialIdSerializer |
| 4057 | |
| 4058 | def get_serializer_class(self): |
| 4059 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4060 | if (no_hyperlinks): |
| 4061 | return self.id_serializer_class |
| 4062 | else: |
| 4063 | return self.serializer_class |
| 4064 | |
| 4065 | def get_queryset(self): |
| 4066 | return SliceCredential.select_by_user(self.request.user) |
| 4067 | |
| 4068 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4069 | |
| 4070 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4071 | |
| 4072 | |
| 4073 | |
| 4074 | class SliverList(generics.ListCreateAPIView): |
| 4075 | queryset = Sliver.objects.select_related().all() |
| 4076 | serializer_class = SliverSerializer |
| 4077 | id_serializer_class = SliverIdSerializer |
| 4078 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 4079 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','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] | 4080 | |
| 4081 | def get_serializer_class(self): |
| 4082 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4083 | if (no_hyperlinks): |
| 4084 | return self.id_serializer_class |
| 4085 | else: |
| 4086 | return self.serializer_class |
| 4087 | |
| 4088 | def get_queryset(self): |
| 4089 | return Sliver.select_by_user(self.request.user) |
| 4090 | |
| 4091 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4092 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4093 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4094 | response = {"error": "validation", |
| 4095 | "specific_error": "not serializer.is_valid()",
|
| 4096 | "reasons": serializer.errors}
|
| 4097 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4098 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4099 | obj.caller = request.user |
| 4100 | if obj.can_update(request.user): |
| 4101 | return super(SliverList, self).create(request, *args, **kwargs) |
| 4102 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4103 | raise Exception("failed obj.can_update") |
| 4104 | |
| 4105 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 4106 | if (ret.status_code%100 != 200): |
| 4107 | raise Exception(ret.data) |
| 4108 | |
| 4109 | return ret |
| 4110 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4111 | |
| 4112 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4113 | queryset = Sliver.objects.select_related().all() |
| 4114 | serializer_class = SliverSerializer |
| 4115 | id_serializer_class = SliverIdSerializer |
| 4116 | |
| 4117 | def get_serializer_class(self): |
| 4118 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4119 | if (no_hyperlinks): |
| 4120 | return self.id_serializer_class |
| 4121 | else: |
| 4122 | return self.serializer_class |
| 4123 | |
| 4124 | def get_queryset(self): |
| 4125 | return Sliver.select_by_user(self.request.user) |
| 4126 | |
| 4127 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4128 | |
| 4129 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4130 | |
| 4131 | |
| 4132 | |
| 4133 | class NodeList(generics.ListCreateAPIView): |
| 4134 | queryset = Node.objects.select_related().all() |
| 4135 | serializer_class = NodeSerializer |
| 4136 | id_serializer_class = NodeIdSerializer |
| 4137 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4138 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4139 | |
| 4140 | def get_serializer_class(self): |
| 4141 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4142 | if (no_hyperlinks): |
| 4143 | return self.id_serializer_class |
| 4144 | else: |
| 4145 | return self.serializer_class |
| 4146 | |
| 4147 | def get_queryset(self): |
| 4148 | return Node.select_by_user(self.request.user) |
| 4149 | |
| 4150 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4151 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4152 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4153 | response = {"error": "validation", |
| 4154 | "specific_error": "not serializer.is_valid()",
|
| 4155 | "reasons": serializer.errors}
|
| 4156 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4157 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4158 | obj.caller = request.user |
| 4159 | if obj.can_update(request.user): |
| 4160 | return super(NodeList, self).create(request, *args, **kwargs) |
| 4161 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4162 | raise Exception("failed obj.can_update") |
| 4163 | |
| 4164 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 4165 | if (ret.status_code%100 != 200): |
| 4166 | raise Exception(ret.data) |
| 4167 | |
| 4168 | return ret |
| 4169 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4170 | |
| 4171 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4172 | queryset = Node.objects.select_related().all() |
| 4173 | serializer_class = NodeSerializer |
| 4174 | id_serializer_class = NodeIdSerializer |
| 4175 | |
| 4176 | def get_serializer_class(self): |
| 4177 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4178 | if (no_hyperlinks): |
| 4179 | return self.id_serializer_class |
| 4180 | else: |
| 4181 | return self.serializer_class |
| 4182 | |
| 4183 | def get_queryset(self): |
| 4184 | return Node.select_by_user(self.request.user) |
| 4185 | |
| 4186 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4187 | |
| 4188 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4189 | |
| 4190 | |
| 4191 | |
| 4192 | class DashboardViewList(generics.ListCreateAPIView): |
| 4193 | queryset = DashboardView.objects.select_related().all() |
| 4194 | serializer_class = DashboardViewSerializer |
| 4195 | id_serializer_class = DashboardViewIdSerializer |
| 4196 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4197 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4198 | |
| 4199 | def get_serializer_class(self): |
| 4200 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4201 | if (no_hyperlinks): |
| 4202 | return self.id_serializer_class |
| 4203 | else: |
| 4204 | return self.serializer_class |
| 4205 | |
| 4206 | def get_queryset(self): |
| 4207 | return DashboardView.select_by_user(self.request.user) |
| 4208 | |
| 4209 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4210 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4211 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4212 | response = {"error": "validation", |
| 4213 | "specific_error": "not serializer.is_valid()",
|
| 4214 | "reasons": serializer.errors}
|
| 4215 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4216 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4217 | obj.caller = request.user |
| 4218 | if obj.can_update(request.user): |
| 4219 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4220 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4221 | raise Exception("failed obj.can_update") |
| 4222 | |
| 4223 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4224 | if (ret.status_code%100 != 200): |
| 4225 | raise Exception(ret.data) |
| 4226 | |
| 4227 | return ret |
| 4228 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4229 | |
| 4230 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4231 | queryset = DashboardView.objects.select_related().all() |
| 4232 | serializer_class = DashboardViewSerializer |
| 4233 | id_serializer_class = DashboardViewIdSerializer |
| 4234 | |
| 4235 | def get_serializer_class(self): |
| 4236 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4237 | if (no_hyperlinks): |
| 4238 | return self.id_serializer_class |
| 4239 | else: |
| 4240 | return self.serializer_class |
| 4241 | |
| 4242 | def get_queryset(self): |
| 4243 | return DashboardView.select_by_user(self.request.user) |
| 4244 | |
| 4245 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4246 | |
| 4247 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4248 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4249 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4250 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4251 | class ControllerNetworkList(generics.ListCreateAPIView): |
| 4252 | queryset = ControllerNetwork.objects.select_related().all() |
| 4253 | serializer_class = ControllerNetworkSerializer |
| 4254 | id_serializer_class = ControllerNetworkIdSerializer |
| 4255 | filter_backends = (filters.DjangoFilterBackend,) |
| 4256 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
| 4257 | |
| 4258 | def get_serializer_class(self): |
| 4259 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4260 | if (no_hyperlinks): |
| 4261 | return self.id_serializer_class |
| 4262 | else: |
| 4263 | return self.serializer_class |
| 4264 | |
| 4265 | def get_queryset(self): |
| 4266 | return ControllerNetwork.select_by_user(self.request.user) |
| 4267 | |
| 4268 | def create(self, request, *args, **kwargs): |
| 4269 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4270 | if not (serializer.is_valid()): |
| 4271 | response = {"error": "validation", |
| 4272 | "specific_error": "not serializer.is_valid()",
|
| 4273 | "reasons": serializer.errors}
|
| 4274 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4275 | obj = serializer.object |
| 4276 | obj.caller = request.user |
| 4277 | if obj.can_update(request.user): |
| 4278 | return super(ControllerNetworkList, self).create(request, *args, **kwargs) |
| 4279 | else: |
| 4280 | raise Exception("failed obj.can_update") |
| 4281 | |
| 4282 | ret = super(ControllerNetworkList, self).create(request, *args, **kwargs) |
| 4283 | if (ret.status_code%100 != 200): |
| 4284 | raise Exception(ret.data) |
| 4285 | |
| 4286 | return ret |
| 4287 | |
| 4288 | |
| 4289 | class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4290 | queryset = ControllerNetwork.objects.select_related().all() |
| 4291 | serializer_class = ControllerNetworkSerializer |
| 4292 | id_serializer_class = ControllerNetworkIdSerializer |
| 4293 | |
| 4294 | def get_serializer_class(self): |
| 4295 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4296 | if (no_hyperlinks): |
| 4297 | return self.id_serializer_class |
| 4298 | else: |
| 4299 | return self.serializer_class |
| 4300 | |
| 4301 | def get_queryset(self): |
| 4302 | return ControllerNetwork.select_by_user(self.request.user) |
| 4303 | |
| 4304 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4305 | |
| 4306 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4307 | |
| 4308 | |
| 4309 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4310 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 4311 | queryset = ImageDeployments.objects.select_related().all() |
| 4312 | serializer_class = ImageDeploymentsSerializer |
| 4313 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4314 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4315 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4316 | |
| 4317 | def get_serializer_class(self): |
| 4318 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4319 | if (no_hyperlinks): |
| 4320 | return self.id_serializer_class |
| 4321 | else: |
| 4322 | return self.serializer_class |
| 4323 | |
| 4324 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4325 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4326 | |
| 4327 | def create(self, request, *args, **kwargs): |
| 4328 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4329 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4330 | response = {"error": "validation", |
| 4331 | "specific_error": "not serializer.is_valid()",
|
| 4332 | "reasons": serializer.errors}
|
| 4333 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4334 | obj = serializer.object |
| 4335 | obj.caller = request.user |
| 4336 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4337 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4338 | else: |
| 4339 | raise Exception("failed obj.can_update") |
| 4340 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4341 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4342 | if (ret.status_code%100 != 200): |
| 4343 | raise Exception(ret.data) |
| 4344 | |
| 4345 | return ret |
| 4346 | |
| 4347 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4348 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4349 | queryset = ImageDeployments.objects.select_related().all() |
| 4350 | serializer_class = ImageDeploymentsSerializer |
| 4351 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4352 | |
| 4353 | def get_serializer_class(self): |
| 4354 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4355 | if (no_hyperlinks): |
| 4356 | return self.id_serializer_class |
| 4357 | else: |
| 4358 | return self.serializer_class |
| 4359 | |
| 4360 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4361 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4362 | |
| 4363 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4364 | |
| 4365 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4366 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4367 | |
| 4368 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4369 | class ControllerUserList(generics.ListCreateAPIView): |
| 4370 | queryset = ControllerUser.objects.select_related().all() |
| 4371 | serializer_class = ControllerUserSerializer |
| 4372 | id_serializer_class = ControllerUserIdSerializer |
| 4373 | filter_backends = (filters.DjangoFilterBackend,) |
| 4374 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 4375 | |
| 4376 | def get_serializer_class(self): |
| 4377 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4378 | if (no_hyperlinks): |
| 4379 | return self.id_serializer_class |
| 4380 | else: |
| 4381 | return self.serializer_class |
| 4382 | |
| 4383 | def get_queryset(self): |
| 4384 | return ControllerUser.select_by_user(self.request.user) |
| 4385 | |
| 4386 | def create(self, request, *args, **kwargs): |
| 4387 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4388 | if not (serializer.is_valid()): |
| 4389 | response = {"error": "validation", |
| 4390 | "specific_error": "not serializer.is_valid()",
|
| 4391 | "reasons": serializer.errors}
|
| 4392 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4393 | obj = serializer.object |
| 4394 | obj.caller = request.user |
| 4395 | if obj.can_update(request.user): |
| 4396 | return super(ControllerUserList, self).create(request, *args, **kwargs) |
| 4397 | else: |
| 4398 | raise Exception("failed obj.can_update") |
| 4399 | |
| 4400 | ret = super(ControllerUserList, self).create(request, *args, **kwargs) |
| 4401 | if (ret.status_code%100 != 200): |
| 4402 | raise Exception(ret.data) |
| 4403 | |
| 4404 | return ret |
| 4405 | |
| 4406 | |
| 4407 | class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4408 | queryset = ControllerUser.objects.select_related().all() |
| 4409 | serializer_class = ControllerUserSerializer |
| 4410 | id_serializer_class = ControllerUserIdSerializer |
| 4411 | |
| 4412 | def get_serializer_class(self): |
| 4413 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4414 | if (no_hyperlinks): |
| 4415 | return self.id_serializer_class |
| 4416 | else: |
| 4417 | return self.serializer_class |
| 4418 | |
| 4419 | def get_queryset(self): |
| 4420 | return ControllerUser.select_by_user(self.request.user) |
| 4421 | |
| 4422 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4423 | |
| 4424 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4425 | |
| 4426 | |
| 4427 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4428 | class ReservedResourceList(generics.ListCreateAPIView): |
| 4429 | queryset = ReservedResource.objects.select_related().all() |
| 4430 | serializer_class = ReservedResourceSerializer |
| 4431 | id_serializer_class = ReservedResourceIdSerializer |
| 4432 | filter_backends = (filters.DjangoFilterBackend,) |
| 4433 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 4434 | |
| 4435 | def get_serializer_class(self): |
| 4436 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4437 | if (no_hyperlinks): |
| 4438 | return self.id_serializer_class |
| 4439 | else: |
| 4440 | return self.serializer_class |
| 4441 | |
| 4442 | def get_queryset(self): |
| 4443 | return ReservedResource.select_by_user(self.request.user) |
| 4444 | |
| 4445 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4446 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4447 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4448 | response = {"error": "validation", |
| 4449 | "specific_error": "not serializer.is_valid()",
|
| 4450 | "reasons": serializer.errors}
|
| 4451 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4452 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4453 | obj.caller = request.user |
| 4454 | if obj.can_update(request.user): |
| 4455 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4456 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4457 | raise Exception("failed obj.can_update") |
| 4458 | |
| 4459 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4460 | if (ret.status_code%100 != 200): |
| 4461 | raise Exception(ret.data) |
| 4462 | |
| 4463 | return ret |
| 4464 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4465 | |
| 4466 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4467 | queryset = ReservedResource.objects.select_related().all() |
| 4468 | serializer_class = ReservedResourceSerializer |
| 4469 | id_serializer_class = ReservedResourceIdSerializer |
| 4470 | |
| 4471 | def get_serializer_class(self): |
| 4472 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4473 | if (no_hyperlinks): |
| 4474 | return self.id_serializer_class |
| 4475 | else: |
| 4476 | return self.serializer_class |
| 4477 | |
| 4478 | def get_queryset(self): |
| 4479 | return ReservedResource.select_by_user(self.request.user) |
| 4480 | |
| 4481 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4482 | |
| 4483 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4484 | |
| 4485 | |
| 4486 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4487 | class PaymentList(generics.ListCreateAPIView): |
| 4488 | queryset = Payment.objects.select_related().all() |
| 4489 | serializer_class = PaymentSerializer |
| 4490 | id_serializer_class = PaymentIdSerializer |
| 4491 | filter_backends = (filters.DjangoFilterBackend,) |
| 4492 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 4493 | |
| 4494 | def get_serializer_class(self): |
| 4495 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4496 | if (no_hyperlinks): |
| 4497 | return self.id_serializer_class |
| 4498 | else: |
| 4499 | return self.serializer_class |
| 4500 | |
| 4501 | def get_queryset(self): |
| 4502 | return Payment.select_by_user(self.request.user) |
| 4503 | |
| 4504 | def create(self, request, *args, **kwargs): |
| 4505 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4506 | if not (serializer.is_valid()): |
| 4507 | response = {"error": "validation", |
| 4508 | "specific_error": "not serializer.is_valid()",
|
| 4509 | "reasons": serializer.errors}
|
| 4510 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4511 | obj = serializer.object |
| 4512 | obj.caller = request.user |
| 4513 | if obj.can_update(request.user): |
| 4514 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 4515 | else: |
| 4516 | raise Exception("failed obj.can_update") |
| 4517 | |
| 4518 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 4519 | if (ret.status_code%100 != 200): |
| 4520 | raise Exception(ret.data) |
| 4521 | |
| 4522 | return ret |
| 4523 | |
| 4524 | |
| 4525 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4526 | queryset = Payment.objects.select_related().all() |
| 4527 | serializer_class = PaymentSerializer |
| 4528 | id_serializer_class = PaymentIdSerializer |
| 4529 | |
| 4530 | def get_serializer_class(self): |
| 4531 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4532 | if (no_hyperlinks): |
| 4533 | return self.id_serializer_class |
| 4534 | else: |
| 4535 | return self.serializer_class |
| 4536 | |
| 4537 | def get_queryset(self): |
| 4538 | return Payment.select_by_user(self.request.user) |
| 4539 | |
| 4540 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4541 | |
| 4542 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4543 | |
| 4544 | |
| 4545 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4546 | class NetworkSliceList(generics.ListCreateAPIView): |
| 4547 | queryset = NetworkSlice.objects.select_related().all() |
| 4548 | serializer_class = NetworkSliceSerializer |
| 4549 | id_serializer_class = NetworkSliceIdSerializer |
| 4550 | filter_backends = (filters.DjangoFilterBackend,) |
| 4551 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 4552 | |
| 4553 | def get_serializer_class(self): |
| 4554 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4555 | if (no_hyperlinks): |
| 4556 | return self.id_serializer_class |
| 4557 | else: |
| 4558 | return self.serializer_class |
| 4559 | |
| 4560 | def get_queryset(self): |
| 4561 | return NetworkSlice.select_by_user(self.request.user) |
| 4562 | |
| 4563 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4564 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4565 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4566 | response = {"error": "validation", |
| 4567 | "specific_error": "not serializer.is_valid()",
|
| 4568 | "reasons": serializer.errors}
|
| 4569 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4570 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4571 | obj.caller = request.user |
| 4572 | if obj.can_update(request.user): |
| 4573 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4574 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4575 | raise Exception("failed obj.can_update") |
| 4576 | |
| 4577 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4578 | if (ret.status_code%100 != 200): |
| 4579 | raise Exception(ret.data) |
| 4580 | |
| 4581 | return ret |
| 4582 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4583 | |
| 4584 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4585 | queryset = NetworkSlice.objects.select_related().all() |
| 4586 | serializer_class = NetworkSliceSerializer |
| 4587 | id_serializer_class = NetworkSliceIdSerializer |
| 4588 | |
| 4589 | def get_serializer_class(self): |
| 4590 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4591 | if (no_hyperlinks): |
| 4592 | return self.id_serializer_class |
| 4593 | else: |
| 4594 | return self.serializer_class |
| 4595 | |
| 4596 | def get_queryset(self): |
| 4597 | return NetworkSlice.select_by_user(self.request.user) |
| 4598 | |
| 4599 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4600 | |
| 4601 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4602 | |
| 4603 | |
| 4604 | |
| 4605 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 4606 | queryset = UserDashboardView.objects.select_related().all() |
| 4607 | serializer_class = UserDashboardViewSerializer |
| 4608 | id_serializer_class = UserDashboardViewIdSerializer |
| 4609 | filter_backends = (filters.DjangoFilterBackend,) |
| 4610 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 4611 | |
| 4612 | def get_serializer_class(self): |
| 4613 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4614 | if (no_hyperlinks): |
| 4615 | return self.id_serializer_class |
| 4616 | else: |
| 4617 | return self.serializer_class |
| 4618 | |
| 4619 | def get_queryset(self): |
| 4620 | return UserDashboardView.select_by_user(self.request.user) |
| 4621 | |
| 4622 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4623 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4624 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4625 | response = {"error": "validation", |
| 4626 | "specific_error": "not serializer.is_valid()",
|
| 4627 | "reasons": serializer.errors}
|
| 4628 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4629 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4630 | obj.caller = request.user |
| 4631 | if obj.can_update(request.user): |
| 4632 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4633 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4634 | raise Exception("failed obj.can_update") |
| 4635 | |
| 4636 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4637 | if (ret.status_code%100 != 200): |
| 4638 | raise Exception(ret.data) |
| 4639 | |
| 4640 | return ret |
| 4641 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4642 | |
| 4643 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4644 | queryset = UserDashboardView.objects.select_related().all() |
| 4645 | serializer_class = UserDashboardViewSerializer |
| 4646 | id_serializer_class = UserDashboardViewIdSerializer |
| 4647 | |
| 4648 | def get_serializer_class(self): |
| 4649 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4650 | if (no_hyperlinks): |
| 4651 | return self.id_serializer_class |
| 4652 | else: |
| 4653 | return self.serializer_class |
| 4654 | |
| 4655 | def get_queryset(self): |
| 4656 | return UserDashboardView.select_by_user(self.request.user) |
| 4657 | |
| 4658 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4659 | |
| 4660 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4661 | |
| 4662 | |
| 4663 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4664 | class ControllerList(generics.ListCreateAPIView): |
| 4665 | queryset = Controller.objects.select_related().all() |
| 4666 | serializer_class = ControllerSerializer |
| 4667 | id_serializer_class = ControllerIdSerializer |
| 4668 | filter_backends = (filters.DjangoFilterBackend,) |
| 4669 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 4670 | |
| 4671 | def get_serializer_class(self): |
| 4672 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4673 | if (no_hyperlinks): |
| 4674 | return self.id_serializer_class |
| 4675 | else: |
| 4676 | return self.serializer_class |
| 4677 | |
| 4678 | def get_queryset(self): |
| 4679 | return Controller.select_by_user(self.request.user) |
| 4680 | |
| 4681 | def create(self, request, *args, **kwargs): |
| 4682 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4683 | if not (serializer.is_valid()): |
| 4684 | response = {"error": "validation", |
| 4685 | "specific_error": "not serializer.is_valid()",
|
| 4686 | "reasons": serializer.errors}
|
| 4687 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4688 | obj = serializer.object |
| 4689 | obj.caller = request.user |
| 4690 | if obj.can_update(request.user): |
| 4691 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4692 | else: |
| 4693 | raise Exception("failed obj.can_update") |
| 4694 | |
| 4695 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 4696 | if (ret.status_code%100 != 200): |
| 4697 | raise Exception(ret.data) |
| 4698 | |
| 4699 | return ret |
| 4700 | |
| 4701 | |
| 4702 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4703 | queryset = Controller.objects.select_related().all() |
| 4704 | serializer_class = ControllerSerializer |
| 4705 | id_serializer_class = ControllerIdSerializer |
| 4706 | |
| 4707 | def get_serializer_class(self): |
| 4708 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4709 | if (no_hyperlinks): |
| 4710 | return self.id_serializer_class |
| 4711 | else: |
| 4712 | return self.serializer_class |
| 4713 | |
| 4714 | def get_queryset(self): |
| 4715 | return Controller.select_by_user(self.request.user) |
| 4716 | |
| 4717 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4718 | |
| 4719 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4720 | |
| 4721 | |
| 4722 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4723 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 4724 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4725 | serializer_class = PlanetStackPrivilegeSerializer |
| 4726 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4727 | filter_backends = (filters.DjangoFilterBackend,) |
| 4728 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 4729 | |
| 4730 | def get_serializer_class(self): |
| 4731 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4732 | if (no_hyperlinks): |
| 4733 | return self.id_serializer_class |
| 4734 | else: |
| 4735 | return self.serializer_class |
| 4736 | |
| 4737 | def get_queryset(self): |
| 4738 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4739 | |
| 4740 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4741 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4742 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4743 | response = {"error": "validation", |
| 4744 | "specific_error": "not serializer.is_valid()",
|
| 4745 | "reasons": serializer.errors}
|
| 4746 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4747 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4748 | obj.caller = request.user |
| 4749 | if obj.can_update(request.user): |
| 4750 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4751 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4752 | raise Exception("failed obj.can_update") |
| 4753 | |
| 4754 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4755 | if (ret.status_code%100 != 200): |
| 4756 | raise Exception(ret.data) |
| 4757 | |
| 4758 | return ret |
| 4759 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4760 | |
| 4761 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4762 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4763 | serializer_class = PlanetStackPrivilegeSerializer |
| 4764 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4765 | |
| 4766 | def get_serializer_class(self): |
| 4767 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4768 | if (no_hyperlinks): |
| 4769 | return self.id_serializer_class |
| 4770 | else: |
| 4771 | return self.serializer_class |
| 4772 | |
| 4773 | def get_queryset(self): |
| 4774 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4775 | |
| 4776 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4777 | |
| 4778 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4779 | |
| 4780 | |
| 4781 | |
| 4782 | class UserList(generics.ListCreateAPIView): |
| 4783 | queryset = User.objects.select_related().all() |
| 4784 | serializer_class = UserSerializer |
| 4785 | id_serializer_class = UserIdSerializer |
| 4786 | filter_backends = (filters.DjangoFilterBackend,) |
| 4787 | filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',) |
| 4788 | |
| 4789 | def get_serializer_class(self): |
| 4790 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4791 | if (no_hyperlinks): |
| 4792 | return self.id_serializer_class |
| 4793 | else: |
| 4794 | return self.serializer_class |
| 4795 | |
| 4796 | def get_queryset(self): |
| 4797 | return User.select_by_user(self.request.user) |
| 4798 | |
| 4799 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4800 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4801 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4802 | response = {"error": "validation", |
| 4803 | "specific_error": "not serializer.is_valid()",
|
| 4804 | "reasons": serializer.errors}
|
| 4805 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4806 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4807 | obj.caller = request.user |
| 4808 | if obj.can_update(request.user): |
| 4809 | return super(UserList, self).create(request, *args, **kwargs) |
| 4810 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4811 | raise Exception("failed obj.can_update") |
| 4812 | |
| 4813 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 4814 | if (ret.status_code%100 != 200): |
| 4815 | raise Exception(ret.data) |
| 4816 | |
| 4817 | return ret |
| 4818 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4819 | |
| 4820 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4821 | queryset = User.objects.select_related().all() |
| 4822 | serializer_class = UserSerializer |
| 4823 | id_serializer_class = UserIdSerializer |
| 4824 | |
| 4825 | def get_serializer_class(self): |
| 4826 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4827 | if (no_hyperlinks): |
| 4828 | return self.id_serializer_class |
| 4829 | else: |
| 4830 | return self.serializer_class |
| 4831 | |
| 4832 | def get_queryset(self): |
| 4833 | return User.select_by_user(self.request.user) |
| 4834 | |
| 4835 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4836 | |
| 4837 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4838 | |
| 4839 | |
| 4840 | |
| 4841 | class DeploymentList(generics.ListCreateAPIView): |
| 4842 | queryset = Deployment.objects.select_related().all() |
| 4843 | serializer_class = DeploymentSerializer |
| 4844 | id_serializer_class = DeploymentIdSerializer |
| 4845 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4846 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4847 | |
| 4848 | def get_serializer_class(self): |
| 4849 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4850 | if (no_hyperlinks): |
| 4851 | return self.id_serializer_class |
| 4852 | else: |
| 4853 | return self.serializer_class |
| 4854 | |
| 4855 | def get_queryset(self): |
| 4856 | return Deployment.select_by_user(self.request.user) |
| 4857 | |
| 4858 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4859 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4860 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4861 | response = {"error": "validation", |
| 4862 | "specific_error": "not serializer.is_valid()",
|
| 4863 | "reasons": serializer.errors}
|
| 4864 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4865 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4866 | obj.caller = request.user |
| 4867 | if obj.can_update(request.user): |
| 4868 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 4869 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4870 | raise Exception("failed obj.can_update") |
| 4871 | |
| 4872 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 4873 | if (ret.status_code%100 != 200): |
| 4874 | raise Exception(ret.data) |
| 4875 | |
| 4876 | return ret |
| 4877 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4878 | |
| 4879 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4880 | queryset = Deployment.objects.select_related().all() |
| 4881 | serializer_class = DeploymentSerializer |
| 4882 | id_serializer_class = DeploymentIdSerializer |
| 4883 | |
| 4884 | def get_serializer_class(self): |
| 4885 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4886 | if (no_hyperlinks): |
| 4887 | return self.id_serializer_class |
| 4888 | else: |
| 4889 | return self.serializer_class |
| 4890 | |
| 4891 | def get_queryset(self): |
| 4892 | return Deployment.select_by_user(self.request.user) |
| 4893 | |
| 4894 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4895 | |
| 4896 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4897 | |
| 4898 | |
| 4899 | |
| 4900 | class ReservationList(generics.ListCreateAPIView): |
| 4901 | queryset = Reservation.objects.select_related().all() |
| 4902 | serializer_class = ReservationSerializer |
| 4903 | id_serializer_class = ReservationIdSerializer |
| 4904 | filter_backends = (filters.DjangoFilterBackend,) |
| 4905 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 4906 | |
| 4907 | def get_serializer_class(self): |
| 4908 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4909 | if (no_hyperlinks): |
| 4910 | return self.id_serializer_class |
| 4911 | else: |
| 4912 | return self.serializer_class |
| 4913 | |
| 4914 | def get_queryset(self): |
| 4915 | return Reservation.select_by_user(self.request.user) |
| 4916 | |
| 4917 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4918 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4919 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4920 | response = {"error": "validation", |
| 4921 | "specific_error": "not serializer.is_valid()",
|
| 4922 | "reasons": serializer.errors}
|
| 4923 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4924 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4925 | obj.caller = request.user |
| 4926 | if obj.can_update(request.user): |
| 4927 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 4928 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4929 | raise Exception("failed obj.can_update") |
| 4930 | |
| 4931 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 4932 | if (ret.status_code%100 != 200): |
| 4933 | raise Exception(ret.data) |
| 4934 | |
| 4935 | return ret |
| 4936 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4937 | |
| 4938 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4939 | queryset = Reservation.objects.select_related().all() |
| 4940 | serializer_class = ReservationSerializer |
| 4941 | id_serializer_class = ReservationIdSerializer |
| 4942 | |
| 4943 | def get_serializer_class(self): |
| 4944 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4945 | if (no_hyperlinks): |
| 4946 | return self.id_serializer_class |
| 4947 | else: |
| 4948 | return self.serializer_class |
| 4949 | |
| 4950 | def get_queryset(self): |
| 4951 | return Reservation.select_by_user(self.request.user) |
| 4952 | |
| 4953 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4954 | |
| 4955 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4956 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4957 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4958 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4959 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 4960 | queryset = SitePrivilege.objects.select_related().all() |
| 4961 | serializer_class = SitePrivilegeSerializer |
| 4962 | id_serializer_class = SitePrivilegeIdSerializer |
| 4963 | filter_backends = (filters.DjangoFilterBackend,) |
| 4964 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 4965 | |
| 4966 | def get_serializer_class(self): |
| 4967 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4968 | if (no_hyperlinks): |
| 4969 | return self.id_serializer_class |
| 4970 | else: |
| 4971 | return self.serializer_class |
| 4972 | |
| 4973 | def get_queryset(self): |
| 4974 | return SitePrivilege.select_by_user(self.request.user) |
| 4975 | |
| 4976 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4977 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4978 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4979 | response = {"error": "validation", |
| 4980 | "specific_error": "not serializer.is_valid()",
|
| 4981 | "reasons": serializer.errors}
|
| 4982 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4983 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4984 | obj.caller = request.user |
| 4985 | if obj.can_update(request.user): |
| 4986 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4987 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4988 | raise Exception("failed obj.can_update") |
| 4989 | |
| 4990 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4991 | if (ret.status_code%100 != 200): |
| 4992 | raise Exception(ret.data) |
| 4993 | |
| 4994 | return ret |
| 4995 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4996 | |
| 4997 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4998 | queryset = SitePrivilege.objects.select_related().all() |
| 4999 | serializer_class = SitePrivilegeSerializer |
| 5000 | id_serializer_class = SitePrivilegeIdSerializer |
| 5001 | |
| 5002 | def get_serializer_class(self): |
| 5003 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5004 | if (no_hyperlinks): |
| 5005 | return self.id_serializer_class |
| 5006 | else: |
| 5007 | return self.serializer_class |
| 5008 | |
| 5009 | def get_queryset(self): |
| 5010 | return SitePrivilege.select_by_user(self.request.user) |
| 5011 | |
| 5012 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5013 | |
| 5014 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5015 | |
| 5016 | |
| 5017 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5018 | class ControllerSliceList(generics.ListCreateAPIView): |
| 5019 | queryset = ControllerSlice.objects.select_related().all() |
| 5020 | serializer_class = ControllerSliceSerializer |
| 5021 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5022 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5023 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5024 | |
| 5025 | def get_serializer_class(self): |
| 5026 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5027 | if (no_hyperlinks): |
| 5028 | return self.id_serializer_class |
| 5029 | else: |
| 5030 | return self.serializer_class |
| 5031 | |
| 5032 | def get_queryset(self): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5033 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5034 | |
| 5035 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5036 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5037 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5038 | response = {"error": "validation", |
| 5039 | "specific_error": "not serializer.is_valid()",
|
| 5040 | "reasons": serializer.errors}
|
| 5041 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5042 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5043 | obj.caller = request.user |
| 5044 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5045 | return super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5046 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5047 | raise Exception("failed obj.can_update") |
| 5048 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5049 | ret = super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5050 | if (ret.status_code%100 != 200): |
| 5051 | raise Exception(ret.data) |
| 5052 | |
| 5053 | return ret |
| 5054 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5055 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5056 | class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5057 | queryset = ControllerSlice.objects.select_related().all() |
| 5058 | serializer_class = ControllerSliceSerializer |
| 5059 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5060 | |
| 5061 | def get_serializer_class(self): |
| 5062 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5063 | if (no_hyperlinks): |
| 5064 | return self.id_serializer_class |
| 5065 | else: |
| 5066 | return self.serializer_class |
| 5067 | |
| 5068 | def get_queryset(self): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5069 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5070 | |
| 5071 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5072 | |
| 5073 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5074 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5075 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5076 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5077 | class ControllerDashboardViewList(generics.ListCreateAPIView): |
| 5078 | queryset = ControllerDashboardView.objects.select_related().all() |
| 5079 | serializer_class = ControllerDashboardViewSerializer |
| 5080 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 5081 | filter_backends = (filters.DjangoFilterBackend,) |
| 5082 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 5083 | |
| 5084 | def get_serializer_class(self): |
| 5085 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5086 | if (no_hyperlinks): |
| 5087 | return self.id_serializer_class |
| 5088 | else: |
| 5089 | return self.serializer_class |
| 5090 | |
| 5091 | def get_queryset(self): |
| 5092 | return ControllerDashboardView.select_by_user(self.request.user) |
| 5093 | |
| 5094 | def create(self, request, *args, **kwargs): |
| 5095 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5096 | if not (serializer.is_valid()): |
| 5097 | response = {"error": "validation", |
| 5098 | "specific_error": "not serializer.is_valid()",
|
| 5099 | "reasons": serializer.errors}
|
| 5100 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5101 | obj = serializer.object |
| 5102 | obj.caller = request.user |
| 5103 | if obj.can_update(request.user): |
| 5104 | return super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 5105 | else: |
| 5106 | raise Exception("failed obj.can_update") |
| 5107 | |
| 5108 | ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 5109 | if (ret.status_code%100 != 200): |
| 5110 | raise Exception(ret.data) |
| 5111 | |
| 5112 | return ret |
| 5113 | |
| 5114 | |
| 5115 | class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5116 | queryset = ControllerDashboardView.objects.select_related().all() |
| 5117 | serializer_class = ControllerDashboardViewSerializer |
| 5118 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 5119 | |
| 5120 | def get_serializer_class(self): |
| 5121 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5122 | if (no_hyperlinks): |
| 5123 | return self.id_serializer_class |
| 5124 | else: |
| 5125 | return self.serializer_class |
| 5126 | |
| 5127 | def get_queryset(self): |
| 5128 | return ControllerDashboardView.select_by_user(self.request.user) |
| 5129 | |
| 5130 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5131 | |
| 5132 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5133 | |
| 5134 | |
| 5135 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5136 | class AccountList(generics.ListCreateAPIView): |
| 5137 | queryset = Account.objects.select_related().all() |
| 5138 | serializer_class = AccountSerializer |
| 5139 | id_serializer_class = AccountIdSerializer |
| 5140 | filter_backends = (filters.DjangoFilterBackend,) |
| 5141 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 5142 | |
| 5143 | def get_serializer_class(self): |
| 5144 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5145 | if (no_hyperlinks): |
| 5146 | return self.id_serializer_class |
| 5147 | else: |
| 5148 | return self.serializer_class |
| 5149 | |
| 5150 | def get_queryset(self): |
| 5151 | return Account.select_by_user(self.request.user) |
| 5152 | |
| 5153 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5154 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5155 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5156 | response = {"error": "validation", |
| 5157 | "specific_error": "not serializer.is_valid()",
|
| 5158 | "reasons": serializer.errors}
|
| 5159 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5160 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5161 | obj.caller = request.user |
| 5162 | if obj.can_update(request.user): |
| 5163 | return super(AccountList, self).create(request, *args, **kwargs) |
| 5164 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5165 | raise Exception("failed obj.can_update") |
| 5166 | |
| 5167 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 5168 | if (ret.status_code%100 != 200): |
| 5169 | raise Exception(ret.data) |
| 5170 | |
| 5171 | return ret |
| 5172 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5173 | |
| 5174 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5175 | queryset = Account.objects.select_related().all() |
| 5176 | serializer_class = AccountSerializer |
| 5177 | id_serializer_class = AccountIdSerializer |
| 5178 | |
| 5179 | def get_serializer_class(self): |
| 5180 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5181 | if (no_hyperlinks): |
| 5182 | return self.id_serializer_class |
| 5183 | else: |
| 5184 | return self.serializer_class |
| 5185 | |
| 5186 | def get_queryset(self): |
| 5187 | return Account.select_by_user(self.request.user) |
| 5188 | |
| 5189 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5190 | |
| 5191 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5192 | |
| 5193 | |
| 5194 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5195 | class ControllerRoleList(generics.ListCreateAPIView): |
| 5196 | queryset = ControllerRole.objects.select_related().all() |
| 5197 | serializer_class = ControllerRoleSerializer |
| 5198 | id_serializer_class = ControllerRoleIdSerializer |
| 5199 | filter_backends = (filters.DjangoFilterBackend,) |
| 5200 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5201 | |
| 5202 | def get_serializer_class(self): |
| 5203 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5204 | if (no_hyperlinks): |
| 5205 | return self.id_serializer_class |
| 5206 | else: |
| 5207 | return self.serializer_class |
| 5208 | |
| 5209 | def get_queryset(self): |
| 5210 | return ControllerRole.select_by_user(self.request.user) |
| 5211 | |
| 5212 | def create(self, request, *args, **kwargs): |
| 5213 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5214 | if not (serializer.is_valid()): |
| 5215 | response = {"error": "validation", |
| 5216 | "specific_error": "not serializer.is_valid()",
|
| 5217 | "reasons": serializer.errors}
|
| 5218 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5219 | obj = serializer.object |
| 5220 | obj.caller = request.user |
| 5221 | if obj.can_update(request.user): |
| 5222 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5223 | else: |
| 5224 | raise Exception("failed obj.can_update") |
| 5225 | |
| 5226 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5227 | if (ret.status_code%100 != 200): |
| 5228 | raise Exception(ret.data) |
| 5229 | |
| 5230 | return ret |
| 5231 | |
| 5232 | |
| 5233 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5234 | queryset = ControllerRole.objects.select_related().all() |
| 5235 | serializer_class = ControllerRoleSerializer |
| 5236 | id_serializer_class = ControllerRoleIdSerializer |
| 5237 | |
| 5238 | def get_serializer_class(self): |
| 5239 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5240 | if (no_hyperlinks): |
| 5241 | return self.id_serializer_class |
| 5242 | else: |
| 5243 | return self.serializer_class |
| 5244 | |
| 5245 | def get_queryset(self): |
| 5246 | return ControllerRole.select_by_user(self.request.user) |
| 5247 | |
| 5248 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5249 | |
| 5250 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5251 | |
| 5252 | |
| 5253 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5254 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 5255 | queryset = NetworkParameterType.objects.select_related().all() |
| 5256 | serializer_class = NetworkParameterTypeSerializer |
| 5257 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5258 | filter_backends = (filters.DjangoFilterBackend,) |
| 5259 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 5260 | |
| 5261 | def get_serializer_class(self): |
| 5262 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5263 | if (no_hyperlinks): |
| 5264 | return self.id_serializer_class |
| 5265 | else: |
| 5266 | return self.serializer_class |
| 5267 | |
| 5268 | def get_queryset(self): |
| 5269 | return NetworkParameterType.select_by_user(self.request.user) |
| 5270 | |
| 5271 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5272 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5273 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5274 | response = {"error": "validation", |
| 5275 | "specific_error": "not serializer.is_valid()",
|
| 5276 | "reasons": serializer.errors}
|
| 5277 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5278 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5279 | obj.caller = request.user |
| 5280 | if obj.can_update(request.user): |
| 5281 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5282 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5283 | raise Exception("failed obj.can_update") |
| 5284 | |
| 5285 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5286 | if (ret.status_code%100 != 200): |
| 5287 | raise Exception(ret.data) |
| 5288 | |
| 5289 | return ret |
| 5290 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5291 | |
| 5292 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5293 | queryset = NetworkParameterType.objects.select_related().all() |
| 5294 | serializer_class = NetworkParameterTypeSerializer |
| 5295 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5296 | |
| 5297 | def get_serializer_class(self): |
| 5298 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5299 | if (no_hyperlinks): |
| 5300 | return self.id_serializer_class |
| 5301 | else: |
| 5302 | return self.serializer_class |
| 5303 | |
| 5304 | def get_queryset(self): |
| 5305 | return NetworkParameterType.select_by_user(self.request.user) |
| 5306 | |
| 5307 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5308 | |
| 5309 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5310 | |
| 5311 | |
| 5312 | |
| 5313 | class SiteCredentialList(generics.ListCreateAPIView): |
| 5314 | queryset = SiteCredential.objects.select_related().all() |
| 5315 | serializer_class = SiteCredentialSerializer |
| 5316 | id_serializer_class = SiteCredentialIdSerializer |
| 5317 | filter_backends = (filters.DjangoFilterBackend,) |
| 5318 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 5319 | |
| 5320 | def get_serializer_class(self): |
| 5321 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5322 | if (no_hyperlinks): |
| 5323 | return self.id_serializer_class |
| 5324 | else: |
| 5325 | return self.serializer_class |
| 5326 | |
| 5327 | def get_queryset(self): |
| 5328 | return SiteCredential.select_by_user(self.request.user) |
| 5329 | |
| 5330 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5331 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5332 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5333 | response = {"error": "validation", |
| 5334 | "specific_error": "not serializer.is_valid()",
|
| 5335 | "reasons": serializer.errors}
|
| 5336 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5337 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5338 | obj.caller = request.user |
| 5339 | if obj.can_update(request.user): |
| 5340 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5341 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5342 | raise Exception("failed obj.can_update") |
| 5343 | |
| 5344 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5345 | if (ret.status_code%100 != 200): |
| 5346 | raise Exception(ret.data) |
| 5347 | |
| 5348 | return ret |
| 5349 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5350 | |
| 5351 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5352 | queryset = SiteCredential.objects.select_related().all() |
| 5353 | serializer_class = SiteCredentialSerializer |
| 5354 | id_serializer_class = SiteCredentialIdSerializer |
| 5355 | |
| 5356 | def get_serializer_class(self): |
| 5357 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5358 | if (no_hyperlinks): |
| 5359 | return self.id_serializer_class |
| 5360 | else: |
| 5361 | return self.serializer_class |
| 5362 | |
| 5363 | def get_queryset(self): |
| 5364 | return SiteCredential.select_by_user(self.request.user) |
| 5365 | |
| 5366 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5367 | |
| 5368 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5369 | |
| 5370 | |
| 5371 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5372 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 5373 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5374 | serializer_class = DeploymentPrivilegeSerializer |
| 5375 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5376 | filter_backends = (filters.DjangoFilterBackend,) |
| 5377 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 5378 | |
| 5379 | def get_serializer_class(self): |
| 5380 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5381 | if (no_hyperlinks): |
| 5382 | return self.id_serializer_class |
| 5383 | else: |
| 5384 | return self.serializer_class |
| 5385 | |
| 5386 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5387 | return DeploymentPrivilege.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 | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5399 | return super(DeploymentPrivilegeList, 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 | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5403 | ret = super(DeploymentPrivilegeList, 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 | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5410 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5411 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5412 | serializer_class = DeploymentPrivilegeSerializer |
| 5413 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5414 | |
| 5415 | def get_serializer_class(self): |
| 5416 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5417 | if (no_hyperlinks): |
| 5418 | return self.id_serializer_class |
| 5419 | else: |
| 5420 | return self.serializer_class |
| 5421 | |
| 5422 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5423 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5424 | |
| 5425 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5426 | |
| 5427 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5428 | |
| 5429 | |
| 5430 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5431 | class ControllerSlicePrivilegeList(generics.ListCreateAPIView): |
| 5432 | queryset = ControllerSlicePrivilege.objects.select_related().all() |
| 5433 | serializer_class = ControllerSlicePrivilegeSerializer |
| 5434 | id_serializer_class = ControllerSlicePrivilegeIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5435 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5436 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5437 | |
| 5438 | def get_serializer_class(self): |
| 5439 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5440 | if (no_hyperlinks): |
| 5441 | return self.id_serializer_class |
| 5442 | else: |
| 5443 | return self.serializer_class |
| 5444 | |
| 5445 | def get_queryset(self): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5446 | return ControllerSlicePrivilege.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5447 | |
| 5448 | def create(self, request, *args, **kwargs): |
| 5449 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5450 | if not (serializer.is_valid()): |
| 5451 | response = {"error": "validation", |
| 5452 | "specific_error": "not serializer.is_valid()",
|
| 5453 | "reasons": serializer.errors}
|
| 5454 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5455 | obj = serializer.object |
| 5456 | obj.caller = request.user |
| 5457 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5458 | return super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5459 | else: |
| 5460 | raise Exception("failed obj.can_update") |
| 5461 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5462 | ret = super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5463 | if (ret.status_code%100 != 200): |
| 5464 | raise Exception(ret.data) |
| 5465 | |
| 5466 | return ret |
| 5467 | |
| 5468 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5469 | class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5470 | queryset = ControllerSlicePrivilege.objects.select_related().all() |
| 5471 | serializer_class = ControllerSlicePrivilegeSerializer |
| 5472 | id_serializer_class = ControllerSlicePrivilegeIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5473 | |
| 5474 | def get_serializer_class(self): |
| 5475 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5476 | if (no_hyperlinks): |
| 5477 | return self.id_serializer_class |
| 5478 | else: |
| 5479 | return self.serializer_class |
| 5480 | |
| 5481 | def get_queryset(self): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5482 | return ControllerSlicePrivilege.select_by_user(self.request.user) |
| 5483 | |
| 5484 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5485 | |
| 5486 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5487 | |
| 5488 | |
| 5489 | |
| 5490 | class SiteDeploymentList(generics.ListCreateAPIView): |
| 5491 | queryset = SiteDeployment.objects.select_related().all() |
| 5492 | serializer_class = SiteDeploymentSerializer |
| 5493 | id_serializer_class = SiteDeploymentIdSerializer |
| 5494 | filter_backends = (filters.DjangoFilterBackend,) |
| 5495 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
| 5496 | |
| 5497 | def get_serializer_class(self): |
| 5498 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5499 | if (no_hyperlinks): |
| 5500 | return self.id_serializer_class |
| 5501 | else: |
| 5502 | return self.serializer_class |
| 5503 | |
| 5504 | def get_queryset(self): |
| 5505 | return SiteDeployment.select_by_user(self.request.user) |
| 5506 | |
| 5507 | def create(self, request, *args, **kwargs): |
| 5508 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5509 | if not (serializer.is_valid()): |
| 5510 | response = {"error": "validation", |
| 5511 | "specific_error": "not serializer.is_valid()",
|
| 5512 | "reasons": serializer.errors}
|
| 5513 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5514 | obj = serializer.object |
| 5515 | obj.caller = request.user |
| 5516 | if obj.can_update(request.user): |
| 5517 | return super(SiteDeploymentList, self).create(request, *args, **kwargs) |
| 5518 | else: |
| 5519 | raise Exception("failed obj.can_update") |
| 5520 | |
| 5521 | ret = super(SiteDeploymentList, self).create(request, *args, **kwargs) |
| 5522 | if (ret.status_code%100 != 200): |
| 5523 | raise Exception(ret.data) |
| 5524 | |
| 5525 | return ret |
| 5526 | |
| 5527 | |
| 5528 | class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5529 | queryset = SiteDeployment.objects.select_related().all() |
| 5530 | serializer_class = SiteDeploymentSerializer |
| 5531 | id_serializer_class = SiteDeploymentIdSerializer |
| 5532 | |
| 5533 | def get_serializer_class(self): |
| 5534 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5535 | if (no_hyperlinks): |
| 5536 | return self.id_serializer_class |
| 5537 | else: |
| 5538 | return self.serializer_class |
| 5539 | |
| 5540 | def get_queryset(self): |
| 5541 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5542 | |
| 5543 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5544 | |
| 5545 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5546 | |
| 5547 | |
| 5548 | |
| 5549 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 5550 | queryset = DeploymentRole.objects.select_related().all() |
| 5551 | serializer_class = DeploymentRoleSerializer |
| 5552 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5553 | filter_backends = (filters.DjangoFilterBackend,) |
| 5554 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5555 | |
| 5556 | def get_serializer_class(self): |
| 5557 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5558 | if (no_hyperlinks): |
| 5559 | return self.id_serializer_class |
| 5560 | else: |
| 5561 | return self.serializer_class |
| 5562 | |
| 5563 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5564 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5565 | |
| 5566 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5567 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5568 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5569 | response = {"error": "validation", |
| 5570 | "specific_error": "not serializer.is_valid()",
|
| 5571 | "reasons": serializer.errors}
|
| 5572 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5573 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5574 | obj.caller = request.user |
| 5575 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5576 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5577 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5578 | raise Exception("failed obj.can_update") |
| 5579 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5580 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5581 | if (ret.status_code%100 != 200): |
| 5582 | raise Exception(ret.data) |
| 5583 | |
| 5584 | return ret |
| 5585 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5586 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5587 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5588 | queryset = DeploymentRole.objects.select_related().all() |
| 5589 | serializer_class = DeploymentRoleSerializer |
| 5590 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5591 | |
| 5592 | def get_serializer_class(self): |
| 5593 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5594 | if (no_hyperlinks): |
| 5595 | return self.id_serializer_class |
| 5596 | else: |
| 5597 | return self.serializer_class |
| 5598 | |
| 5599 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5600 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5601 | |
| 5602 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5603 | |
| 5604 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5605 | |
| 5606 | |
| 5607 | |
| 5608 | class UserCredentialList(generics.ListCreateAPIView): |
| 5609 | queryset = UserCredential.objects.select_related().all() |
| 5610 | serializer_class = UserCredentialSerializer |
| 5611 | id_serializer_class = UserCredentialIdSerializer |
| 5612 | filter_backends = (filters.DjangoFilterBackend,) |
| 5613 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 5614 | |
| 5615 | def get_serializer_class(self): |
| 5616 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5617 | if (no_hyperlinks): |
| 5618 | return self.id_serializer_class |
| 5619 | else: |
| 5620 | return self.serializer_class |
| 5621 | |
| 5622 | def get_queryset(self): |
| 5623 | return UserCredential.select_by_user(self.request.user) |
| 5624 | |
| 5625 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5626 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5627 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5628 | response = {"error": "validation", |
| 5629 | "specific_error": "not serializer.is_valid()",
|
| 5630 | "reasons": serializer.errors}
|
| 5631 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5632 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5633 | obj.caller = request.user |
| 5634 | if obj.can_update(request.user): |
| 5635 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5636 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5637 | raise Exception("failed obj.can_update") |
| 5638 | |
| 5639 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5640 | if (ret.status_code%100 != 200): |
| 5641 | raise Exception(ret.data) |
| 5642 | |
| 5643 | return ret |
| 5644 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5645 | |
| 5646 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5647 | queryset = UserCredential.objects.select_related().all() |
| 5648 | serializer_class = UserCredentialSerializer |
| 5649 | id_serializer_class = UserCredentialIdSerializer |
| 5650 | |
| 5651 | def get_serializer_class(self): |
| 5652 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5653 | if (no_hyperlinks): |
| 5654 | return self.id_serializer_class |
| 5655 | else: |
| 5656 | return self.serializer_class |
| 5657 | |
| 5658 | def get_queryset(self): |
| 5659 | return UserCredential.select_by_user(self.request.user) |
| 5660 | |
| 5661 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5662 | |
| 5663 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5664 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5665 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5666 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5667 | class SliceTagList(generics.ListCreateAPIView): |
| 5668 | queryset = SliceTag.objects.select_related().all() |
| 5669 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5670 | id_serializer_class = SliceTagIdSerializer |
| 5671 | filter_backends = (filters.DjangoFilterBackend,) |
| 5672 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 5673 | |
| 5674 | def get_serializer_class(self): |
| 5675 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5676 | if (no_hyperlinks): |
| 5677 | return self.id_serializer_class |
| 5678 | else: |
| 5679 | return self.serializer_class |
| 5680 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5681 | def get_queryset(self): |
| 5682 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5683 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5684 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5685 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5686 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5687 | response = {"error": "validation", |
| 5688 | "specific_error": "not serializer.is_valid()",
|
| 5689 | "reasons": serializer.errors}
|
| 5690 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5691 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5692 | obj.caller = request.user |
| 5693 | if obj.can_update(request.user): |
| 5694 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 5695 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5696 | raise Exception("failed obj.can_update") |
| 5697 | |
| 5698 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 5699 | if (ret.status_code%100 != 200): |
| 5700 | raise Exception(ret.data) |
| 5701 | |
| 5702 | return ret |
| 5703 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5704 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5705 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5706 | queryset = SliceTag.objects.select_related().all() |
| 5707 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5708 | id_serializer_class = SliceTagIdSerializer |
| 5709 | |
| 5710 | def get_serializer_class(self): |
| 5711 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5712 | if (no_hyperlinks): |
| 5713 | return self.id_serializer_class |
| 5714 | else: |
| 5715 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5716 | |
| 5717 | def get_queryset(self): |
| 5718 | return SliceTag.select_by_user(self.request.user) |
| 5719 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5720 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5721 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5722 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5723 | |
| 5724 | |
| 5725 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5726 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 5727 | queryset = NetworkTemplate.objects.select_related().all() |
| 5728 | serializer_class = NetworkTemplateSerializer |
| 5729 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5730 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 5731 | filter_fields = ('id','created','updated','enacted','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] | 5732 | |
| 5733 | def get_serializer_class(self): |
| 5734 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5735 | if (no_hyperlinks): |
| 5736 | return self.id_serializer_class |
| 5737 | else: |
| 5738 | return self.serializer_class |
| 5739 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5740 | def get_queryset(self): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5741 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5742 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5743 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5744 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5745 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5746 | response = {"error": "validation", |
| 5747 | "specific_error": "not serializer.is_valid()",
|
| 5748 | "reasons": serializer.errors}
|
| 5749 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5750 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5751 | obj.caller = request.user |
| 5752 | if obj.can_update(request.user): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5753 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5754 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5755 | raise Exception("failed obj.can_update") |
| 5756 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5757 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5758 | if (ret.status_code%100 != 200): |
| 5759 | raise Exception(ret.data) |
| 5760 | |
| 5761 | return ret |
| 5762 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5763 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5764 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5765 | queryset = NetworkTemplate.objects.select_related().all() |
| 5766 | serializer_class = NetworkTemplateSerializer |
| 5767 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5768 | |
| 5769 | def get_serializer_class(self): |
| 5770 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5771 | if (no_hyperlinks): |
| 5772 | return self.id_serializer_class |
| 5773 | else: |
| 5774 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5775 | |
| 5776 | def get_queryset(self): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5777 | return NetworkTemplate.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5778 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5779 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5780 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5781 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5782 | |
| 5783 | |
| 5784 | |
| 5785 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5786 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5787 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5788 | id_serializer_class = RouterIdSerializer |
| 5789 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5790 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5791 | |
| 5792 | def get_serializer_class(self): |
| 5793 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5794 | if (no_hyperlinks): |
| 5795 | return self.id_serializer_class |
| 5796 | else: |
| 5797 | return self.serializer_class |
| 5798 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5799 | def get_queryset(self): |
| 5800 | return Router.select_by_user(self.request.user) |
| 5801 | |
| 5802 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5803 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5804 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5805 | response = {"error": "validation", |
| 5806 | "specific_error": "not serializer.is_valid()",
|
| 5807 | "reasons": serializer.errors}
|
| 5808 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5809 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5810 | obj.caller = request.user |
| 5811 | if obj.can_update(request.user): |
| 5812 | return super(RouterList, self).create(request, *args, **kwargs) |
| 5813 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5814 | raise Exception("failed obj.can_update") |
| 5815 | |
| 5816 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 5817 | if (ret.status_code%100 != 200): |
| 5818 | raise Exception(ret.data) |
| 5819 | |
| 5820 | return ret |
| 5821 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5822 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5823 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5824 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5825 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5826 | id_serializer_class = RouterIdSerializer |
| 5827 | |
| 5828 | def get_serializer_class(self): |
| 5829 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5830 | if (no_hyperlinks): |
| 5831 | return self.id_serializer_class |
| 5832 | else: |
| 5833 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5834 | |
| 5835 | def get_queryset(self): |
| 5836 | return Router.select_by_user(self.request.user) |
| 5837 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5838 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5839 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5840 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5841 | |
| 5842 | |
| 5843 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5844 | class ServiceResourceList(generics.ListCreateAPIView): |
| 5845 | queryset = ServiceResource.objects.select_related().all() |
| 5846 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5847 | id_serializer_class = ServiceResourceIdSerializer |
| 5848 | filter_backends = (filters.DjangoFilterBackend,) |
| 5849 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 5850 | |
| 5851 | def get_serializer_class(self): |
| 5852 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5853 | if (no_hyperlinks): |
| 5854 | return self.id_serializer_class |
| 5855 | else: |
| 5856 | return self.serializer_class |
| 5857 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5858 | def get_queryset(self): |
| 5859 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5860 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5861 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5862 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5863 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5864 | response = {"error": "validation", |
| 5865 | "specific_error": "not serializer.is_valid()",
|
| 5866 | "reasons": serializer.errors}
|
| 5867 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5868 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5869 | obj.caller = request.user |
| 5870 | if obj.can_update(request.user): |
| 5871 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5872 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5873 | raise Exception("failed obj.can_update") |
| 5874 | |
| 5875 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5876 | if (ret.status_code%100 != 200): |
| 5877 | raise Exception(ret.data) |
| 5878 | |
| 5879 | return ret |
| 5880 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5881 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5882 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5883 | queryset = ServiceResource.objects.select_related().all() |
| 5884 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5885 | id_serializer_class = ServiceResourceIdSerializer |
| 5886 | |
| 5887 | def get_serializer_class(self): |
| 5888 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5889 | if (no_hyperlinks): |
| 5890 | return self.id_serializer_class |
| 5891 | else: |
| 5892 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5893 | |
| 5894 | def get_queryset(self): |
| 5895 | return ServiceResource.select_by_user(self.request.user) |
| 5896 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5897 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5898 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5899 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5900 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5901 | |
| 5902 | |