Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1 | from rest_framework.decorators import api_view |
| 2 | from rest_framework.response import Response |
| 3 | from rest_framework.reverse import reverse |
| 4 | from rest_framework import serializers |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5 | from rest_framework import generics |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 7 | from rest_framework.generics import GenericAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 8 | from core.models import * |
| 9 | from django.forms import widgets |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 10 | from rest_framework import filters |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 11 | from django.conf.urls import patterns, url |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 12 | from django.core.exceptions import PermissionDenied |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 13 | |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 14 | if hasattr(serializers, "ReadOnlyField"): |
| 15 | # rest_framework 3.x |
| 16 | IdField = serializers.ReadOnlyField |
| 17 | else: |
| 18 | # rest_framework 2.x |
| 19 | IdField = serializers.Field |
| 20 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 21 | """ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 22 | Schema of the generator object: |
| 23 | all: Set of all Model objects |
| 24 | all_if(regex): Set of Model objects that match regex |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 25 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 26 | Model object: |
| 27 | plural: English plural of object name |
| 28 | camel: CamelCase version of object name |
| 29 | refs: list of references to other Model objects |
| 30 | props: list of properties minus refs |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 31 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 32 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 33 | """ |
| 34 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 35 | def get_REST_patterns(): |
| 36 | return patterns('', |
| 37 | url(r'^plstackapi/$', api_root), |
| 38 | |
| 39 | url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 40 | url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
| 41 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 42 | url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'), |
| 43 | url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'), |
| 44 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 45 | url(r'plstackapi/controllersiteprivileges/$', ControllerSitePrivilegeList.as_view(), name='controllersiteprivilege-list'), |
| 46 | url(r'plstackapi/controllersiteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSitePrivilegeDetail.as_view(), name ='controllersiteprivilege-detail'), |
| 47 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 48 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 49 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
| 50 | |
| 51 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 52 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
| 53 | |
| 54 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 55 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
| 56 | |
| 57 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 58 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
| 59 | |
| 60 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 61 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
| 62 | |
| 63 | url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 64 | url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
| 65 | |
| 66 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 67 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
| 68 | |
| 69 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 70 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
| 71 | |
| 72 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 73 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
| 74 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 75 | url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 76 | url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
| 77 | |
| 78 | url(r'plstackapi/controllersites/$', ControllerSiteList.as_view(), name='controllersite-list'), |
| 79 | url(r'plstackapi/controllersites/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDetail.as_view(), name ='controllersite-detail'), |
| 80 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 81 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 82 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 83 | |
| 84 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 85 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 86 | |
| 87 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 88 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 89 | |
| 90 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 91 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 92 | |
| 93 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 94 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 95 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 96 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 97 | 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] | 98 | |
| 99 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 100 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 101 | |
| 102 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 103 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 104 | |
| 105 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 106 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 107 | |
| 108 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 109 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 110 | |
| 111 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 112 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 113 | |
| 114 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 115 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 116 | |
| 117 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 118 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 119 | |
| 120 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 121 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 122 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 123 | url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetwork-list'), |
| 124 | url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetwork-detail'), |
| 125 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 126 | url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 127 | 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] | 128 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 129 | url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controlleruser-list'), |
| 130 | url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controlleruser-detail'), |
| 131 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 132 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 133 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 134 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 135 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 136 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 137 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 138 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 139 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 140 | |
| 141 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 142 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 143 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 144 | url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'), |
| 145 | url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
| 146 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 147 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 148 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 149 | |
| 150 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 151 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 152 | |
| 153 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 154 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
| 155 | |
| 156 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 157 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 158 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 159 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 160 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 161 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 162 | url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslice-list'), |
| 163 | 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] | 164 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 165 | url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'), |
| 166 | url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'), |
| 167 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 168 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 169 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 170 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 171 | url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 172 | url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
| 173 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 174 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 175 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 176 | |
| 177 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 178 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 179 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 180 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 181 | 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] | 182 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 183 | url(r'plstackapi/controllersliceprivileges/$', ControllerSlicePrivilegeList.as_view(), name='controllersliceprivilege-list'), |
| 184 | url(r'plstackapi/controllersliceprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicePrivilegeDetail.as_view(), name ='controllersliceprivilege-detail'), |
| 185 | |
| 186 | url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployment-list'), |
| 187 | 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] | 188 | |
| 189 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 190 | 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] | 191 | |
| 192 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 193 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 194 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 195 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 196 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 197 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 198 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 199 | 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] | 200 | |
| 201 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 202 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 203 | |
| 204 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 205 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 206 | |
| 207 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 208 | |
| 209 | @api_view(['GET']) |
| 210 | def api_root(request, format=None): |
| 211 | return Response({ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 212 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 213 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 214 | 'controllersiteprivileges': reverse('controllersiteprivilege-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 215 | 'images': reverse('image-list', request=request, format=format), |
| 216 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 217 | 'sites': reverse('site-list', request=request, format=format), |
| 218 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 219 | 'tags': reverse('tag-list', request=request, format=format), |
| 220 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 221 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 222 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
| 223 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 224 | 'flavors': reverse('flavor-list', request=request, format=format), |
| 225 | 'controllersites': reverse('controllersite-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 226 | 'projects': reverse('project-list', request=request, format=format), |
| 227 | 'slices': reverse('slice-list', request=request, format=format), |
| 228 | 'networks': reverse('network-list', request=request, format=format), |
| 229 | 'services': reverse('service-list', request=request, format=format), |
| 230 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 231 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 232 | 'charges': reverse('charge-list', request=request, format=format), |
| 233 | 'roles': reverse('role-list', request=request, format=format), |
| 234 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
| 235 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 236 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 237 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 238 | 'nodes': reverse('node-list', request=request, format=format), |
| 239 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 240 | 'controllernetworks': reverse('controllernetwork-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 241 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 242 | 'controllerusers': reverse('controlleruser-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 243 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 244 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 245 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 246 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 247 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 248 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 249 | 'users': reverse('user-list', request=request, format=format), |
| 250 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 251 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 252 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 253 | 'controllerslices': reverse('controllerslice-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 254 | 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 255 | 'accounts': reverse('account-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 256 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 257 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 258 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 259 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 260 | 'controllersliceprivileges': reverse('controllersliceprivilege-list', request=request, format=format), |
| 261 | 'sitedeployments': reverse('sitedeployment-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 262 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 263 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 264 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 265 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 266 | 'routers': reverse('router-list', request=request, format=format), |
| 267 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
| 268 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 269 | }) |
| 270 | |
| 271 | # Based on serializers.py |
| 272 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 273 | class XOSModelSerializer(serializers.ModelSerializer): |
| 274 | def save_object(self, obj, **kwargs): |
| 275 | |
| 276 | """ rest_framework can't deal with ManyToMany relations that have a |
| 277 | through table. In plstackapi, most of the through tables we have |
| 278 | use defaults or blank fields, so there's no reason why we shouldn't |
| 279 | be able to save these objects. |
| 280 | |
| 281 | So, let's strip out these m2m relations, and deal with them ourself. |
| 282 | """ |
| 283 | obj._complex_m2m_data={};
|
| 284 | if getattr(obj, '_m2m_data', None):
|
| 285 | for relatedObject in obj._meta.get_all_related_many_to_many_objects():
|
| 286 | if (relatedObject.field.rel.through._meta.auto_created):
|
| 287 | # These are non-trough ManyToMany relations and
|
| 288 | # can be updated just fine
|
| 289 | continue
|
| 290 | fieldName = relatedObject.get_accessor_name()
|
| 291 | if fieldName in obj._m2m_data.keys():
|
| 292 | obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
|
| 293 | del obj._m2m_data[fieldName]
|
| 294 |
|
| 295 | serializers.ModelSerializer.save_object(self, obj, **kwargs); |
| 296 | |
| 297 | for (accessor, stuff) in obj._complex_m2m_data.items(): |
| 298 | (relatedObject, data) = stuff |
| 299 | through = relatedObject.field.rel.through |
| 300 | local_fieldName = relatedObject.field.m2m_reverse_field_name() |
| 301 | remote_fieldName = relatedObject.field.m2m_field_name() |
| 302 | |
| 303 | # get the current set of existing relations |
| 304 | existing = through.objects.filter(**{local_fieldName: obj}); |
| 305 | |
| 306 | data_ids = [item.id for item in data] |
| 307 | existing_ids = [getattr(item,remote_fieldName).id for item in existing] |
| 308 | |
| 309 | #print "data_ids", data_ids |
| 310 | #print "existing_ids", existing_ids |
| 311 | |
| 312 | # remove relations that are in 'existing' but not in 'data' |
| 313 | for item in list(existing): |
| 314 | if (getattr(item,remote_fieldName).id not in data_ids): |
| 315 | print "delete", getattr(item,remote_fieldName) |
| 316 | item.delete() #(purge=True) |
| 317 | |
| 318 | # add relations that are in 'data' but not in 'existing' |
| 319 | for item in data: |
| 320 | if (item.id not in existing_ids): |
| 321 | #print "add", item |
| 322 | newModel = through(**{local_fieldName: obj, remote_fieldName: item}) |
| 323 | newModel.save() |
| 324 | |
| 325 | |
| 326 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 327 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 328 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 329 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 330 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 331 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 332 | def getHumanReadableName(self, obj):
|
| 333 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 334 | def getValidators(self, obj): |
| 335 | try: |
| 336 | return obj.getValidators() |
| 337 | except: |
| 338 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 339 | class Meta: |
| 340 | model = ServiceAttribute |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 341 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 342 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 343 | class ServiceAttributeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 344 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 345 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 346 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 347 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 348 | def getHumanReadableName(self, obj):
|
| 349 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 350 | def getValidators(self, obj):
|
| 351 | try: |
| 352 | return obj.getValidators() |
| 353 | except: |
| 354 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 355 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 356 | model = ServiceAttribute |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 357 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 358 | |
| 359 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 360 | |
| 361 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 362 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 363 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 364 | |
| 365 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 366 | validators = serializers.SerializerMethodField("getValidators") |
| 367 | def getHumanReadableName(self, obj):
|
| 368 | return str(obj) |
| 369 | def getValidators(self, obj): |
| 370 | try: |
| 371 | return obj.getValidators() |
| 372 | except: |
| 373 | return None |
| 374 | class Meta: |
| 375 | model = ControllerImages |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 376 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 377 | |
| 378 | class ControllerImagesIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 379 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 380 | |
| 381 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 382 | validators = serializers.SerializerMethodField("getValidators") |
| 383 | def getHumanReadableName(self, obj):
|
| 384 | return str(obj)
|
| 385 | def getValidators(self, obj):
|
| 386 | try: |
| 387 | return obj.getValidators() |
| 388 | except: |
| 389 | return None
|
| 390 | class Meta:
|
| 391 | model = ControllerImages |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 392 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 393 | |
| 394 | |
| 395 | |
| 396 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 397 | class ControllerSitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 398 | id = IdField() |
| 399 | |
| 400 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 401 | validators = serializers.SerializerMethodField("getValidators") |
| 402 | def getHumanReadableName(self, obj):
|
| 403 | return str(obj) |
| 404 | def getValidators(self, obj): |
| 405 | try: |
| 406 | return obj.getValidators() |
| 407 | except: |
| 408 | return None |
| 409 | class Meta: |
| 410 | model = ControllerSitePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 411 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 412 | |
| 413 | class ControllerSitePrivilegeIdSerializer(XOSModelSerializer): |
| 414 | id = IdField() |
| 415 | |
| 416 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 417 | validators = serializers.SerializerMethodField("getValidators") |
| 418 | def getHumanReadableName(self, obj):
|
| 419 | return str(obj)
|
| 420 | def getValidators(self, obj):
|
| 421 | try: |
| 422 | return obj.getValidators() |
| 423 | except: |
| 424 | return None
|
| 425 | class Meta:
|
| 426 | model = ControllerSitePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 427 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 428 | |
| 429 | |
| 430 | |
| 431 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 432 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 433 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 434 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 435 | |
| 436 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 437 | |
| 438 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 439 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 440 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 441 | def getHumanReadableName(self, obj):
|
| 442 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 443 | def getValidators(self, obj): |
| 444 | try: |
| 445 | return obj.getValidators() |
| 446 | except: |
| 447 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 448 | class Meta: |
| 449 | model = Image |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 450 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 451 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 452 | class ImageIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 453 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 454 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 455 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 456 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 457 | |
| 458 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 459 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 460 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 461 | def getHumanReadableName(self, obj):
|
| 462 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 463 | def getValidators(self, obj):
|
| 464 | try: |
| 465 | return obj.getValidators() |
| 466 | except: |
| 467 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 468 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 469 | model = Image |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 470 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 471 | |
| 472 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 473 | |
| 474 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 475 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 476 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 477 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 478 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 479 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 480 | def getHumanReadableName(self, obj):
|
| 481 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 482 | def getValidators(self, obj): |
| 483 | try: |
| 484 | return obj.getValidators() |
| 485 | except: |
| 486 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 487 | class Meta: |
| 488 | model = NetworkParameter |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 489 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 490 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 491 | class NetworkParameterIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 492 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 493 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 494 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 495 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 496 | def getHumanReadableName(self, obj):
|
| 497 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 498 | def getValidators(self, obj):
|
| 499 | try: |
| 500 | return obj.getValidators() |
| 501 | except: |
| 502 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 503 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 504 | model = NetworkParameter |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 505 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 506 | |
| 507 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 508 | |
| 509 | |
| 510 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 511 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 512 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 513 | |
| 514 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 515 | |
| 516 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 517 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 518 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 519 | def getHumanReadableName(self, obj):
|
| 520 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 521 | def getValidators(self, obj): |
| 522 | try: |
| 523 | return obj.getValidators() |
| 524 | except: |
| 525 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 526 | class Meta: |
| 527 | model = Site |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 528 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 529 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 530 | class SiteIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 531 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 532 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 533 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 534 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 535 | |
| 536 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 537 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 538 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 539 | def getHumanReadableName(self, obj):
|
| 540 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 541 | def getValidators(self, obj):
|
| 542 | try: |
| 543 | return obj.getValidators() |
| 544 | except: |
| 545 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 546 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 547 | model = Site |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 548 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 549 | |
| 550 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 551 | |
| 552 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 553 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 554 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 555 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 556 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 557 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 558 | def getHumanReadableName(self, obj):
|
| 559 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 560 | def getValidators(self, obj): |
| 561 | try: |
| 562 | return obj.getValidators() |
| 563 | except: |
| 564 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 565 | class Meta: |
| 566 | model = SliceRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 567 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 568 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 569 | class SliceRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 570 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 571 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 572 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 573 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 574 | def getHumanReadableName(self, obj):
|
| 575 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 576 | def getValidators(self, obj):
|
| 577 | try: |
| 578 | return obj.getValidators() |
| 579 | except: |
| 580 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 581 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 582 | model = SliceRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 583 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 584 | |
| 585 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 586 | |
| 587 | |
| 588 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 589 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 590 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 591 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 592 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 593 | def getHumanReadableName(self, obj):
|
| 594 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 595 | def getValidators(self, obj): |
| 596 | try: |
| 597 | return obj.getValidators() |
| 598 | except: |
| 599 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 600 | class Meta: |
| 601 | model = Tag |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 602 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 603 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 604 | class TagIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 605 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 606 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 607 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 608 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 609 | def getHumanReadableName(self, obj):
|
| 610 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 611 | def getValidators(self, obj):
|
| 612 | try: |
| 613 | return obj.getValidators() |
| 614 | except: |
| 615 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 616 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 617 | model = Tag |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 618 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 619 | |
| 620 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 621 | |
| 622 | |
| 623 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 624 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 625 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 626 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 627 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 628 | def getHumanReadableName(self, obj):
|
| 629 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 630 | def getValidators(self, obj): |
| 631 | try: |
| 632 | return obj.getValidators() |
| 633 | except: |
| 634 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 635 | class Meta: |
| 636 | model = Invoice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 637 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 638 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 639 | class InvoiceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 640 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 641 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 642 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 643 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 644 | def getHumanReadableName(self, obj):
|
| 645 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 646 | def getValidators(self, obj):
|
| 647 | try: |
| 648 | return obj.getValidators() |
| 649 | except: |
| 650 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 651 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 652 | model = Invoice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 653 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 654 | |
| 655 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 656 | |
| 657 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 658 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 659 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 660 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 661 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 662 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 663 | def getHumanReadableName(self, obj):
|
| 664 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 665 | def getValidators(self, obj): |
| 666 | try: |
| 667 | return obj.getValidators() |
| 668 | except: |
| 669 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 670 | class Meta: |
| 671 | model = SlicePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 672 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 673 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 674 | class SlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 675 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 676 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 677 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 678 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 679 | def getHumanReadableName(self, obj):
|
| 680 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 681 | def getValidators(self, obj):
|
| 682 | try: |
| 683 | return obj.getValidators() |
| 684 | except: |
| 685 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 686 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 687 | model = SlicePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 688 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 689 | |
| 690 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 691 | |
| 692 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 693 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 694 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 695 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 696 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 697 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 698 | def getHumanReadableName(self, obj):
|
| 699 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 700 | def getValidators(self, obj): |
| 701 | try: |
| 702 | return obj.getValidators() |
| 703 | except: |
| 704 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 705 | class Meta: |
| 706 | model = PlanetStackRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 707 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 708 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 709 | class PlanetStackRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 710 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 711 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 712 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 713 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 714 | def getHumanReadableName(self, obj):
|
| 715 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 716 | def getValidators(self, obj):
|
| 717 | try: |
| 718 | return obj.getValidators() |
| 719 | except: |
| 720 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 721 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 722 | model = PlanetStackRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 723 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 724 | |
| 725 | |
| 726 | |
| 727 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 728 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 729 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 730 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 731 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 732 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 733 | def getHumanReadableName(self, obj):
|
| 734 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 735 | def getValidators(self, obj): |
| 736 | try: |
| 737 | return obj.getValidators() |
| 738 | except: |
| 739 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 740 | class Meta: |
| 741 | model = NetworkSliver |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 742 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 743 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 744 | class NetworkSliverIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 745 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 746 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 747 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 748 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 749 | def getHumanReadableName(self, obj):
|
| 750 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 751 | def getValidators(self, obj):
|
| 752 | try: |
| 753 | return obj.getValidators() |
| 754 | except: |
| 755 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 756 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 757 | model = NetworkSliver |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 758 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 759 | |
| 760 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 761 | |
| 762 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 763 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
| 764 | id = IdField() |
| 765 | |
| 766 | |
| 767 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 768 | |
| 769 | |
| 770 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 771 | validators = serializers.SerializerMethodField("getValidators") |
| 772 | def getHumanReadableName(self, obj):
|
| 773 | return str(obj) |
| 774 | def getValidators(self, obj): |
| 775 | try: |
| 776 | return obj.getValidators() |
| 777 | except: |
| 778 | return None |
| 779 | class Meta: |
| 780 | model = Flavor |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 781 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 782 | |
| 783 | class FlavorIdSerializer(XOSModelSerializer): |
| 784 | id = IdField() |
| 785 | |
| 786 | |
| 787 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
| 788 | |
| 789 | |
| 790 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 791 | validators = serializers.SerializerMethodField("getValidators") |
| 792 | def getHumanReadableName(self, obj):
|
| 793 | return str(obj)
|
| 794 | def getValidators(self, obj):
|
| 795 | try: |
| 796 | return obj.getValidators() |
| 797 | except: |
| 798 | return None
|
| 799 | class Meta:
|
| 800 | model = Flavor |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 801 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | class ControllerSiteSerializer(serializers.HyperlinkedModelSerializer): |
| 807 | id = IdField() |
| 808 | |
| 809 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 810 | validators = serializers.SerializerMethodField("getValidators") |
| 811 | def getHumanReadableName(self, obj):
|
| 812 | return str(obj) |
| 813 | def getValidators(self, obj): |
| 814 | try: |
| 815 | return obj.getValidators() |
| 816 | except: |
| 817 | return None |
| 818 | class Meta: |
| 819 | model = ControllerSite |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 820 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 821 | |
| 822 | class ControllerSiteIdSerializer(XOSModelSerializer): |
| 823 | id = IdField() |
| 824 | |
| 825 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 826 | validators = serializers.SerializerMethodField("getValidators") |
| 827 | def getHumanReadableName(self, obj):
|
| 828 | return str(obj)
|
| 829 | def getValidators(self, obj):
|
| 830 | try: |
| 831 | return obj.getValidators() |
| 832 | except: |
| 833 | return None
|
| 834 | class Meta:
|
| 835 | model = ControllerSite |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 836 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 837 | |
| 838 | |
| 839 | |
| 840 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 841 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 842 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 843 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 844 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 845 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 846 | def getHumanReadableName(self, obj):
|
| 847 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 848 | def getValidators(self, obj): |
| 849 | try: |
| 850 | return obj.getValidators() |
| 851 | except: |
| 852 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 853 | class Meta: |
| 854 | model = Project |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 855 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 856 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 857 | class ProjectIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 858 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 859 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 860 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 861 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 862 | def getHumanReadableName(self, obj):
|
| 863 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 864 | def getValidators(self, obj):
|
| 865 | try: |
| 866 | return obj.getValidators() |
| 867 | except: |
| 868 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 869 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 870 | model = Project |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 871 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 872 | |
| 873 | |
| 874 | |
| 875 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 876 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 877 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 878 | |
| 879 | |
| 880 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 881 | |
| 882 | |
| 883 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 884 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 885 | |
| 886 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 887 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 888 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 889 | def getHumanReadableName(self, obj):
|
| 890 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 891 | def getValidators(self, obj): |
| 892 | try: |
| 893 | return obj.getValidators() |
| 894 | except: |
| 895 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 896 | class Meta: |
| 897 | model = Slice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 898 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 899 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 900 | class SliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 901 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 902 | |
| 903 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 904 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 905 | |
| 906 | |
| 907 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 908 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 909 | |
| 910 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 911 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 912 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 913 | def getHumanReadableName(self, obj):
|
| 914 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 915 | def getValidators(self, obj):
|
| 916 | try: |
| 917 | return obj.getValidators() |
| 918 | except: |
| 919 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 920 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 921 | model = Slice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 922 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 923 | |
| 924 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 925 | |
| 926 | |
| 927 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 928 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 929 | |
| 930 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 931 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 932 | |
| 933 | |
| 934 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 935 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 936 | |
| 937 | |
| 938 | |
| 939 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 940 | |
| 941 | |
| 942 | |
| 943 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 944 | |
| 945 | |
| 946 | |
| 947 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 948 | |
| 949 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 950 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 951 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 952 | def getHumanReadableName(self, obj):
|
| 953 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 954 | def getValidators(self, obj): |
| 955 | try: |
| 956 | return obj.getValidators() |
| 957 | except: |
| 958 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 959 | class Meta: |
| 960 | model = Network |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 961 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 962 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 963 | class NetworkIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 964 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 965 | |
| 966 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 967 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 968 | |
| 969 | |
| 970 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 971 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 972 | |
| 973 | |
| 974 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 975 | slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 976 | |
| 977 | |
| 978 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 979 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 980 | |
| 981 | |
| 982 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 983 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 984 | |
| 985 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 986 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 987 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 988 | def getHumanReadableName(self, obj):
|
| 989 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 990 | def getValidators(self, obj):
|
| 991 | try: |
| 992 | return obj.getValidators() |
| 993 | except: |
| 994 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 995 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 996 | model = Network |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 997 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 998 | |
| 999 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1000 | |
| 1001 | |
| 1002 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1003 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1004 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1005 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1006 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1007 | def getHumanReadableName(self, obj):
|
| 1008 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1009 | def getValidators(self, obj): |
| 1010 | try: |
| 1011 | return obj.getValidators() |
| 1012 | except: |
| 1013 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1014 | class Meta: |
| 1015 | model = Service |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1016 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1017 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1018 | class ServiceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1019 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1020 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1021 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1022 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1023 | def getHumanReadableName(self, obj):
|
| 1024 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1025 | def getValidators(self, obj):
|
| 1026 | try: |
| 1027 | return obj.getValidators() |
| 1028 | except: |
| 1029 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1030 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1031 | model = Service |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1032 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1033 | |
| 1034 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1035 | |
| 1036 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1037 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1038 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1039 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1040 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1041 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1042 | def getHumanReadableName(self, obj):
|
| 1043 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1044 | def getValidators(self, obj): |
| 1045 | try: |
| 1046 | return obj.getValidators() |
| 1047 | except: |
| 1048 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1049 | class Meta: |
| 1050 | model = ServiceClass |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1051 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1052 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1053 | class ServiceClassIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1054 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1055 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1056 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1057 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1058 | def getHumanReadableName(self, obj):
|
| 1059 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1060 | def getValidators(self, obj):
|
| 1061 | try: |
| 1062 | return obj.getValidators() |
| 1063 | except: |
| 1064 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1065 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1066 | model = ServiceClass |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1067 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1068 | |
| 1069 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1070 | |
| 1071 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1072 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1073 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1074 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1075 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1076 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1077 | def getHumanReadableName(self, obj):
|
| 1078 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1079 | def getValidators(self, obj): |
| 1080 | try: |
| 1081 | return obj.getValidators() |
| 1082 | except: |
| 1083 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1084 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1085 | model = PlanetStack |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1086 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1087 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1088 | class PlanetStackIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1089 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1090 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1091 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1092 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1093 | def getHumanReadableName(self, obj):
|
| 1094 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1095 | def getValidators(self, obj):
|
| 1096 | try: |
| 1097 | return obj.getValidators() |
| 1098 | except: |
| 1099 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1100 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1101 | model = PlanetStack |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1102 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1103 | |
| 1104 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1105 | |
| 1106 | |
| 1107 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1108 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1109 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1110 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1111 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1112 | def getHumanReadableName(self, obj):
|
| 1113 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1114 | def getValidators(self, obj): |
| 1115 | try: |
| 1116 | return obj.getValidators() |
| 1117 | except: |
| 1118 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1119 | class Meta: |
| 1120 | model = Charge |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1121 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1122 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1123 | class ChargeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1124 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1125 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1126 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1127 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1128 | def getHumanReadableName(self, obj):
|
| 1129 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1130 | def getValidators(self, obj):
|
| 1131 | try: |
| 1132 | return obj.getValidators() |
| 1133 | except: |
| 1134 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1135 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1136 | model = Charge |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1137 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1138 | |
| 1139 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1140 | |
| 1141 | |
| 1142 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1143 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1144 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1145 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1146 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1147 | def getHumanReadableName(self, obj):
|
| 1148 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1149 | def getValidators(self, obj): |
| 1150 | try: |
| 1151 | return obj.getValidators() |
| 1152 | except: |
| 1153 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1154 | class Meta: |
| 1155 | model = Role |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1156 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1157 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1158 | class RoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1159 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1160 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1161 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1162 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1163 | def getHumanReadableName(self, obj):
|
| 1164 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1165 | def getValidators(self, obj):
|
| 1166 | try: |
| 1167 | return obj.getValidators() |
| 1168 | except: |
| 1169 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1170 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1171 | model = Role |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1172 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1173 | |
| 1174 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1175 | |
| 1176 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1177 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1178 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1179 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1180 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1181 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1182 | def getHumanReadableName(self, obj):
|
| 1183 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1184 | def getValidators(self, obj): |
| 1185 | try: |
| 1186 | return obj.getValidators() |
| 1187 | except: |
| 1188 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1189 | class Meta: |
| 1190 | model = UsableObject |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1191 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1192 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1193 | class UsableObjectIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1194 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1195 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1196 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1197 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1198 | def getHumanReadableName(self, obj):
|
| 1199 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1200 | def getValidators(self, obj):
|
| 1201 | try: |
| 1202 | return obj.getValidators() |
| 1203 | except: |
| 1204 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1205 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1206 | model = UsableObject |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1207 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1208 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1209 | |
| 1210 | |
| 1211 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1212 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1213 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1214 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1215 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1216 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1217 | def getHumanReadableName(self, obj):
|
| 1218 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1219 | def getValidators(self, obj): |
| 1220 | try: |
| 1221 | return obj.getValidators() |
| 1222 | except: |
| 1223 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1224 | class Meta: |
| 1225 | model = SiteRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1226 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1227 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1228 | class SiteRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1229 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1230 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1231 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1232 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1233 | def getHumanReadableName(self, obj):
|
| 1234 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1235 | def getValidators(self, obj):
|
| 1236 | try: |
| 1237 | return obj.getValidators() |
| 1238 | except: |
| 1239 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1240 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1241 | model = SiteRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1242 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1243 | |
| 1244 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1245 | |
| 1246 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1247 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1248 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1249 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1250 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1251 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1252 | def getHumanReadableName(self, obj):
|
| 1253 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1254 | def getValidators(self, obj): |
| 1255 | try: |
| 1256 | return obj.getValidators() |
| 1257 | except: |
| 1258 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1259 | class Meta: |
| 1260 | model = SliceCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1261 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1262 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1263 | class SliceCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1264 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1265 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1266 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1267 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1268 | def getHumanReadableName(self, obj):
|
| 1269 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1270 | def getValidators(self, obj):
|
| 1271 | try: |
| 1272 | return obj.getValidators() |
| 1273 | except: |
| 1274 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1275 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1276 | model = SliceCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1277 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1278 | |
| 1279 | |
| 1280 | |
| 1281 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1282 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1283 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1284 | |
| 1285 | |
| 1286 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1287 | |
| 1288 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1289 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1290 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1291 | def getHumanReadableName(self, obj):
|
| 1292 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1293 | def getValidators(self, obj): |
| 1294 | try: |
| 1295 | return obj.getValidators() |
| 1296 | except: |
| 1297 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1298 | class Meta: |
| 1299 | model = Sliver |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1300 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1301 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1302 | class SliverIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1303 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1304 | |
| 1305 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1306 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1307 | |
| 1308 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1309 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1310 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1311 | def getHumanReadableName(self, obj):
|
| 1312 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1313 | def getValidators(self, obj):
|
| 1314 | try: |
| 1315 | return obj.getValidators() |
| 1316 | except: |
| 1317 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1318 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1319 | model = Sliver |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1320 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1321 | |
| 1322 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1323 | |
| 1324 | |
| 1325 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1326 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1327 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1328 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1329 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1330 | def getHumanReadableName(self, obj):
|
| 1331 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1332 | def getValidators(self, obj): |
| 1333 | try: |
| 1334 | return obj.getValidators() |
| 1335 | except: |
| 1336 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1337 | class Meta: |
| 1338 | model = Node |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1339 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1340 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1341 | class NodeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1342 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1343 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1344 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1345 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1346 | def getHumanReadableName(self, obj):
|
| 1347 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1348 | def getValidators(self, obj):
|
| 1349 | try: |
| 1350 | return obj.getValidators() |
| 1351 | except: |
| 1352 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1353 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1354 | model = Node |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1355 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1356 | |
| 1357 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1358 | |
| 1359 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1360 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1361 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1362 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1363 | |
| 1364 | controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail') |
| 1365 | |
| 1366 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1367 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1368 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1369 | def getHumanReadableName(self, obj):
|
| 1370 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1371 | def getValidators(self, obj): |
| 1372 | try: |
| 1373 | return obj.getValidators() |
| 1374 | except: |
| 1375 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1376 | class Meta: |
| 1377 | model = DashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1378 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1379 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1380 | class DashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1381 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1382 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1383 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1384 | controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1385 | |
| 1386 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1387 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1388 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1389 | def getHumanReadableName(self, obj):
|
| 1390 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1391 | def getValidators(self, obj):
|
| 1392 | try: |
| 1393 | return obj.getValidators() |
| 1394 | except: |
| 1395 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1396 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1397 | model = DashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1398 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1399 | |
| 1400 | |
| 1401 | |
| 1402 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1403 | class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer): |
| 1404 | id = IdField() |
| 1405 | |
| 1406 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1407 | validators = serializers.SerializerMethodField("getValidators") |
| 1408 | def getHumanReadableName(self, obj):
|
| 1409 | return str(obj) |
| 1410 | def getValidators(self, obj): |
| 1411 | try: |
| 1412 | return obj.getValidators() |
| 1413 | except: |
| 1414 | return None |
| 1415 | class Meta: |
| 1416 | model = ControllerNetwork |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1417 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1418 | |
| 1419 | class ControllerNetworkIdSerializer(XOSModelSerializer): |
| 1420 | id = IdField() |
| 1421 | |
| 1422 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1423 | validators = serializers.SerializerMethodField("getValidators") |
| 1424 | def getHumanReadableName(self, obj):
|
| 1425 | return str(obj)
|
| 1426 | def getValidators(self, obj):
|
| 1427 | try: |
| 1428 | return obj.getValidators() |
| 1429 | except: |
| 1430 | return None
|
| 1431 | class Meta:
|
| 1432 | model = ControllerNetwork |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1433 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1434 | |
| 1435 | |
| 1436 | |
| 1437 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1438 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1439 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1440 | |
| 1441 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1442 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1443 | def getHumanReadableName(self, obj):
|
| 1444 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1445 | def getValidators(self, obj): |
| 1446 | try: |
| 1447 | return obj.getValidators() |
| 1448 | except: |
| 1449 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1450 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1451 | model = ImageDeployments |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1452 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1453 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1454 | class ImageDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1455 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1456 | |
| 1457 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1458 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1459 | def getHumanReadableName(self, obj):
|
| 1460 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1461 | def getValidators(self, obj):
|
| 1462 | try: |
| 1463 | return obj.getValidators() |
| 1464 | except: |
| 1465 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1466 | class Meta:
|
| 1467 | model = ImageDeployments |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1468 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1469 | |
| 1470 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1471 | |
| 1472 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1473 | class ControllerUserSerializer(serializers.HyperlinkedModelSerializer): |
| 1474 | id = IdField() |
| 1475 | |
| 1476 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1477 | validators = serializers.SerializerMethodField("getValidators") |
| 1478 | def getHumanReadableName(self, obj):
|
| 1479 | return str(obj) |
| 1480 | def getValidators(self, obj): |
| 1481 | try: |
| 1482 | return obj.getValidators() |
| 1483 | except: |
| 1484 | return None |
| 1485 | class Meta: |
| 1486 | model = ControllerUser |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1487 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1488 | |
| 1489 | class ControllerUserIdSerializer(XOSModelSerializer): |
| 1490 | id = IdField() |
| 1491 | |
| 1492 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1493 | validators = serializers.SerializerMethodField("getValidators") |
| 1494 | def getHumanReadableName(self, obj):
|
| 1495 | return str(obj)
|
| 1496 | def getValidators(self, obj):
|
| 1497 | try: |
| 1498 | return obj.getValidators() |
| 1499 | except: |
| 1500 | return None
|
| 1501 | class Meta:
|
| 1502 | model = ControllerUser |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1503 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1504 | |
| 1505 | |
| 1506 | |
| 1507 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1508 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1509 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1510 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1511 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1512 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1513 | def getHumanReadableName(self, obj):
|
| 1514 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1515 | def getValidators(self, obj): |
| 1516 | try: |
| 1517 | return obj.getValidators() |
| 1518 | except: |
| 1519 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1520 | class Meta: |
| 1521 | model = ReservedResource |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1522 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1523 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1524 | class ReservedResourceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1525 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1526 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1527 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1528 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1529 | def getHumanReadableName(self, obj):
|
| 1530 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1531 | def getValidators(self, obj):
|
| 1532 | try: |
| 1533 | return obj.getValidators() |
| 1534 | except: |
| 1535 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1536 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1537 | model = ReservedResource |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1538 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1539 | |
| 1540 | |
| 1541 | |
| 1542 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1543 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1544 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1545 | |
| 1546 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1547 | validators = serializers.SerializerMethodField("getValidators") |
| 1548 | def getHumanReadableName(self, obj):
|
| 1549 | return str(obj) |
| 1550 | def getValidators(self, obj): |
| 1551 | try: |
| 1552 | return obj.getValidators() |
| 1553 | except: |
| 1554 | return None |
| 1555 | class Meta: |
| 1556 | model = Payment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1557 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1558 | |
| 1559 | class PaymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1560 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1561 | |
| 1562 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1563 | validators = serializers.SerializerMethodField("getValidators") |
| 1564 | def getHumanReadableName(self, obj):
|
| 1565 | return str(obj)
|
| 1566 | def getValidators(self, obj):
|
| 1567 | try: |
| 1568 | return obj.getValidators() |
| 1569 | except: |
| 1570 | return None
|
| 1571 | class Meta:
|
| 1572 | model = Payment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1573 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1574 | |
| 1575 | |
| 1576 | |
| 1577 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1578 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1579 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1580 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1581 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1582 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1583 | def getHumanReadableName(self, obj):
|
| 1584 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1585 | def getValidators(self, obj): |
| 1586 | try: |
| 1587 | return obj.getValidators() |
| 1588 | except: |
| 1589 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1590 | class Meta: |
| 1591 | model = NetworkSlice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1592 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1593 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1594 | class NetworkSliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1595 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1596 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1597 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1598 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1599 | def getHumanReadableName(self, obj):
|
| 1600 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1601 | def getValidators(self, obj):
|
| 1602 | try: |
| 1603 | return obj.getValidators() |
| 1604 | except: |
| 1605 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1606 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1607 | model = NetworkSlice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1608 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1609 | |
| 1610 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1611 | |
| 1612 | |
| 1613 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1614 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1615 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1616 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1617 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1618 | def getHumanReadableName(self, obj):
|
| 1619 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1620 | def getValidators(self, obj): |
| 1621 | try: |
| 1622 | return obj.getValidators() |
| 1623 | except: |
| 1624 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1625 | class Meta: |
| 1626 | model = UserDashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1627 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1628 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1629 | class UserDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1630 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1631 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1632 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1633 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1634 | def getHumanReadableName(self, obj):
|
| 1635 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1636 | def getValidators(self, obj):
|
| 1637 | try: |
| 1638 | return obj.getValidators() |
| 1639 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1640 | return None
|
| 1641 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1642 | model = UserDashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1643 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1644 | |
| 1645 | |
| 1646 | |
| 1647 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1648 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1649 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1650 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1651 | |
| 1652 | dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail') |
| 1653 | |
| 1654 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1655 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1656 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1657 | def getHumanReadableName(self, obj):
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1658 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1659 | def getValidators(self, obj): |
| 1660 | try: |
| 1661 | return obj.getValidators() |
| 1662 | except: |
| 1663 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1664 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1665 | model = Controller |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1666 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1667 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1668 | class ControllerIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1669 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1670 | |
| 1671 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1672 | dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1673 | |
| 1674 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1675 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1676 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1677 | def getHumanReadableName(self, obj):
|
| 1678 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1679 | def getValidators(self, obj):
|
| 1680 | try: |
| 1681 | return obj.getValidators() |
| 1682 | except: |
| 1683 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1684 | class Meta:
|
| 1685 | model = Controller |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1686 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1687 | |
| 1688 | |
| 1689 | |
| 1690 | |
| 1691 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1692 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1693 | |
| 1694 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1695 | validators = serializers.SerializerMethodField("getValidators") |
| 1696 | def getHumanReadableName(self, obj):
|
| 1697 | return str(obj) |
| 1698 | def getValidators(self, obj): |
| 1699 | try: |
| 1700 | return obj.getValidators() |
| 1701 | except: |
| 1702 | return None |
| 1703 | class Meta: |
| 1704 | model = PlanetStackPrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1705 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1706 | |
| 1707 | class PlanetStackPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1708 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1709 | |
| 1710 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1711 | validators = serializers.SerializerMethodField("getValidators") |
| 1712 | def getHumanReadableName(self, obj):
|
| 1713 | return str(obj)
|
| 1714 | def getValidators(self, obj):
|
| 1715 | try: |
| 1716 | return obj.getValidators() |
| 1717 | except: |
| 1718 | return None
|
| 1719 | class Meta:
|
| 1720 | model = PlanetStackPrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1721 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1722 | |
| 1723 | |
| 1724 | |
| 1725 | |
| 1726 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1727 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1728 | |
| 1729 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1730 | validators = serializers.SerializerMethodField("getValidators") |
| 1731 | def getHumanReadableName(self, obj):
|
| 1732 | return str(obj) |
| 1733 | def getValidators(self, obj): |
| 1734 | try: |
| 1735 | return obj.getValidators() |
| 1736 | except: |
| 1737 | return None |
| 1738 | class Meta: |
| 1739 | model = User |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1740 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1741 | |
| 1742 | class UserIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1743 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1744 | |
| 1745 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1746 | validators = serializers.SerializerMethodField("getValidators") |
| 1747 | def getHumanReadableName(self, obj):
|
| 1748 | return str(obj)
|
| 1749 | def getValidators(self, obj):
|
| 1750 | try: |
| 1751 | return obj.getValidators() |
| 1752 | except: |
| 1753 | return None
|
| 1754 | class Meta:
|
| 1755 | model = User |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1756 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1757 | |
| 1758 | |
| 1759 | |
| 1760 | |
| 1761 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1762 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1763 | |
| 1764 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1765 | images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail') |
| 1766 | |
| 1767 | |
| 1768 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1769 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1770 | |
| 1771 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1772 | |
| 1773 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1774 | |
| 1775 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1776 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1777 | validators = serializers.SerializerMethodField("getValidators") |
| 1778 | def getHumanReadableName(self, obj):
|
| 1779 | return str(obj) |
| 1780 | def getValidators(self, obj): |
| 1781 | try: |
| 1782 | return obj.getValidators() |
| 1783 | except: |
| 1784 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1785 | class Meta: |
| 1786 | model = Deployment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1787 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1788 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1789 | class DeploymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1790 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1791 | |
| 1792 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1793 | images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all()) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1794 | |
| 1795 | |
| 1796 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1797 | sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1798 | |
| 1799 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1800 | |
| 1801 | flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all()) |
| 1802 | |
| 1803 | |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1804 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1805 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1806 | def getHumanReadableName(self, obj):
|
| 1807 | return str(obj)
|
| 1808 | def getValidators(self, obj):
|
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1809 | try: |
| 1810 | return obj.getValidators() |
| 1811 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1812 | return None
|
| 1813 | class Meta:
|
| 1814 | model = Deployment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1815 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1816 | |
| 1817 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1818 | |
| 1819 | |
| 1820 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1821 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1822 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1823 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1824 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1825 | def getHumanReadableName(self, obj):
|
| 1826 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1827 | def getValidators(self, obj): |
| 1828 | try: |
| 1829 | return obj.getValidators() |
| 1830 | except: |
| 1831 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1832 | class Meta: |
| 1833 | model = Reservation |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1834 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1835 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1836 | class ReservationIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1837 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1838 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1839 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1840 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1841 | def getHumanReadableName(self, obj):
|
| 1842 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1843 | def getValidators(self, obj):
|
| 1844 | try: |
| 1845 | return obj.getValidators() |
| 1846 | except: |
| 1847 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1848 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1849 | model = Reservation |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1850 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1851 | |
| 1852 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1853 | |
| 1854 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1855 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1856 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1857 | |
| 1858 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1859 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1860 | def getHumanReadableName(self, obj):
|
| 1861 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1862 | def getValidators(self, obj): |
| 1863 | try: |
| 1864 | return obj.getValidators() |
| 1865 | except: |
| 1866 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1867 | class Meta: |
| 1868 | model = SitePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1869 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1870 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1871 | class SitePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1872 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1873 | |
| 1874 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1875 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1876 | def getHumanReadableName(self, obj):
|
| 1877 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1878 | def getValidators(self, obj):
|
| 1879 | try: |
| 1880 | return obj.getValidators() |
| 1881 | except: |
| 1882 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1883 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1884 | model = SitePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1885 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1886 | |
| 1887 | |
| 1888 | |
| 1889 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1890 | class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1891 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1892 | |
| 1893 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1894 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1895 | def getHumanReadableName(self, obj):
|
| 1896 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1897 | def getValidators(self, obj): |
| 1898 | try: |
| 1899 | return obj.getValidators() |
| 1900 | except: |
| 1901 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1902 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1903 | model = ControllerSlice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1904 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1905 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1906 | class ControllerSliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1907 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1908 | |
| 1909 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1910 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1911 | def getHumanReadableName(self, obj):
|
| 1912 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1913 | def getValidators(self, obj):
|
| 1914 | try: |
| 1915 | return obj.getValidators() |
| 1916 | except: |
| 1917 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1918 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 1919 | model = ControllerSlice |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1920 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1921 | |
| 1922 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1923 | |
| 1924 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1925 | class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1926 | id = IdField() |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1927 | |
| 1928 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1929 | validators = serializers.SerializerMethodField("getValidators") |
| 1930 | def getHumanReadableName(self, obj):
|
| 1931 | return str(obj) |
| 1932 | def getValidators(self, obj): |
| 1933 | try: |
| 1934 | return obj.getValidators() |
| 1935 | except: |
| 1936 | return None |
| 1937 | class Meta: |
| 1938 | model = ControllerDashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1939 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1940 | |
| 1941 | class ControllerDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1942 | id = IdField() |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1943 | |
| 1944 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1945 | validators = serializers.SerializerMethodField("getValidators") |
| 1946 | def getHumanReadableName(self, obj):
|
| 1947 | return str(obj)
|
| 1948 | def getValidators(self, obj):
|
| 1949 | try: |
| 1950 | return obj.getValidators() |
| 1951 | except: |
| 1952 | return None
|
| 1953 | class Meta:
|
| 1954 | model = ControllerDashboardView |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1955 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1956 | |
| 1957 | |
| 1958 | |
| 1959 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1960 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1961 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1962 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1963 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1964 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1965 | def getHumanReadableName(self, obj):
|
| 1966 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1967 | def getValidators(self, obj): |
| 1968 | try: |
| 1969 | return obj.getValidators() |
| 1970 | except: |
| 1971 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1972 | class Meta: |
| 1973 | model = Account |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1974 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1975 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1976 | class AccountIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1977 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1978 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1979 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1980 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1981 | def getHumanReadableName(self, obj):
|
| 1982 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1983 | def getValidators(self, obj):
|
| 1984 | try: |
| 1985 | return obj.getValidators() |
| 1986 | except: |
| 1987 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1988 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1989 | model = Account |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 1990 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1991 | |
| 1992 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1993 | |
| 1994 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1995 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1996 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1997 | |
| 1998 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1999 | validators = serializers.SerializerMethodField("getValidators") |
| 2000 | def getHumanReadableName(self, obj):
|
| 2001 | return str(obj) |
| 2002 | def getValidators(self, obj): |
| 2003 | try: |
| 2004 | return obj.getValidators() |
| 2005 | except: |
| 2006 | return None |
| 2007 | class Meta: |
| 2008 | model = ControllerRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2009 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2010 | |
| 2011 | class ControllerRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2012 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2013 | |
| 2014 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2015 | validators = serializers.SerializerMethodField("getValidators") |
| 2016 | def getHumanReadableName(self, obj):
|
| 2017 | return str(obj)
|
| 2018 | def getValidators(self, obj):
|
| 2019 | try: |
| 2020 | return obj.getValidators() |
| 2021 | except: |
| 2022 | return None
|
| 2023 | class Meta:
|
| 2024 | model = ControllerRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2025 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2026 | |
| 2027 | |
| 2028 | |
| 2029 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2030 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2031 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2032 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2033 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2034 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2035 | def getHumanReadableName(self, obj):
|
| 2036 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2037 | def getValidators(self, obj): |
| 2038 | try: |
| 2039 | return obj.getValidators() |
| 2040 | except: |
| 2041 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2042 | class Meta: |
| 2043 | model = NetworkParameterType |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2044 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2045 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2046 | class NetworkParameterTypeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2047 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2048 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2049 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2050 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2051 | def getHumanReadableName(self, obj):
|
| 2052 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2053 | def getValidators(self, obj):
|
| 2054 | try: |
| 2055 | return obj.getValidators() |
| 2056 | except: |
| 2057 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2058 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2059 | model = NetworkParameterType |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2060 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2061 | |
| 2062 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2063 | |
| 2064 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2065 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2066 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2067 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2068 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2069 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2070 | def getHumanReadableName(self, obj):
|
| 2071 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2072 | def getValidators(self, obj): |
| 2073 | try: |
| 2074 | return obj.getValidators() |
| 2075 | except: |
| 2076 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2077 | class Meta: |
| 2078 | model = SiteCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2079 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2080 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2081 | class SiteCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2082 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2083 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2084 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2085 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2086 | def getHumanReadableName(self, obj):
|
| 2087 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2088 | def getValidators(self, obj):
|
| 2089 | try: |
| 2090 | return obj.getValidators() |
| 2091 | except: |
| 2092 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2093 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2094 | model = SiteCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2095 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2096 | |
| 2097 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2098 | |
| 2099 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2100 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2101 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2102 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2103 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2104 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2105 | def getHumanReadableName(self, obj):
|
| 2106 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2107 | def getValidators(self, obj): |
| 2108 | try: |
| 2109 | return obj.getValidators() |
| 2110 | except: |
| 2111 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2112 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2113 | model = DeploymentPrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2114 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2115 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2116 | class DeploymentPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2117 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2118 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2119 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2120 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2121 | def getHumanReadableName(self, obj):
|
| 2122 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2123 | def getValidators(self, obj):
|
| 2124 | try: |
| 2125 | return obj.getValidators() |
| 2126 | except: |
| 2127 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2128 | class Meta:
|
| 2129 | model = DeploymentPrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2130 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2131 | |
| 2132 | |
| 2133 | |
| 2134 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2135 | class ControllerSlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2136 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2137 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2138 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2139 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2140 | def getHumanReadableName(self, obj):
|
| 2141 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2142 | def getValidators(self, obj): |
| 2143 | try: |
| 2144 | return obj.getValidators() |
| 2145 | except: |
| 2146 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2147 | class Meta: |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2148 | model = ControllerSlicePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2149 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2150 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2151 | class ControllerSlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2152 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2153 | |
| 2154 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2155 | validators = serializers.SerializerMethodField("getValidators") |
| 2156 | def getHumanReadableName(self, obj):
|
| 2157 | return str(obj)
|
| 2158 | def getValidators(self, obj):
|
| 2159 | try: |
| 2160 | return obj.getValidators() |
| 2161 | except: |
| 2162 | return None
|
| 2163 | class Meta:
|
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2164 | model = ControllerSlicePrivilege |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2165 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2166 | |
| 2167 | |
| 2168 | |
| 2169 | |
| 2170 | class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer): |
| 2171 | id = IdField() |
| 2172 | |
| 2173 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2174 | validators = serializers.SerializerMethodField("getValidators") |
| 2175 | def getHumanReadableName(self, obj):
|
| 2176 | return str(obj) |
| 2177 | def getValidators(self, obj): |
| 2178 | try: |
| 2179 | return obj.getValidators() |
| 2180 | except: |
| 2181 | return None |
| 2182 | class Meta: |
| 2183 | model = SiteDeployment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2184 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2185 | |
| 2186 | class SiteDeploymentIdSerializer(XOSModelSerializer): |
| 2187 | id = IdField() |
| 2188 | |
| 2189 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2190 | validators = serializers.SerializerMethodField("getValidators") |
| 2191 | def getHumanReadableName(self, obj):
|
| 2192 | return str(obj)
|
| 2193 | def getValidators(self, obj):
|
| 2194 | try: |
| 2195 | return obj.getValidators() |
| 2196 | except: |
| 2197 | return None
|
| 2198 | class Meta:
|
| 2199 | model = SiteDeployment |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2200 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2201 | |
| 2202 | |
| 2203 | |
| 2204 | |
| 2205 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2206 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2207 | |
| 2208 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2209 | validators = serializers.SerializerMethodField("getValidators") |
| 2210 | def getHumanReadableName(self, obj):
|
| 2211 | return str(obj) |
| 2212 | def getValidators(self, obj): |
| 2213 | try: |
| 2214 | return obj.getValidators() |
| 2215 | except: |
| 2216 | return None |
| 2217 | class Meta: |
| 2218 | model = DeploymentRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2219 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2220 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2221 | class DeploymentRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2222 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2223 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2224 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2225 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2226 | def getHumanReadableName(self, obj):
|
| 2227 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2228 | def getValidators(self, obj):
|
| 2229 | try: |
| 2230 | return obj.getValidators() |
| 2231 | except: |
| 2232 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2233 | class Meta:
|
| 2234 | model = DeploymentRole |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2235 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2236 | |
| 2237 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2238 | |
| 2239 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2240 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2241 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2242 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2243 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2244 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2245 | def getHumanReadableName(self, obj):
|
| 2246 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2247 | def getValidators(self, obj): |
| 2248 | try: |
| 2249 | return obj.getValidators() |
| 2250 | except: |
| 2251 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2252 | class Meta: |
| 2253 | model = UserCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2254 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2255 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2256 | class UserCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2257 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2258 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2259 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2260 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2261 | def getHumanReadableName(self, obj):
|
| 2262 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2263 | def getValidators(self, obj):
|
| 2264 | try: |
| 2265 | return obj.getValidators() |
| 2266 | except: |
| 2267 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2268 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2269 | model = UserCredential |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2270 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2271 | |
| 2272 | |
| 2273 | |
| 2274 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2275 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2276 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2277 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2278 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2279 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2280 | def getHumanReadableName(self, obj):
|
| 2281 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2282 | def getValidators(self, obj): |
| 2283 | try: |
| 2284 | return obj.getValidators() |
| 2285 | except: |
| 2286 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2287 | class Meta: |
| 2288 | model = SliceTag |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2289 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2290 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2291 | class SliceTagIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2292 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2293 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2294 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2295 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2296 | def getHumanReadableName(self, obj):
|
| 2297 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2298 | def getValidators(self, obj):
|
| 2299 | try: |
| 2300 | return obj.getValidators() |
| 2301 | except: |
| 2302 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2303 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2304 | model = SliceTag |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2305 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2306 | |
| 2307 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2308 | |
| 2309 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2310 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2311 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2312 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2313 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2314 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2315 | def getHumanReadableName(self, obj):
|
| 2316 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2317 | def getValidators(self, obj): |
| 2318 | try: |
| 2319 | return obj.getValidators() |
| 2320 | except: |
| 2321 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2322 | class Meta: |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2323 | model = NetworkTemplate |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2324 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2325 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2326 | class NetworkTemplateIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2327 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2328 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2329 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2330 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2331 | def getHumanReadableName(self, obj):
|
| 2332 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2333 | def getValidators(self, obj):
|
| 2334 | try: |
| 2335 | return obj.getValidators() |
| 2336 | except: |
| 2337 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2338 | class Meta:
|
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2339 | model = NetworkTemplate |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2340 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2341 | |
| 2342 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2343 | |
| 2344 | |
| 2345 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2346 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2347 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2348 | |
| 2349 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2350 | |
| 2351 | |
| 2352 | |
| 2353 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2354 | |
| 2355 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2356 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2357 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2358 | def getHumanReadableName(self, obj):
|
| 2359 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2360 | def getValidators(self, obj): |
| 2361 | try: |
| 2362 | return obj.getValidators() |
| 2363 | except: |
| 2364 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2365 | class Meta: |
| 2366 | model = Router |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2367 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2368 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2369 | class RouterIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2370 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2371 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2372 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2373 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2374 | |
| 2375 | |
| 2376 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2377 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2378 | |
| 2379 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2380 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2381 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2382 | def getHumanReadableName(self, obj):
|
| 2383 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2384 | def getValidators(self, obj):
|
| 2385 | try: |
| 2386 | return obj.getValidators() |
| 2387 | except: |
| 2388 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2389 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2390 | model = Router |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2391 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2392 | |
| 2393 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2394 | |
| 2395 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2396 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2397 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2398 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2399 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2400 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2401 | def getHumanReadableName(self, obj):
|
| 2402 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2403 | def getValidators(self, obj): |
| 2404 | try: |
| 2405 | return obj.getValidators() |
| 2406 | except: |
| 2407 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2408 | class Meta: |
| 2409 | model = ServiceResource |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2410 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2411 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2412 | class ServiceResourceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2413 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2414 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2415 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2416 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2417 | def getHumanReadableName(self, obj):
|
| 2418 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2419 | def getValidators(self, obj):
|
| 2420 | try: |
| 2421 | return obj.getValidators() |
| 2422 | except: |
| 2423 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2424 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2425 | model = ServiceResource |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2426 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2427 | |
| 2428 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2429 | |
| 2430 | |
| 2431 | serializerLookUp = { |
| 2432 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2433 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2434 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2435 | ControllerImages: ControllerImagesSerializer, |
| 2436 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2437 | ControllerSitePrivilege: ControllerSitePrivilegeSerializer, |
| 2438 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2439 | Image: ImageSerializer, |
| 2440 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2441 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2442 | |
| 2443 | Site: SiteSerializer, |
| 2444 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2445 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2446 | |
| 2447 | Tag: TagSerializer, |
| 2448 | |
| 2449 | Invoice: InvoiceSerializer, |
| 2450 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2451 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2452 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2453 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2454 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2455 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2456 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2457 | Flavor: FlavorSerializer, |
| 2458 | |
| 2459 | ControllerSite: ControllerSiteSerializer, |
| 2460 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2461 | Project: ProjectSerializer, |
| 2462 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2463 | Slice: SliceSerializer, |
| 2464 | |
| 2465 | Network: NetworkSerializer, |
| 2466 | |
| 2467 | Service: ServiceSerializer, |
| 2468 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2469 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2470 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2471 | PlanetStack: PlanetStackSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2472 | |
| 2473 | Charge: ChargeSerializer, |
| 2474 | |
| 2475 | Role: RoleSerializer, |
| 2476 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2477 | UsableObject: UsableObjectSerializer, |
| 2478 | |
| 2479 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2480 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2481 | SliceCredential: SliceCredentialSerializer, |
| 2482 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2483 | Sliver: SliverSerializer, |
| 2484 | |
| 2485 | Node: NodeSerializer, |
| 2486 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2487 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2488 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2489 | ControllerNetwork: ControllerNetworkSerializer, |
| 2490 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2491 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2492 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2493 | ControllerUser: ControllerUserSerializer, |
| 2494 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2495 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2496 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2497 | Payment: PaymentSerializer, |
| 2498 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2499 | NetworkSlice: NetworkSliceSerializer, |
| 2500 | |
| 2501 | UserDashboardView: UserDashboardViewSerializer, |
| 2502 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2503 | Controller: ControllerSerializer, |
| 2504 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2505 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2506 | |
| 2507 | User: UserSerializer, |
| 2508 | |
| 2509 | Deployment: DeploymentSerializer, |
| 2510 | |
| 2511 | Reservation: ReservationSerializer, |
| 2512 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2513 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2514 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2515 | ControllerSlice: ControllerSliceSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2516 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2517 | ControllerDashboardView: ControllerDashboardViewSerializer, |
| 2518 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2519 | Account: AccountSerializer, |
| 2520 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2521 | ControllerRole: ControllerRoleSerializer, |
| 2522 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2523 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2524 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2525 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2526 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2527 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2528 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2529 | ControllerSlicePrivilege: ControllerSlicePrivilegeSerializer, |
| 2530 | |
| 2531 | SiteDeployment: SiteDeploymentSerializer, |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2532 | |
| 2533 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2534 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2535 | UserCredential: UserCredentialSerializer, |
| 2536 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2537 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2538 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2539 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2540 | |
| 2541 | Router: RouterSerializer, |
| 2542 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2543 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2544 | |
| 2545 | None: None, |
| 2546 | } |
| 2547 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2548 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2549 | |
| 2550 | # To handle fine-grained field permissions, we have to check can_update |
| 2551 | # the object has been updated but before it has been saved. |
| 2552 | |
| 2553 | def update(self, request, *args, **kwargs):
|
| 2554 | partial = kwargs.pop('partial', False)
|
| 2555 | self.object = self.get_object_or_none()
|
| 2556 |
|
| 2557 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2558 | files=request.FILES, partial=partial)
|
| 2559 |
|
| 2560 | if not serializer.is_valid():
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2561 | response = {"error": "validation",
|
| 2562 | "specific_error": "not serializer.is_valid()",
|
| 2563 | "reasons": serializer.errors}
|
| 2564 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2565 |
|
| 2566 | try:
|
| 2567 | self.pre_save(serializer.object)
|
| 2568 | except ValidationError as err:
|
| 2569 | # full_clean on model instance may be called in pre_save,
|
| 2570 | # so we have to handle eventual errors.
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2571 | response = {"error": "validation",
|
| 2572 | "specific_error": "ValidationError in pre_save",
|
| 2573 | "reasons": err.message_dict}
|
| 2574 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2575 |
|
| 2576 | if serializer.object is not None:
|
| 2577 | if not serializer.object.can_update(request.user):
|
| 2578 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2579 |
|
| 2580 | if self.object is None:
|
| 2581 | self.object = serializer.save(force_insert=True)
|
| 2582 | self.post_save(self.object, created=True)
|
| 2583 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2584 |
|
| 2585 | self.object = serializer.save(force_update=True)
|
| 2586 | self.post_save(self.object, created=False)
|
| 2587 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2588 | |
| 2589 | def destroy(self, request, *args, **kwargs): |
| 2590 | obj = self.get_object() |
| 2591 | if obj.can_update(request.user): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2592 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2593 | else: |
| 2594 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2595 | |
| 2596 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2597 | # Based on core/views/*.py |
| 2598 | |
| 2599 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2600 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 2601 | queryset = ServiceAttribute.objects.select_related().all() |
| 2602 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2603 | id_serializer_class = ServiceAttributeIdSerializer |
| 2604 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2605 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2606 | |
| 2607 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2608 | no_hyperlinks=False |
| 2609 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2610 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2611 | if (no_hyperlinks): |
| 2612 | return self.id_serializer_class |
| 2613 | else: |
| 2614 | return self.serializer_class |
| 2615 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2616 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2617 | if (not self.request.user.is_authenticated()): |
| 2618 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2619 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2620 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2621 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2622 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2623 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2624 | response = {"error": "validation", |
| 2625 | "specific_error": "not serializer.is_valid()",
|
| 2626 | "reasons": serializer.errors}
|
| 2627 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2628 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2629 | obj.caller = request.user |
| 2630 | if obj.can_update(request.user): |
| 2631 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2632 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2633 | raise Exception("failed obj.can_update") |
| 2634 | |
| 2635 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2636 | if (ret.status_code%100 != 200): |
| 2637 | raise Exception(ret.data) |
| 2638 | |
| 2639 | return ret |
| 2640 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2641 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2642 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2643 | queryset = ServiceAttribute.objects.select_related().all() |
| 2644 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2645 | id_serializer_class = ServiceAttributeIdSerializer |
| 2646 | |
| 2647 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2648 | no_hyperlinks=False |
| 2649 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2650 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2651 | if (no_hyperlinks): |
| 2652 | return self.id_serializer_class |
| 2653 | else: |
| 2654 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2655 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2656 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2657 | if (not self.request.user.is_authenticated()): |
| 2658 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2659 | return ServiceAttribute.select_by_user(self.request.user) |
| 2660 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2661 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2662 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2663 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2664 | |
| 2665 | |
| 2666 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2667 | class ControllerImagesList(generics.ListCreateAPIView): |
| 2668 | queryset = ControllerImages.objects.select_related().all() |
| 2669 | serializer_class = ControllerImagesSerializer |
| 2670 | id_serializer_class = ControllerImagesIdSerializer |
| 2671 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2672 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2673 | |
| 2674 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2675 | no_hyperlinks=False |
| 2676 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2677 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2678 | if (no_hyperlinks): |
| 2679 | return self.id_serializer_class |
| 2680 | else: |
| 2681 | return self.serializer_class |
| 2682 | |
| 2683 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2684 | if (not self.request.user.is_authenticated()): |
| 2685 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2686 | return ControllerImages.select_by_user(self.request.user) |
| 2687 | |
| 2688 | def create(self, request, *args, **kwargs): |
| 2689 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2690 | if not (serializer.is_valid()): |
| 2691 | response = {"error": "validation", |
| 2692 | "specific_error": "not serializer.is_valid()",
|
| 2693 | "reasons": serializer.errors}
|
| 2694 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2695 | obj = serializer.object |
| 2696 | obj.caller = request.user |
| 2697 | if obj.can_update(request.user): |
| 2698 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2699 | else: |
| 2700 | raise Exception("failed obj.can_update") |
| 2701 | |
| 2702 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2703 | if (ret.status_code%100 != 200): |
| 2704 | raise Exception(ret.data) |
| 2705 | |
| 2706 | return ret |
| 2707 | |
| 2708 | |
| 2709 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2710 | queryset = ControllerImages.objects.select_related().all() |
| 2711 | serializer_class = ControllerImagesSerializer |
| 2712 | id_serializer_class = ControllerImagesIdSerializer |
| 2713 | |
| 2714 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2715 | no_hyperlinks=False |
| 2716 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2717 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2718 | if (no_hyperlinks): |
| 2719 | return self.id_serializer_class |
| 2720 | else: |
| 2721 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2722 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2723 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2724 | if (not self.request.user.is_authenticated()): |
| 2725 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2726 | return ControllerImages.select_by_user(self.request.user) |
| 2727 | |
| 2728 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2729 | |
| 2730 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2731 | |
| 2732 | |
| 2733 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2734 | class ControllerSitePrivilegeList(generics.ListCreateAPIView): |
| 2735 | queryset = ControllerSitePrivilege.objects.select_related().all() |
| 2736 | serializer_class = ControllerSitePrivilegeSerializer |
| 2737 | id_serializer_class = ControllerSitePrivilegeIdSerializer |
| 2738 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2739 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2740 | |
| 2741 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2742 | no_hyperlinks=False |
| 2743 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2744 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2745 | if (no_hyperlinks): |
| 2746 | return self.id_serializer_class |
| 2747 | else: |
| 2748 | return self.serializer_class |
| 2749 | |
| 2750 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2751 | if (not self.request.user.is_authenticated()): |
| 2752 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2753 | return ControllerSitePrivilege.select_by_user(self.request.user) |
| 2754 | |
| 2755 | def create(self, request, *args, **kwargs): |
| 2756 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2757 | if not (serializer.is_valid()): |
| 2758 | response = {"error": "validation", |
| 2759 | "specific_error": "not serializer.is_valid()",
|
| 2760 | "reasons": serializer.errors}
|
| 2761 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2762 | obj = serializer.object |
| 2763 | obj.caller = request.user |
| 2764 | if obj.can_update(request.user): |
| 2765 | return super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs) |
| 2766 | else: |
| 2767 | raise Exception("failed obj.can_update") |
| 2768 | |
| 2769 | ret = super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs) |
| 2770 | if (ret.status_code%100 != 200): |
| 2771 | raise Exception(ret.data) |
| 2772 | |
| 2773 | return ret |
| 2774 | |
| 2775 | |
| 2776 | class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2777 | queryset = ControllerSitePrivilege.objects.select_related().all() |
| 2778 | serializer_class = ControllerSitePrivilegeSerializer |
| 2779 | id_serializer_class = ControllerSitePrivilegeIdSerializer |
| 2780 | |
| 2781 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2782 | no_hyperlinks=False |
| 2783 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2784 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2785 | if (no_hyperlinks): |
| 2786 | return self.id_serializer_class |
| 2787 | else: |
| 2788 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2789 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2790 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2791 | if (not self.request.user.is_authenticated()): |
| 2792 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 2793 | return ControllerSitePrivilege.select_by_user(self.request.user) |
| 2794 | |
| 2795 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2796 | |
| 2797 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2798 | |
| 2799 | |
| 2800 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2801 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2802 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2803 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2804 | id_serializer_class = ImageIdSerializer |
| 2805 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2806 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2807 | |
| 2808 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2809 | no_hyperlinks=False |
| 2810 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2811 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2812 | if (no_hyperlinks): |
| 2813 | return self.id_serializer_class |
| 2814 | else: |
| 2815 | return self.serializer_class |
| 2816 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2817 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2818 | if (not self.request.user.is_authenticated()): |
| 2819 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2820 | return Image.select_by_user(self.request.user) |
| 2821 | |
| 2822 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2823 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2824 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2825 | response = {"error": "validation", |
| 2826 | "specific_error": "not serializer.is_valid()",
|
| 2827 | "reasons": serializer.errors}
|
| 2828 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2829 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2830 | obj.caller = request.user |
| 2831 | if obj.can_update(request.user): |
| 2832 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2833 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2834 | raise Exception("failed obj.can_update") |
| 2835 | |
| 2836 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2837 | if (ret.status_code%100 != 200): |
| 2838 | raise Exception(ret.data) |
| 2839 | |
| 2840 | return ret |
| 2841 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2842 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2843 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2844 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2845 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2846 | id_serializer_class = ImageIdSerializer |
| 2847 | |
| 2848 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2849 | no_hyperlinks=False |
| 2850 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2851 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2852 | if (no_hyperlinks): |
| 2853 | return self.id_serializer_class |
| 2854 | else: |
| 2855 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2856 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2857 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2858 | if (not self.request.user.is_authenticated()): |
| 2859 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2860 | return Image.select_by_user(self.request.user) |
| 2861 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2862 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2863 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2864 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2865 | |
| 2866 | |
| 2867 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2868 | class NetworkParameterList(generics.ListCreateAPIView): |
| 2869 | queryset = NetworkParameter.objects.select_related().all() |
| 2870 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2871 | id_serializer_class = NetworkParameterIdSerializer |
| 2872 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2873 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2874 | |
| 2875 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2876 | no_hyperlinks=False |
| 2877 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2878 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2879 | if (no_hyperlinks): |
| 2880 | return self.id_serializer_class |
| 2881 | else: |
| 2882 | return self.serializer_class |
| 2883 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2884 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2885 | if (not self.request.user.is_authenticated()): |
| 2886 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2887 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2888 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2889 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2890 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2891 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2892 | response = {"error": "validation", |
| 2893 | "specific_error": "not serializer.is_valid()",
|
| 2894 | "reasons": serializer.errors}
|
| 2895 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2896 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2897 | obj.caller = request.user |
| 2898 | if obj.can_update(request.user): |
| 2899 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2900 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2901 | raise Exception("failed obj.can_update") |
| 2902 | |
| 2903 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2904 | if (ret.status_code%100 != 200): |
| 2905 | raise Exception(ret.data) |
| 2906 | |
| 2907 | return ret |
| 2908 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2909 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2910 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2911 | queryset = NetworkParameter.objects.select_related().all() |
| 2912 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2913 | id_serializer_class = NetworkParameterIdSerializer |
| 2914 | |
| 2915 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2916 | no_hyperlinks=False |
| 2917 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2918 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2919 | if (no_hyperlinks): |
| 2920 | return self.id_serializer_class |
| 2921 | else: |
| 2922 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2923 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2924 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2925 | if (not self.request.user.is_authenticated()): |
| 2926 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2927 | return NetworkParameter.select_by_user(self.request.user) |
| 2928 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2929 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2930 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2931 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2932 | |
| 2933 | |
| 2934 | |
| 2935 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2936 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2937 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2938 | id_serializer_class = SiteIdSerializer |
| 2939 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2940 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2941 | |
| 2942 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2943 | no_hyperlinks=False |
| 2944 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2945 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2946 | if (no_hyperlinks): |
| 2947 | return self.id_serializer_class |
| 2948 | else: |
| 2949 | return self.serializer_class |
| 2950 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2951 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2952 | if (not self.request.user.is_authenticated()): |
| 2953 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2954 | return Site.select_by_user(self.request.user) |
| 2955 | |
| 2956 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2957 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2958 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2959 | response = {"error": "validation", |
| 2960 | "specific_error": "not serializer.is_valid()",
|
| 2961 | "reasons": serializer.errors}
|
| 2962 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2963 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2964 | obj.caller = request.user |
| 2965 | if obj.can_update(request.user): |
| 2966 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2967 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2968 | raise Exception("failed obj.can_update") |
| 2969 | |
| 2970 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2971 | if (ret.status_code%100 != 200): |
| 2972 | raise Exception(ret.data) |
| 2973 | |
| 2974 | return ret |
| 2975 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2976 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2977 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2978 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2979 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2980 | id_serializer_class = SiteIdSerializer |
| 2981 | |
| 2982 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2983 | no_hyperlinks=False |
| 2984 | if hasattr(self.request,"QUERY_PARAMS"): |
| 2985 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2986 | if (no_hyperlinks): |
| 2987 | return self.id_serializer_class |
| 2988 | else: |
| 2989 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 2990 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2991 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 2992 | if (not self.request.user.is_authenticated()): |
| 2993 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2994 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2995 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2996 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2997 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2998 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2999 | |
| 3000 | |
| 3001 | |
| 3002 | class SliceRoleList(generics.ListCreateAPIView): |
| 3003 | queryset = SliceRole.objects.select_related().all() |
| 3004 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3005 | id_serializer_class = SliceRoleIdSerializer |
| 3006 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3007 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3008 | |
| 3009 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3010 | no_hyperlinks=False |
| 3011 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3012 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3013 | if (no_hyperlinks): |
| 3014 | return self.id_serializer_class |
| 3015 | else: |
| 3016 | return self.serializer_class |
| 3017 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3018 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3019 | if (not self.request.user.is_authenticated()): |
| 3020 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3021 | return SliceRole.select_by_user(self.request.user) |
| 3022 | |
| 3023 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3024 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3025 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3026 | response = {"error": "validation", |
| 3027 | "specific_error": "not serializer.is_valid()",
|
| 3028 | "reasons": serializer.errors}
|
| 3029 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3030 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3031 | obj.caller = request.user |
| 3032 | if obj.can_update(request.user): |
| 3033 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 3034 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3035 | raise Exception("failed obj.can_update") |
| 3036 | |
| 3037 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 3038 | if (ret.status_code%100 != 200): |
| 3039 | raise Exception(ret.data) |
| 3040 | |
| 3041 | return ret |
| 3042 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3043 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3044 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3045 | queryset = SliceRole.objects.select_related().all() |
| 3046 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3047 | id_serializer_class = SliceRoleIdSerializer |
| 3048 | |
| 3049 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3050 | no_hyperlinks=False |
| 3051 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3052 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3053 | if (no_hyperlinks): |
| 3054 | return self.id_serializer_class |
| 3055 | else: |
| 3056 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3057 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3058 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3059 | if (not self.request.user.is_authenticated()): |
| 3060 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3061 | return SliceRole.select_by_user(self.request.user) |
| 3062 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3063 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3064 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3065 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3066 | |
| 3067 | |
| 3068 | |
| 3069 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3070 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3071 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3072 | id_serializer_class = TagIdSerializer |
| 3073 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3074 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3075 | |
| 3076 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3077 | no_hyperlinks=False |
| 3078 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3079 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 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): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3086 | if (not self.request.user.is_authenticated()): |
| 3087 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3088 | return Tag.select_by_user(self.request.user) |
| 3089 | |
| 3090 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3091 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3092 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3093 | response = {"error": "validation", |
| 3094 | "specific_error": "not serializer.is_valid()",
|
| 3095 | "reasons": serializer.errors}
|
| 3096 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3097 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3098 | obj.caller = request.user |
| 3099 | if obj.can_update(request.user): |
| 3100 | return super(TagList, self).create(request, *args, **kwargs) |
| 3101 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3102 | raise Exception("failed obj.can_update") |
| 3103 | |
| 3104 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 3105 | if (ret.status_code%100 != 200): |
| 3106 | raise Exception(ret.data) |
| 3107 | |
| 3108 | return ret |
| 3109 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3110 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3111 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3112 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3113 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3114 | id_serializer_class = TagIdSerializer |
| 3115 | |
| 3116 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3117 | no_hyperlinks=False |
| 3118 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3119 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3120 | if (no_hyperlinks): |
| 3121 | return self.id_serializer_class |
| 3122 | else: |
| 3123 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3124 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3125 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3126 | if (not self.request.user.is_authenticated()): |
| 3127 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3128 | return Tag.select_by_user(self.request.user) |
| 3129 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3130 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3131 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3132 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3133 | |
| 3134 | |
| 3135 | |
| 3136 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3137 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3138 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3139 | id_serializer_class = InvoiceIdSerializer |
| 3140 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3141 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3142 | |
| 3143 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3144 | no_hyperlinks=False |
| 3145 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3146 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3147 | if (no_hyperlinks): |
| 3148 | return self.id_serializer_class |
| 3149 | else: |
| 3150 | return self.serializer_class |
| 3151 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3152 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3153 | if (not self.request.user.is_authenticated()): |
| 3154 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3155 | return Invoice.select_by_user(self.request.user) |
| 3156 | |
| 3157 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3158 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3159 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3160 | response = {"error": "validation", |
| 3161 | "specific_error": "not serializer.is_valid()",
|
| 3162 | "reasons": serializer.errors}
|
| 3163 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3164 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3165 | obj.caller = request.user |
| 3166 | if obj.can_update(request.user): |
| 3167 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 3168 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3169 | raise Exception("failed obj.can_update") |
| 3170 | |
| 3171 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 3172 | if (ret.status_code%100 != 200): |
| 3173 | raise Exception(ret.data) |
| 3174 | |
| 3175 | return ret |
| 3176 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3177 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3178 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3179 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3180 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3181 | id_serializer_class = InvoiceIdSerializer |
| 3182 | |
| 3183 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3184 | no_hyperlinks=False |
| 3185 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3186 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3187 | if (no_hyperlinks): |
| 3188 | return self.id_serializer_class |
| 3189 | else: |
| 3190 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3191 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3192 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3193 | if (not self.request.user.is_authenticated()): |
| 3194 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3195 | return Invoice.select_by_user(self.request.user) |
| 3196 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3197 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3198 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3199 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3200 | |
| 3201 | |
| 3202 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3203 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 3204 | queryset = SlicePrivilege.objects.select_related().all() |
| 3205 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3206 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3207 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3208 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3209 | |
| 3210 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3211 | no_hyperlinks=False |
| 3212 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3213 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3214 | if (no_hyperlinks): |
| 3215 | return self.id_serializer_class |
| 3216 | else: |
| 3217 | return self.serializer_class |
| 3218 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3219 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3220 | if (not self.request.user.is_authenticated()): |
| 3221 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3222 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3223 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3224 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3225 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3226 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3227 | response = {"error": "validation", |
| 3228 | "specific_error": "not serializer.is_valid()",
|
| 3229 | "reasons": serializer.errors}
|
| 3230 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3231 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3232 | obj.caller = request.user |
| 3233 | if obj.can_update(request.user): |
| 3234 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3235 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3236 | raise Exception("failed obj.can_update") |
| 3237 | |
| 3238 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3239 | if (ret.status_code%100 != 200): |
| 3240 | raise Exception(ret.data) |
| 3241 | |
| 3242 | return ret |
| 3243 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3244 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3245 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3246 | queryset = SlicePrivilege.objects.select_related().all() |
| 3247 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3248 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3249 | |
| 3250 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3251 | no_hyperlinks=False |
| 3252 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3253 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3254 | if (no_hyperlinks): |
| 3255 | return self.id_serializer_class |
| 3256 | else: |
| 3257 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3258 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3259 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3260 | if (not self.request.user.is_authenticated()): |
| 3261 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3262 | return SlicePrivilege.select_by_user(self.request.user) |
| 3263 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3264 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3265 | |
| 3266 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3267 | |
| 3268 | |
| 3269 | |
| 3270 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 3271 | queryset = PlanetStackRole.objects.select_related().all() |
| 3272 | serializer_class = PlanetStackRoleSerializer |
| 3273 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3274 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3275 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3276 | |
| 3277 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3278 | no_hyperlinks=False |
| 3279 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3280 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3281 | if (no_hyperlinks): |
| 3282 | return self.id_serializer_class |
| 3283 | else: |
| 3284 | return self.serializer_class |
| 3285 | |
| 3286 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3287 | if (not self.request.user.is_authenticated()): |
| 3288 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3289 | return PlanetStackRole.select_by_user(self.request.user) |
| 3290 | |
| 3291 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3292 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3293 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3294 | response = {"error": "validation", |
| 3295 | "specific_error": "not serializer.is_valid()",
|
| 3296 | "reasons": serializer.errors}
|
| 3297 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3298 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3299 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3300 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3301 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3302 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3303 | raise Exception("failed obj.can_update") |
| 3304 | |
| 3305 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 3306 | if (ret.status_code%100 != 200): |
| 3307 | raise Exception(ret.data) |
| 3308 | |
| 3309 | return ret |
| 3310 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3311 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3312 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3313 | queryset = PlanetStackRole.objects.select_related().all() |
| 3314 | serializer_class = PlanetStackRoleSerializer |
| 3315 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3316 | |
| 3317 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3318 | no_hyperlinks=False |
| 3319 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3320 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3321 | if (no_hyperlinks): |
| 3322 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3323 | else: |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3324 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3325 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3326 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3327 | if (not self.request.user.is_authenticated()): |
| 3328 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3329 | return PlanetStackRole.select_by_user(self.request.user) |
| 3330 | |
| 3331 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3332 | |
| 3333 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3334 | |
| 3335 | |
| 3336 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3337 | class NetworkSliverList(generics.ListCreateAPIView): |
| 3338 | queryset = NetworkSliver.objects.select_related().all() |
| 3339 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3340 | id_serializer_class = NetworkSliverIdSerializer |
| 3341 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3342 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3343 | |
| 3344 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3345 | no_hyperlinks=False |
| 3346 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3347 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3348 | if (no_hyperlinks): |
| 3349 | return self.id_serializer_class |
| 3350 | else: |
| 3351 | return self.serializer_class |
| 3352 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3353 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3354 | if (not self.request.user.is_authenticated()): |
| 3355 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3356 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3357 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3358 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3359 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3360 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3361 | response = {"error": "validation", |
| 3362 | "specific_error": "not serializer.is_valid()",
|
| 3363 | "reasons": serializer.errors}
|
| 3364 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3365 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3366 | obj.caller = request.user |
| 3367 | if obj.can_update(request.user): |
| 3368 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3369 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3370 | raise Exception("failed obj.can_update") |
| 3371 | |
| 3372 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3373 | if (ret.status_code%100 != 200): |
| 3374 | raise Exception(ret.data) |
| 3375 | |
| 3376 | return ret |
| 3377 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3378 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3379 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3380 | queryset = NetworkSliver.objects.select_related().all() |
| 3381 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3382 | id_serializer_class = NetworkSliverIdSerializer |
| 3383 | |
| 3384 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3385 | no_hyperlinks=False |
| 3386 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3387 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3388 | if (no_hyperlinks): |
| 3389 | return self.id_serializer_class |
| 3390 | else: |
| 3391 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3392 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3393 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3394 | if (not self.request.user.is_authenticated()): |
| 3395 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3396 | return NetworkSliver.select_by_user(self.request.user) |
| 3397 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3398 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3399 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3400 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3401 | |
| 3402 | |
| 3403 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3404 | class FlavorList(generics.ListCreateAPIView): |
| 3405 | queryset = Flavor.objects.select_related().all() |
| 3406 | serializer_class = FlavorSerializer |
| 3407 | id_serializer_class = FlavorIdSerializer |
| 3408 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3409 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3410 | |
| 3411 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3412 | no_hyperlinks=False |
| 3413 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3414 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3415 | if (no_hyperlinks): |
| 3416 | return self.id_serializer_class |
| 3417 | else: |
| 3418 | return self.serializer_class |
| 3419 | |
| 3420 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3421 | if (not self.request.user.is_authenticated()): |
| 3422 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3423 | return Flavor.select_by_user(self.request.user) |
| 3424 | |
| 3425 | def create(self, request, *args, **kwargs): |
| 3426 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3427 | if not (serializer.is_valid()): |
| 3428 | response = {"error": "validation", |
| 3429 | "specific_error": "not serializer.is_valid()",
|
| 3430 | "reasons": serializer.errors}
|
| 3431 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3432 | obj = serializer.object |
| 3433 | obj.caller = request.user |
| 3434 | if obj.can_update(request.user): |
| 3435 | return super(FlavorList, self).create(request, *args, **kwargs) |
| 3436 | else: |
| 3437 | raise Exception("failed obj.can_update") |
| 3438 | |
| 3439 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 3440 | if (ret.status_code%100 != 200): |
| 3441 | raise Exception(ret.data) |
| 3442 | |
| 3443 | return ret |
| 3444 | |
| 3445 | |
| 3446 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3447 | queryset = Flavor.objects.select_related().all() |
| 3448 | serializer_class = FlavorSerializer |
| 3449 | id_serializer_class = FlavorIdSerializer |
| 3450 | |
| 3451 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3452 | no_hyperlinks=False |
| 3453 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3454 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3455 | if (no_hyperlinks): |
| 3456 | return self.id_serializer_class |
| 3457 | else: |
| 3458 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3459 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3460 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3461 | if (not self.request.user.is_authenticated()): |
| 3462 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3463 | return Flavor.select_by_user(self.request.user) |
| 3464 | |
| 3465 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3466 | |
| 3467 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3468 | |
| 3469 | |
| 3470 | |
| 3471 | class ControllerSiteList(generics.ListCreateAPIView): |
| 3472 | queryset = ControllerSite.objects.select_related().all() |
| 3473 | serializer_class = ControllerSiteSerializer |
| 3474 | id_serializer_class = ControllerSiteIdSerializer |
| 3475 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3476 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3477 | |
| 3478 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3479 | no_hyperlinks=False |
| 3480 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3481 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3482 | if (no_hyperlinks): |
| 3483 | return self.id_serializer_class |
| 3484 | else: |
| 3485 | return self.serializer_class |
| 3486 | |
| 3487 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3488 | if (not self.request.user.is_authenticated()): |
| 3489 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3490 | return ControllerSite.select_by_user(self.request.user) |
| 3491 | |
| 3492 | def create(self, request, *args, **kwargs): |
| 3493 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3494 | if not (serializer.is_valid()): |
| 3495 | response = {"error": "validation", |
| 3496 | "specific_error": "not serializer.is_valid()",
|
| 3497 | "reasons": serializer.errors}
|
| 3498 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3499 | obj = serializer.object |
| 3500 | obj.caller = request.user |
| 3501 | if obj.can_update(request.user): |
| 3502 | return super(ControllerSiteList, self).create(request, *args, **kwargs) |
| 3503 | else: |
| 3504 | raise Exception("failed obj.can_update") |
| 3505 | |
| 3506 | ret = super(ControllerSiteList, self).create(request, *args, **kwargs) |
| 3507 | if (ret.status_code%100 != 200): |
| 3508 | raise Exception(ret.data) |
| 3509 | |
| 3510 | return ret |
| 3511 | |
| 3512 | |
| 3513 | class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3514 | queryset = ControllerSite.objects.select_related().all() |
| 3515 | serializer_class = ControllerSiteSerializer |
| 3516 | id_serializer_class = ControllerSiteIdSerializer |
| 3517 | |
| 3518 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3519 | no_hyperlinks=False |
| 3520 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3521 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3522 | if (no_hyperlinks): |
| 3523 | return self.id_serializer_class |
| 3524 | else: |
| 3525 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3526 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3527 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3528 | if (not self.request.user.is_authenticated()): |
| 3529 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3530 | return ControllerSite.select_by_user(self.request.user) |
| 3531 | |
| 3532 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3533 | |
| 3534 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3535 | |
| 3536 | |
| 3537 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3538 | class ProjectList(generics.ListCreateAPIView): |
| 3539 | queryset = Project.objects.select_related().all() |
| 3540 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3541 | id_serializer_class = ProjectIdSerializer |
| 3542 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3543 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3544 | |
| 3545 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3546 | no_hyperlinks=False |
| 3547 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3548 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3549 | if (no_hyperlinks): |
| 3550 | return self.id_serializer_class |
| 3551 | else: |
| 3552 | return self.serializer_class |
| 3553 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3554 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3555 | if (not self.request.user.is_authenticated()): |
| 3556 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3557 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3558 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3559 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3560 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3561 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3562 | response = {"error": "validation", |
| 3563 | "specific_error": "not serializer.is_valid()",
|
| 3564 | "reasons": serializer.errors}
|
| 3565 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3566 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3567 | obj.caller = request.user |
| 3568 | if obj.can_update(request.user): |
| 3569 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 3570 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3571 | raise Exception("failed obj.can_update") |
| 3572 | |
| 3573 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 3574 | if (ret.status_code%100 != 200): |
| 3575 | raise Exception(ret.data) |
| 3576 | |
| 3577 | return ret |
| 3578 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3579 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3580 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3581 | queryset = Project.objects.select_related().all() |
| 3582 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3583 | id_serializer_class = ProjectIdSerializer |
| 3584 | |
| 3585 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3586 | no_hyperlinks=False |
| 3587 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3588 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3589 | if (no_hyperlinks): |
| 3590 | return self.id_serializer_class |
| 3591 | else: |
| 3592 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3593 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3594 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3595 | if (not self.request.user.is_authenticated()): |
| 3596 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3597 | return Project.select_by_user(self.request.user) |
| 3598 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3599 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3600 | |
| 3601 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3602 | |
| 3603 | |
| 3604 | |
| 3605 | class SliceList(generics.ListCreateAPIView): |
| 3606 | queryset = Slice.objects.select_related().all() |
| 3607 | serializer_class = SliceSerializer |
| 3608 | id_serializer_class = SliceIdSerializer |
| 3609 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3610 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3611 | |
| 3612 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3613 | no_hyperlinks=False |
| 3614 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3615 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3616 | if (no_hyperlinks): |
| 3617 | return self.id_serializer_class |
| 3618 | else: |
| 3619 | return self.serializer_class |
| 3620 | |
| 3621 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3622 | if (not self.request.user.is_authenticated()): |
| 3623 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3624 | return Slice.select_by_user(self.request.user) |
| 3625 | |
| 3626 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3627 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3628 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3629 | response = {"error": "validation", |
| 3630 | "specific_error": "not serializer.is_valid()",
|
| 3631 | "reasons": serializer.errors}
|
| 3632 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3633 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3634 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3635 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3636 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3637 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3638 | raise Exception("failed obj.can_update") |
| 3639 | |
| 3640 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3641 | if (ret.status_code%100 != 200): |
| 3642 | raise Exception(ret.data) |
| 3643 | |
| 3644 | return ret |
| 3645 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3646 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3647 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3648 | queryset = Slice.objects.select_related().all() |
| 3649 | serializer_class = SliceSerializer |
| 3650 | id_serializer_class = SliceIdSerializer |
| 3651 | |
| 3652 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3653 | no_hyperlinks=False |
| 3654 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3655 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3656 | if (no_hyperlinks): |
| 3657 | return self.id_serializer_class |
| 3658 | else: |
| 3659 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3660 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3661 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3662 | if (not self.request.user.is_authenticated()): |
| 3663 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3664 | return Slice.select_by_user(self.request.user) |
| 3665 | |
| 3666 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3667 | |
| 3668 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3669 | |
| 3670 | |
| 3671 | |
| 3672 | class NetworkList(generics.ListCreateAPIView): |
| 3673 | queryset = Network.objects.select_related().all() |
| 3674 | serializer_class = NetworkSerializer |
| 3675 | id_serializer_class = NetworkIdSerializer |
| 3676 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3677 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3678 | |
| 3679 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3680 | no_hyperlinks=False |
| 3681 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3682 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3683 | if (no_hyperlinks): |
| 3684 | return self.id_serializer_class |
| 3685 | else: |
| 3686 | return self.serializer_class |
| 3687 | |
| 3688 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3689 | if (not self.request.user.is_authenticated()): |
| 3690 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3691 | return Network.select_by_user(self.request.user) |
| 3692 | |
| 3693 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3694 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3695 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3696 | response = {"error": "validation", |
| 3697 | "specific_error": "not serializer.is_valid()",
|
| 3698 | "reasons": serializer.errors}
|
| 3699 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3700 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3701 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3702 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3703 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3704 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3705 | raise Exception("failed obj.can_update") |
| 3706 | |
| 3707 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3708 | if (ret.status_code%100 != 200): |
| 3709 | raise Exception(ret.data) |
| 3710 | |
| 3711 | return ret |
| 3712 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3713 | |
| 3714 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3715 | queryset = Network.objects.select_related().all() |
| 3716 | serializer_class = NetworkSerializer |
| 3717 | id_serializer_class = NetworkIdSerializer |
| 3718 | |
| 3719 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3720 | no_hyperlinks=False |
| 3721 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3722 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3723 | if (no_hyperlinks): |
| 3724 | return self.id_serializer_class |
| 3725 | else: |
| 3726 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3727 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3728 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3729 | if (not self.request.user.is_authenticated()): |
| 3730 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3731 | return Network.select_by_user(self.request.user) |
| 3732 | |
| 3733 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3734 | |
| 3735 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3736 | |
| 3737 | |
| 3738 | |
| 3739 | class ServiceList(generics.ListCreateAPIView): |
| 3740 | queryset = Service.objects.select_related().all() |
| 3741 | serializer_class = ServiceSerializer |
| 3742 | id_serializer_class = ServiceIdSerializer |
| 3743 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3744 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3745 | |
| 3746 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3747 | no_hyperlinks=False |
| 3748 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3749 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3750 | if (no_hyperlinks): |
| 3751 | return self.id_serializer_class |
| 3752 | else: |
| 3753 | return self.serializer_class |
| 3754 | |
| 3755 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3756 | if (not self.request.user.is_authenticated()): |
| 3757 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3758 | return Service.select_by_user(self.request.user) |
| 3759 | |
| 3760 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3761 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3762 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3763 | response = {"error": "validation", |
| 3764 | "specific_error": "not serializer.is_valid()",
|
| 3765 | "reasons": serializer.errors}
|
| 3766 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3767 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3768 | obj.caller = request.user |
| 3769 | if obj.can_update(request.user): |
| 3770 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3771 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3772 | raise Exception("failed obj.can_update") |
| 3773 | |
| 3774 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3775 | if (ret.status_code%100 != 200): |
| 3776 | raise Exception(ret.data) |
| 3777 | |
| 3778 | return ret |
| 3779 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3780 | |
| 3781 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3782 | queryset = Service.objects.select_related().all() |
| 3783 | serializer_class = ServiceSerializer |
| 3784 | id_serializer_class = ServiceIdSerializer |
| 3785 | |
| 3786 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3787 | no_hyperlinks=False |
| 3788 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3789 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3790 | if (no_hyperlinks): |
| 3791 | return self.id_serializer_class |
| 3792 | else: |
| 3793 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3794 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3795 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3796 | if (not self.request.user.is_authenticated()): |
| 3797 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3798 | return Service.select_by_user(self.request.user) |
| 3799 | |
| 3800 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3801 | |
| 3802 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3803 | |
| 3804 | |
| 3805 | |
| 3806 | class ServiceClassList(generics.ListCreateAPIView): |
| 3807 | queryset = ServiceClass.objects.select_related().all() |
| 3808 | serializer_class = ServiceClassSerializer |
| 3809 | id_serializer_class = ServiceClassIdSerializer |
| 3810 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3811 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3812 | |
| 3813 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3814 | no_hyperlinks=False |
| 3815 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3816 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3817 | if (no_hyperlinks): |
| 3818 | return self.id_serializer_class |
| 3819 | else: |
| 3820 | return self.serializer_class |
| 3821 | |
| 3822 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3823 | if (not self.request.user.is_authenticated()): |
| 3824 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3825 | return ServiceClass.select_by_user(self.request.user) |
| 3826 | |
| 3827 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3828 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3829 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3830 | response = {"error": "validation", |
| 3831 | "specific_error": "not serializer.is_valid()",
|
| 3832 | "reasons": serializer.errors}
|
| 3833 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3834 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3835 | obj.caller = request.user |
| 3836 | if obj.can_update(request.user): |
| 3837 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3838 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3839 | raise Exception("failed obj.can_update") |
| 3840 | |
| 3841 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3842 | if (ret.status_code%100 != 200): |
| 3843 | raise Exception(ret.data) |
| 3844 | |
| 3845 | return ret |
| 3846 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3847 | |
| 3848 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3849 | queryset = ServiceClass.objects.select_related().all() |
| 3850 | serializer_class = ServiceClassSerializer |
| 3851 | id_serializer_class = ServiceClassIdSerializer |
| 3852 | |
| 3853 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3854 | no_hyperlinks=False |
| 3855 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3856 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3857 | if (no_hyperlinks): |
| 3858 | return self.id_serializer_class |
| 3859 | else: |
| 3860 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3861 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3862 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3863 | if (not self.request.user.is_authenticated()): |
| 3864 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3865 | return ServiceClass.select_by_user(self.request.user) |
| 3866 | |
| 3867 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3868 | |
| 3869 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3870 | |
| 3871 | |
| 3872 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3873 | class PlanetStackList(generics.ListCreateAPIView): |
| 3874 | queryset = PlanetStack.objects.select_related().all() |
| 3875 | serializer_class = PlanetStackSerializer |
| 3876 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3877 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3878 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3879 | |
| 3880 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3881 | no_hyperlinks=False |
| 3882 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3883 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3884 | if (no_hyperlinks): |
| 3885 | return self.id_serializer_class |
| 3886 | else: |
| 3887 | return self.serializer_class |
| 3888 | |
| 3889 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3890 | if (not self.request.user.is_authenticated()): |
| 3891 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3892 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3893 | |
| 3894 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3895 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3896 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3897 | response = {"error": "validation", |
| 3898 | "specific_error": "not serializer.is_valid()",
|
| 3899 | "reasons": serializer.errors}
|
| 3900 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3901 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3902 | obj.caller = request.user |
| 3903 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3904 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3905 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3906 | raise Exception("failed obj.can_update") |
| 3907 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3908 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3909 | if (ret.status_code%100 != 200): |
| 3910 | raise Exception(ret.data) |
| 3911 | |
| 3912 | return ret |
| 3913 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3914 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3915 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3916 | queryset = PlanetStack.objects.select_related().all() |
| 3917 | serializer_class = PlanetStackSerializer |
| 3918 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3919 | |
| 3920 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3921 | no_hyperlinks=False |
| 3922 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3923 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3924 | if (no_hyperlinks): |
| 3925 | return self.id_serializer_class |
| 3926 | else: |
| 3927 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3928 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3929 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3930 | if (not self.request.user.is_authenticated()): |
| 3931 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 3932 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3933 | |
| 3934 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3935 | |
| 3936 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3937 | |
| 3938 | |
| 3939 | |
| 3940 | class ChargeList(generics.ListCreateAPIView): |
| 3941 | queryset = Charge.objects.select_related().all() |
| 3942 | serializer_class = ChargeSerializer |
| 3943 | id_serializer_class = ChargeIdSerializer |
| 3944 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3945 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3946 | |
| 3947 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3948 | no_hyperlinks=False |
| 3949 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3950 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3951 | if (no_hyperlinks): |
| 3952 | return self.id_serializer_class |
| 3953 | else: |
| 3954 | return self.serializer_class |
| 3955 | |
| 3956 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3957 | if (not self.request.user.is_authenticated()): |
| 3958 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3959 | return Charge.select_by_user(self.request.user) |
| 3960 | |
| 3961 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3962 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3963 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3964 | response = {"error": "validation", |
| 3965 | "specific_error": "not serializer.is_valid()",
|
| 3966 | "reasons": serializer.errors}
|
| 3967 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3968 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3969 | obj.caller = request.user |
| 3970 | if obj.can_update(request.user): |
| 3971 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3972 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3973 | raise Exception("failed obj.can_update") |
| 3974 | |
| 3975 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3976 | if (ret.status_code%100 != 200): |
| 3977 | raise Exception(ret.data) |
| 3978 | |
| 3979 | return ret |
| 3980 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3981 | |
| 3982 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3983 | queryset = Charge.objects.select_related().all() |
| 3984 | serializer_class = ChargeSerializer |
| 3985 | id_serializer_class = ChargeIdSerializer |
| 3986 | |
| 3987 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3988 | no_hyperlinks=False |
| 3989 | if hasattr(self.request,"QUERY_PARAMS"): |
| 3990 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3991 | if (no_hyperlinks): |
| 3992 | return self.id_serializer_class |
| 3993 | else: |
| 3994 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 3995 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3996 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 3997 | if (not self.request.user.is_authenticated()): |
| 3998 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3999 | return Charge.select_by_user(self.request.user) |
| 4000 | |
| 4001 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4002 | |
| 4003 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4004 | |
| 4005 | |
| 4006 | |
| 4007 | class RoleList(generics.ListCreateAPIView): |
| 4008 | queryset = Role.objects.select_related().all() |
| 4009 | serializer_class = RoleSerializer |
| 4010 | id_serializer_class = RoleIdSerializer |
| 4011 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4012 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4013 | |
| 4014 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4015 | no_hyperlinks=False |
| 4016 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4017 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4018 | if (no_hyperlinks): |
| 4019 | return self.id_serializer_class |
| 4020 | else: |
| 4021 | return self.serializer_class |
| 4022 | |
| 4023 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4024 | if (not self.request.user.is_authenticated()): |
| 4025 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4026 | return Role.select_by_user(self.request.user) |
| 4027 | |
| 4028 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4029 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4030 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4031 | response = {"error": "validation", |
| 4032 | "specific_error": "not serializer.is_valid()",
|
| 4033 | "reasons": serializer.errors}
|
| 4034 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4035 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4036 | obj.caller = request.user |
| 4037 | if obj.can_update(request.user): |
| 4038 | return super(RoleList, self).create(request, *args, **kwargs) |
| 4039 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4040 | raise Exception("failed obj.can_update") |
| 4041 | |
| 4042 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 4043 | if (ret.status_code%100 != 200): |
| 4044 | raise Exception(ret.data) |
| 4045 | |
| 4046 | return ret |
| 4047 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4048 | |
| 4049 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4050 | queryset = Role.objects.select_related().all() |
| 4051 | serializer_class = RoleSerializer |
| 4052 | id_serializer_class = RoleIdSerializer |
| 4053 | |
| 4054 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4055 | no_hyperlinks=False |
| 4056 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4057 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4058 | if (no_hyperlinks): |
| 4059 | return self.id_serializer_class |
| 4060 | else: |
| 4061 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4062 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4063 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4064 | if (not self.request.user.is_authenticated()): |
| 4065 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4066 | return Role.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 UsableObjectList(generics.ListCreateAPIView): |
| 4075 | queryset = UsableObject.objects.select_related().all() |
| 4076 | serializer_class = UsableObjectSerializer |
| 4077 | id_serializer_class = UsableObjectIdSerializer |
| 4078 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4079 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4080 | |
| 4081 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4082 | no_hyperlinks=False |
| 4083 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4084 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4085 | if (no_hyperlinks): |
| 4086 | return self.id_serializer_class |
| 4087 | else: |
| 4088 | return self.serializer_class |
| 4089 | |
| 4090 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4091 | if (not self.request.user.is_authenticated()): |
| 4092 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4093 | return UsableObject.select_by_user(self.request.user) |
| 4094 | |
| 4095 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4096 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4097 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4098 | response = {"error": "validation", |
| 4099 | "specific_error": "not serializer.is_valid()",
|
| 4100 | "reasons": serializer.errors}
|
| 4101 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4102 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4103 | obj.caller = request.user |
| 4104 | if obj.can_update(request.user): |
| 4105 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 4106 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4107 | raise Exception("failed obj.can_update") |
| 4108 | |
| 4109 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 4110 | if (ret.status_code%100 != 200): |
| 4111 | raise Exception(ret.data) |
| 4112 | |
| 4113 | return ret |
| 4114 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4115 | |
| 4116 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4117 | queryset = UsableObject.objects.select_related().all() |
| 4118 | serializer_class = UsableObjectSerializer |
| 4119 | id_serializer_class = UsableObjectIdSerializer |
| 4120 | |
| 4121 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4122 | no_hyperlinks=False |
| 4123 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4124 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4125 | if (no_hyperlinks): |
| 4126 | return self.id_serializer_class |
| 4127 | else: |
| 4128 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4129 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4130 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4131 | if (not self.request.user.is_authenticated()): |
| 4132 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4133 | return UsableObject.select_by_user(self.request.user) |
| 4134 | |
| 4135 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4136 | |
| 4137 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4138 | |
| 4139 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4140 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4141 | class SiteRoleList(generics.ListCreateAPIView): |
| 4142 | queryset = SiteRole.objects.select_related().all() |
| 4143 | serializer_class = SiteRoleSerializer |
| 4144 | id_serializer_class = SiteRoleIdSerializer |
| 4145 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4146 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4147 | |
| 4148 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4149 | no_hyperlinks=False |
| 4150 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4151 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4152 | if (no_hyperlinks): |
| 4153 | return self.id_serializer_class |
| 4154 | else: |
| 4155 | return self.serializer_class |
| 4156 | |
| 4157 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4158 | if (not self.request.user.is_authenticated()): |
| 4159 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4160 | return SiteRole.select_by_user(self.request.user) |
| 4161 | |
| 4162 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4163 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4164 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4165 | response = {"error": "validation", |
| 4166 | "specific_error": "not serializer.is_valid()",
|
| 4167 | "reasons": serializer.errors}
|
| 4168 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4169 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4170 | obj.caller = request.user |
| 4171 | if obj.can_update(request.user): |
| 4172 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 4173 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4174 | raise Exception("failed obj.can_update") |
| 4175 | |
| 4176 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 4177 | if (ret.status_code%100 != 200): |
| 4178 | raise Exception(ret.data) |
| 4179 | |
| 4180 | return ret |
| 4181 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4182 | |
| 4183 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4184 | queryset = SiteRole.objects.select_related().all() |
| 4185 | serializer_class = SiteRoleSerializer |
| 4186 | id_serializer_class = SiteRoleIdSerializer |
| 4187 | |
| 4188 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4189 | no_hyperlinks=False |
| 4190 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4191 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4192 | if (no_hyperlinks): |
| 4193 | return self.id_serializer_class |
| 4194 | else: |
| 4195 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4196 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4197 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4198 | if (not self.request.user.is_authenticated()): |
| 4199 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4200 | return SiteRole.select_by_user(self.request.user) |
| 4201 | |
| 4202 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4203 | |
| 4204 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4205 | |
| 4206 | |
| 4207 | |
| 4208 | class SliceCredentialList(generics.ListCreateAPIView): |
| 4209 | queryset = SliceCredential.objects.select_related().all() |
| 4210 | serializer_class = SliceCredentialSerializer |
| 4211 | id_serializer_class = SliceCredentialIdSerializer |
| 4212 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4213 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4214 | |
| 4215 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4216 | no_hyperlinks=False |
| 4217 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4218 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4219 | if (no_hyperlinks): |
| 4220 | return self.id_serializer_class |
| 4221 | else: |
| 4222 | return self.serializer_class |
| 4223 | |
| 4224 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4225 | if (not self.request.user.is_authenticated()): |
| 4226 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4227 | return SliceCredential.select_by_user(self.request.user) |
| 4228 | |
| 4229 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4230 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4231 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4232 | response = {"error": "validation", |
| 4233 | "specific_error": "not serializer.is_valid()",
|
| 4234 | "reasons": serializer.errors}
|
| 4235 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4236 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4237 | obj.caller = request.user |
| 4238 | if obj.can_update(request.user): |
| 4239 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 4240 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4241 | raise Exception("failed obj.can_update") |
| 4242 | |
| 4243 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 4244 | if (ret.status_code%100 != 200): |
| 4245 | raise Exception(ret.data) |
| 4246 | |
| 4247 | return ret |
| 4248 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4249 | |
| 4250 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4251 | queryset = SliceCredential.objects.select_related().all() |
| 4252 | serializer_class = SliceCredentialSerializer |
| 4253 | id_serializer_class = SliceCredentialIdSerializer |
| 4254 | |
| 4255 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4256 | no_hyperlinks=False |
| 4257 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4258 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4259 | if (no_hyperlinks): |
| 4260 | return self.id_serializer_class |
| 4261 | else: |
| 4262 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4263 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4264 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4265 | if (not self.request.user.is_authenticated()): |
| 4266 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4267 | return SliceCredential.select_by_user(self.request.user) |
| 4268 | |
| 4269 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4270 | |
| 4271 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4272 | |
| 4273 | |
| 4274 | |
| 4275 | class SliverList(generics.ListCreateAPIView): |
| 4276 | queryset = Sliver.objects.select_related().all() |
| 4277 | serializer_class = SliverSerializer |
| 4278 | id_serializer_class = SliverIdSerializer |
| 4279 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4280 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4281 | |
| 4282 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4283 | no_hyperlinks=False |
| 4284 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4285 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4286 | if (no_hyperlinks): |
| 4287 | return self.id_serializer_class |
| 4288 | else: |
| 4289 | return self.serializer_class |
| 4290 | |
| 4291 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4292 | if (not self.request.user.is_authenticated()): |
| 4293 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4294 | return Sliver.select_by_user(self.request.user) |
| 4295 | |
| 4296 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4297 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4298 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4299 | response = {"error": "validation", |
| 4300 | "specific_error": "not serializer.is_valid()",
|
| 4301 | "reasons": serializer.errors}
|
| 4302 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4303 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4304 | obj.caller = request.user |
| 4305 | if obj.can_update(request.user): |
| 4306 | return super(SliverList, self).create(request, *args, **kwargs) |
| 4307 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4308 | raise Exception("failed obj.can_update") |
| 4309 | |
| 4310 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 4311 | if (ret.status_code%100 != 200): |
| 4312 | raise Exception(ret.data) |
| 4313 | |
| 4314 | return ret |
| 4315 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4316 | |
| 4317 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4318 | queryset = Sliver.objects.select_related().all() |
| 4319 | serializer_class = SliverSerializer |
| 4320 | id_serializer_class = SliverIdSerializer |
| 4321 | |
| 4322 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4323 | no_hyperlinks=False |
| 4324 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4325 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4326 | if (no_hyperlinks): |
| 4327 | return self.id_serializer_class |
| 4328 | else: |
| 4329 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4330 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4331 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4332 | if (not self.request.user.is_authenticated()): |
| 4333 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4334 | return Sliver.select_by_user(self.request.user) |
| 4335 | |
| 4336 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4337 | |
| 4338 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4339 | |
| 4340 | |
| 4341 | |
| 4342 | class NodeList(generics.ListCreateAPIView): |
| 4343 | queryset = Node.objects.select_related().all() |
| 4344 | serializer_class = NodeSerializer |
| 4345 | id_serializer_class = NodeIdSerializer |
| 4346 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4347 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4348 | |
| 4349 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4350 | no_hyperlinks=False |
| 4351 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4352 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4353 | if (no_hyperlinks): |
| 4354 | return self.id_serializer_class |
| 4355 | else: |
| 4356 | return self.serializer_class |
| 4357 | |
| 4358 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4359 | if (not self.request.user.is_authenticated()): |
| 4360 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4361 | return Node.select_by_user(self.request.user) |
| 4362 | |
| 4363 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4364 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4365 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4366 | response = {"error": "validation", |
| 4367 | "specific_error": "not serializer.is_valid()",
|
| 4368 | "reasons": serializer.errors}
|
| 4369 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4370 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4371 | obj.caller = request.user |
| 4372 | if obj.can_update(request.user): |
| 4373 | return super(NodeList, self).create(request, *args, **kwargs) |
| 4374 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4375 | raise Exception("failed obj.can_update") |
| 4376 | |
| 4377 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 4378 | if (ret.status_code%100 != 200): |
| 4379 | raise Exception(ret.data) |
| 4380 | |
| 4381 | return ret |
| 4382 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4383 | |
| 4384 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4385 | queryset = Node.objects.select_related().all() |
| 4386 | serializer_class = NodeSerializer |
| 4387 | id_serializer_class = NodeIdSerializer |
| 4388 | |
| 4389 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4390 | no_hyperlinks=False |
| 4391 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4392 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4393 | if (no_hyperlinks): |
| 4394 | return self.id_serializer_class |
| 4395 | else: |
| 4396 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4397 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4398 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4399 | if (not self.request.user.is_authenticated()): |
| 4400 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4401 | return Node.select_by_user(self.request.user) |
| 4402 | |
| 4403 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4404 | |
| 4405 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4406 | |
| 4407 | |
| 4408 | |
| 4409 | class DashboardViewList(generics.ListCreateAPIView): |
| 4410 | queryset = DashboardView.objects.select_related().all() |
| 4411 | serializer_class = DashboardViewSerializer |
| 4412 | id_serializer_class = DashboardViewIdSerializer |
| 4413 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4414 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4415 | |
| 4416 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4417 | no_hyperlinks=False |
| 4418 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4419 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4420 | if (no_hyperlinks): |
| 4421 | return self.id_serializer_class |
| 4422 | else: |
| 4423 | return self.serializer_class |
| 4424 | |
| 4425 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4426 | if (not self.request.user.is_authenticated()): |
| 4427 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4428 | return DashboardView.select_by_user(self.request.user) |
| 4429 | |
| 4430 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4431 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4432 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4433 | response = {"error": "validation", |
| 4434 | "specific_error": "not serializer.is_valid()",
|
| 4435 | "reasons": serializer.errors}
|
| 4436 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4437 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4438 | obj.caller = request.user |
| 4439 | if obj.can_update(request.user): |
| 4440 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4441 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4442 | raise Exception("failed obj.can_update") |
| 4443 | |
| 4444 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4445 | if (ret.status_code%100 != 200): |
| 4446 | raise Exception(ret.data) |
| 4447 | |
| 4448 | return ret |
| 4449 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4450 | |
| 4451 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4452 | queryset = DashboardView.objects.select_related().all() |
| 4453 | serializer_class = DashboardViewSerializer |
| 4454 | id_serializer_class = DashboardViewIdSerializer |
| 4455 | |
| 4456 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4457 | no_hyperlinks=False |
| 4458 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4459 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4460 | if (no_hyperlinks): |
| 4461 | return self.id_serializer_class |
| 4462 | else: |
| 4463 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4464 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4465 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4466 | if (not self.request.user.is_authenticated()): |
| 4467 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4468 | return DashboardView.select_by_user(self.request.user) |
| 4469 | |
| 4470 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4471 | |
| 4472 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4473 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4474 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4475 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4476 | class ControllerNetworkList(generics.ListCreateAPIView): |
| 4477 | queryset = ControllerNetwork.objects.select_related().all() |
| 4478 | serializer_class = ControllerNetworkSerializer |
| 4479 | id_serializer_class = ControllerNetworkIdSerializer |
| 4480 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4481 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4482 | |
| 4483 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4484 | no_hyperlinks=False |
| 4485 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4486 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4487 | if (no_hyperlinks): |
| 4488 | return self.id_serializer_class |
| 4489 | else: |
| 4490 | return self.serializer_class |
| 4491 | |
| 4492 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4493 | if (not self.request.user.is_authenticated()): |
| 4494 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4495 | return ControllerNetwork.select_by_user(self.request.user) |
| 4496 | |
| 4497 | def create(self, request, *args, **kwargs): |
| 4498 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4499 | if not (serializer.is_valid()): |
| 4500 | response = {"error": "validation", |
| 4501 | "specific_error": "not serializer.is_valid()",
|
| 4502 | "reasons": serializer.errors}
|
| 4503 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4504 | obj = serializer.object |
| 4505 | obj.caller = request.user |
| 4506 | if obj.can_update(request.user): |
| 4507 | return super(ControllerNetworkList, self).create(request, *args, **kwargs) |
| 4508 | else: |
| 4509 | raise Exception("failed obj.can_update") |
| 4510 | |
| 4511 | ret = super(ControllerNetworkList, self).create(request, *args, **kwargs) |
| 4512 | if (ret.status_code%100 != 200): |
| 4513 | raise Exception(ret.data) |
| 4514 | |
| 4515 | return ret |
| 4516 | |
| 4517 | |
| 4518 | class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4519 | queryset = ControllerNetwork.objects.select_related().all() |
| 4520 | serializer_class = ControllerNetworkSerializer |
| 4521 | id_serializer_class = ControllerNetworkIdSerializer |
| 4522 | |
| 4523 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4524 | no_hyperlinks=False |
| 4525 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4526 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4527 | if (no_hyperlinks): |
| 4528 | return self.id_serializer_class |
| 4529 | else: |
| 4530 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4531 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4532 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4533 | if (not self.request.user.is_authenticated()): |
| 4534 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4535 | return ControllerNetwork.select_by_user(self.request.user) |
| 4536 | |
| 4537 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4538 | |
| 4539 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4540 | |
| 4541 | |
| 4542 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4543 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 4544 | queryset = ImageDeployments.objects.select_related().all() |
| 4545 | serializer_class = ImageDeploymentsSerializer |
| 4546 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4547 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4548 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4549 | |
| 4550 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4551 | no_hyperlinks=False |
| 4552 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4553 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4554 | if (no_hyperlinks): |
| 4555 | return self.id_serializer_class |
| 4556 | else: |
| 4557 | return self.serializer_class |
| 4558 | |
| 4559 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4560 | if (not self.request.user.is_authenticated()): |
| 4561 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4562 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4563 | |
| 4564 | def create(self, request, *args, **kwargs): |
| 4565 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4566 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4567 | response = {"error": "validation", |
| 4568 | "specific_error": "not serializer.is_valid()",
|
| 4569 | "reasons": serializer.errors}
|
| 4570 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4571 | obj = serializer.object |
| 4572 | obj.caller = request.user |
| 4573 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4574 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4575 | else: |
| 4576 | raise Exception("failed obj.can_update") |
| 4577 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4578 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4579 | if (ret.status_code%100 != 200): |
| 4580 | raise Exception(ret.data) |
| 4581 | |
| 4582 | return ret |
| 4583 | |
| 4584 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4585 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4586 | queryset = ImageDeployments.objects.select_related().all() |
| 4587 | serializer_class = ImageDeploymentsSerializer |
| 4588 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4589 | |
| 4590 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4591 | no_hyperlinks=False |
| 4592 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4593 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4594 | if (no_hyperlinks): |
| 4595 | return self.id_serializer_class |
| 4596 | else: |
| 4597 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4598 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4599 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4600 | if (not self.request.user.is_authenticated()): |
| 4601 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4602 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4603 | |
| 4604 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4605 | |
| 4606 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4607 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4608 | |
| 4609 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4610 | class ControllerUserList(generics.ListCreateAPIView): |
| 4611 | queryset = ControllerUser.objects.select_related().all() |
| 4612 | serializer_class = ControllerUserSerializer |
| 4613 | id_serializer_class = ControllerUserIdSerializer |
| 4614 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4615 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4616 | |
| 4617 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4618 | no_hyperlinks=False |
| 4619 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4620 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4621 | if (no_hyperlinks): |
| 4622 | return self.id_serializer_class |
| 4623 | else: |
| 4624 | return self.serializer_class |
| 4625 | |
| 4626 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4627 | if (not self.request.user.is_authenticated()): |
| 4628 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4629 | return ControllerUser.select_by_user(self.request.user) |
| 4630 | |
| 4631 | def create(self, request, *args, **kwargs): |
| 4632 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4633 | if not (serializer.is_valid()): |
| 4634 | response = {"error": "validation", |
| 4635 | "specific_error": "not serializer.is_valid()",
|
| 4636 | "reasons": serializer.errors}
|
| 4637 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4638 | obj = serializer.object |
| 4639 | obj.caller = request.user |
| 4640 | if obj.can_update(request.user): |
| 4641 | return super(ControllerUserList, self).create(request, *args, **kwargs) |
| 4642 | else: |
| 4643 | raise Exception("failed obj.can_update") |
| 4644 | |
| 4645 | ret = super(ControllerUserList, self).create(request, *args, **kwargs) |
| 4646 | if (ret.status_code%100 != 200): |
| 4647 | raise Exception(ret.data) |
| 4648 | |
| 4649 | return ret |
| 4650 | |
| 4651 | |
| 4652 | class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4653 | queryset = ControllerUser.objects.select_related().all() |
| 4654 | serializer_class = ControllerUserSerializer |
| 4655 | id_serializer_class = ControllerUserIdSerializer |
| 4656 | |
| 4657 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4658 | no_hyperlinks=False |
| 4659 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4660 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4661 | if (no_hyperlinks): |
| 4662 | return self.id_serializer_class |
| 4663 | else: |
| 4664 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4665 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4666 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4667 | if (not self.request.user.is_authenticated()): |
| 4668 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 4669 | return ControllerUser.select_by_user(self.request.user) |
| 4670 | |
| 4671 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4672 | |
| 4673 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4674 | |
| 4675 | |
| 4676 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4677 | class ReservedResourceList(generics.ListCreateAPIView): |
| 4678 | queryset = ReservedResource.objects.select_related().all() |
| 4679 | serializer_class = ReservedResourceSerializer |
| 4680 | id_serializer_class = ReservedResourceIdSerializer |
| 4681 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4682 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4683 | |
| 4684 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4685 | no_hyperlinks=False |
| 4686 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4687 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4688 | if (no_hyperlinks): |
| 4689 | return self.id_serializer_class |
| 4690 | else: |
| 4691 | return self.serializer_class |
| 4692 | |
| 4693 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4694 | if (not self.request.user.is_authenticated()): |
| 4695 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4696 | return ReservedResource.select_by_user(self.request.user) |
| 4697 | |
| 4698 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4699 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4700 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4701 | response = {"error": "validation", |
| 4702 | "specific_error": "not serializer.is_valid()",
|
| 4703 | "reasons": serializer.errors}
|
| 4704 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4705 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4706 | obj.caller = request.user |
| 4707 | if obj.can_update(request.user): |
| 4708 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4709 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4710 | raise Exception("failed obj.can_update") |
| 4711 | |
| 4712 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4713 | if (ret.status_code%100 != 200): |
| 4714 | raise Exception(ret.data) |
| 4715 | |
| 4716 | return ret |
| 4717 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4718 | |
| 4719 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4720 | queryset = ReservedResource.objects.select_related().all() |
| 4721 | serializer_class = ReservedResourceSerializer |
| 4722 | id_serializer_class = ReservedResourceIdSerializer |
| 4723 | |
| 4724 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4725 | no_hyperlinks=False |
| 4726 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4727 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4728 | if (no_hyperlinks): |
| 4729 | return self.id_serializer_class |
| 4730 | else: |
| 4731 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4732 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4733 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4734 | if (not self.request.user.is_authenticated()): |
| 4735 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4736 | return ReservedResource.select_by_user(self.request.user) |
| 4737 | |
| 4738 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4739 | |
| 4740 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4741 | |
| 4742 | |
| 4743 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4744 | class PaymentList(generics.ListCreateAPIView): |
| 4745 | queryset = Payment.objects.select_related().all() |
| 4746 | serializer_class = PaymentSerializer |
| 4747 | id_serializer_class = PaymentIdSerializer |
| 4748 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4749 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4750 | |
| 4751 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4752 | no_hyperlinks=False |
| 4753 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4754 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4755 | if (no_hyperlinks): |
| 4756 | return self.id_serializer_class |
| 4757 | else: |
| 4758 | return self.serializer_class |
| 4759 | |
| 4760 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4761 | if (not self.request.user.is_authenticated()): |
| 4762 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4763 | return Payment.select_by_user(self.request.user) |
| 4764 | |
| 4765 | def create(self, request, *args, **kwargs): |
| 4766 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4767 | if not (serializer.is_valid()): |
| 4768 | response = {"error": "validation", |
| 4769 | "specific_error": "not serializer.is_valid()",
|
| 4770 | "reasons": serializer.errors}
|
| 4771 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4772 | obj = serializer.object |
| 4773 | obj.caller = request.user |
| 4774 | if obj.can_update(request.user): |
| 4775 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 4776 | else: |
| 4777 | raise Exception("failed obj.can_update") |
| 4778 | |
| 4779 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 4780 | if (ret.status_code%100 != 200): |
| 4781 | raise Exception(ret.data) |
| 4782 | |
| 4783 | return ret |
| 4784 | |
| 4785 | |
| 4786 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4787 | queryset = Payment.objects.select_related().all() |
| 4788 | serializer_class = PaymentSerializer |
| 4789 | id_serializer_class = PaymentIdSerializer |
| 4790 | |
| 4791 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4792 | no_hyperlinks=False |
| 4793 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4794 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4795 | if (no_hyperlinks): |
| 4796 | return self.id_serializer_class |
| 4797 | else: |
| 4798 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4799 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4800 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4801 | if (not self.request.user.is_authenticated()): |
| 4802 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4803 | return Payment.select_by_user(self.request.user) |
| 4804 | |
| 4805 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4806 | |
| 4807 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4808 | |
| 4809 | |
| 4810 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4811 | class NetworkSliceList(generics.ListCreateAPIView): |
| 4812 | queryset = NetworkSlice.objects.select_related().all() |
| 4813 | serializer_class = NetworkSliceSerializer |
| 4814 | id_serializer_class = NetworkSliceIdSerializer |
| 4815 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4816 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4817 | |
| 4818 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4819 | no_hyperlinks=False |
| 4820 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4821 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4822 | if (no_hyperlinks): |
| 4823 | return self.id_serializer_class |
| 4824 | else: |
| 4825 | return self.serializer_class |
| 4826 | |
| 4827 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4828 | if (not self.request.user.is_authenticated()): |
| 4829 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4830 | return NetworkSlice.select_by_user(self.request.user) |
| 4831 | |
| 4832 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4833 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4834 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4835 | response = {"error": "validation", |
| 4836 | "specific_error": "not serializer.is_valid()",
|
| 4837 | "reasons": serializer.errors}
|
| 4838 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4839 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4840 | obj.caller = request.user |
| 4841 | if obj.can_update(request.user): |
| 4842 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4843 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4844 | raise Exception("failed obj.can_update") |
| 4845 | |
| 4846 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4847 | if (ret.status_code%100 != 200): |
| 4848 | raise Exception(ret.data) |
| 4849 | |
| 4850 | return ret |
| 4851 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4852 | |
| 4853 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4854 | queryset = NetworkSlice.objects.select_related().all() |
| 4855 | serializer_class = NetworkSliceSerializer |
| 4856 | id_serializer_class = NetworkSliceIdSerializer |
| 4857 | |
| 4858 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4859 | no_hyperlinks=False |
| 4860 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4861 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4862 | if (no_hyperlinks): |
| 4863 | return self.id_serializer_class |
| 4864 | else: |
| 4865 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4866 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4867 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4868 | if (not self.request.user.is_authenticated()): |
| 4869 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4870 | return NetworkSlice.select_by_user(self.request.user) |
| 4871 | |
| 4872 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4873 | |
| 4874 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4875 | |
| 4876 | |
| 4877 | |
| 4878 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 4879 | queryset = UserDashboardView.objects.select_related().all() |
| 4880 | serializer_class = UserDashboardViewSerializer |
| 4881 | id_serializer_class = UserDashboardViewIdSerializer |
| 4882 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4883 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4884 | |
| 4885 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4886 | no_hyperlinks=False |
| 4887 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4888 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4889 | if (no_hyperlinks): |
| 4890 | return self.id_serializer_class |
| 4891 | else: |
| 4892 | return self.serializer_class |
| 4893 | |
| 4894 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4895 | if (not self.request.user.is_authenticated()): |
| 4896 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4897 | return UserDashboardView.select_by_user(self.request.user) |
| 4898 | |
| 4899 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4900 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4901 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4902 | response = {"error": "validation", |
| 4903 | "specific_error": "not serializer.is_valid()",
|
| 4904 | "reasons": serializer.errors}
|
| 4905 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4906 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4907 | obj.caller = request.user |
| 4908 | if obj.can_update(request.user): |
| 4909 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4910 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4911 | raise Exception("failed obj.can_update") |
| 4912 | |
| 4913 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4914 | if (ret.status_code%100 != 200): |
| 4915 | raise Exception(ret.data) |
| 4916 | |
| 4917 | return ret |
| 4918 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4919 | |
| 4920 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4921 | queryset = UserDashboardView.objects.select_related().all() |
| 4922 | serializer_class = UserDashboardViewSerializer |
| 4923 | id_serializer_class = UserDashboardViewIdSerializer |
| 4924 | |
| 4925 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4926 | no_hyperlinks=False |
| 4927 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4928 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4929 | if (no_hyperlinks): |
| 4930 | return self.id_serializer_class |
| 4931 | else: |
| 4932 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4933 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4934 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4935 | if (not self.request.user.is_authenticated()): |
| 4936 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4937 | return UserDashboardView.select_by_user(self.request.user) |
| 4938 | |
| 4939 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4940 | |
| 4941 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4942 | |
| 4943 | |
| 4944 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4945 | class ControllerList(generics.ListCreateAPIView): |
| 4946 | queryset = Controller.objects.select_related().all() |
| 4947 | serializer_class = ControllerSerializer |
| 4948 | id_serializer_class = ControllerIdSerializer |
| 4949 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4950 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4951 | |
| 4952 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4953 | no_hyperlinks=False |
| 4954 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4955 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4956 | if (no_hyperlinks): |
| 4957 | return self.id_serializer_class |
| 4958 | else: |
| 4959 | return self.serializer_class |
| 4960 | |
| 4961 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 4962 | if (not self.request.user.is_authenticated()): |
| 4963 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4964 | return Controller.select_by_user(self.request.user) |
| 4965 | |
| 4966 | def create(self, request, *args, **kwargs): |
| 4967 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4968 | if not (serializer.is_valid()): |
| 4969 | response = {"error": "validation", |
| 4970 | "specific_error": "not serializer.is_valid()",
|
| 4971 | "reasons": serializer.errors}
|
| 4972 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4973 | obj = serializer.object |
| 4974 | obj.caller = request.user |
| 4975 | if obj.can_update(request.user): |
| 4976 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4977 | else: |
| 4978 | raise Exception("failed obj.can_update") |
| 4979 | |
| 4980 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 4981 | if (ret.status_code%100 != 200): |
| 4982 | raise Exception(ret.data) |
| 4983 | |
| 4984 | return ret |
| 4985 | |
| 4986 | |
| 4987 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4988 | queryset = Controller.objects.select_related().all() |
| 4989 | serializer_class = ControllerSerializer |
| 4990 | id_serializer_class = ControllerIdSerializer |
| 4991 | |
| 4992 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 4993 | no_hyperlinks=False |
| 4994 | if hasattr(self.request,"QUERY_PARAMS"): |
| 4995 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4996 | if (no_hyperlinks): |
| 4997 | return self.id_serializer_class |
| 4998 | else: |
| 4999 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5000 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5001 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5002 | if (not self.request.user.is_authenticated()): |
| 5003 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5004 | return Controller.select_by_user(self.request.user) |
| 5005 | |
| 5006 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5007 | |
| 5008 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5009 | |
| 5010 | |
| 5011 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5012 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 5013 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 5014 | serializer_class = PlanetStackPrivilegeSerializer |
| 5015 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 5016 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5017 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5018 | |
| 5019 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5020 | no_hyperlinks=False |
| 5021 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5022 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5023 | if (no_hyperlinks): |
| 5024 | return self.id_serializer_class |
| 5025 | else: |
| 5026 | return self.serializer_class |
| 5027 | |
| 5028 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5029 | if (not self.request.user.is_authenticated()): |
| 5030 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5031 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 5032 | |
| 5033 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5034 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5035 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5036 | response = {"error": "validation", |
| 5037 | "specific_error": "not serializer.is_valid()",
|
| 5038 | "reasons": serializer.errors}
|
| 5039 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5040 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5041 | obj.caller = request.user |
| 5042 | if obj.can_update(request.user): |
| 5043 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 5044 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5045 | raise Exception("failed obj.can_update") |
| 5046 | |
| 5047 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 5048 | if (ret.status_code%100 != 200): |
| 5049 | raise Exception(ret.data) |
| 5050 | |
| 5051 | return ret |
| 5052 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5053 | |
| 5054 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5055 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 5056 | serializer_class = PlanetStackPrivilegeSerializer |
| 5057 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 5058 | |
| 5059 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5060 | no_hyperlinks=False |
| 5061 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5062 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5063 | if (no_hyperlinks): |
| 5064 | return self.id_serializer_class |
| 5065 | else: |
| 5066 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5067 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5068 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5069 | if (not self.request.user.is_authenticated()): |
| 5070 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5071 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 5072 | |
| 5073 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5074 | |
| 5075 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5076 | |
| 5077 | |
| 5078 | |
| 5079 | class UserList(generics.ListCreateAPIView): |
| 5080 | queryset = User.objects.select_related().all() |
| 5081 | serializer_class = UserSerializer |
| 5082 | id_serializer_class = UserIdSerializer |
| 5083 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5084 | filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5085 | |
| 5086 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5087 | no_hyperlinks=False |
| 5088 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5089 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5090 | if (no_hyperlinks): |
| 5091 | return self.id_serializer_class |
| 5092 | else: |
| 5093 | return self.serializer_class |
| 5094 | |
| 5095 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5096 | if (not self.request.user.is_authenticated()): |
| 5097 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5098 | return User.select_by_user(self.request.user) |
| 5099 | |
| 5100 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5101 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5102 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5103 | response = {"error": "validation", |
| 5104 | "specific_error": "not serializer.is_valid()",
|
| 5105 | "reasons": serializer.errors}
|
| 5106 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5107 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5108 | obj.caller = request.user |
| 5109 | if obj.can_update(request.user): |
| 5110 | return super(UserList, self).create(request, *args, **kwargs) |
| 5111 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5112 | raise Exception("failed obj.can_update") |
| 5113 | |
| 5114 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 5115 | if (ret.status_code%100 != 200): |
| 5116 | raise Exception(ret.data) |
| 5117 | |
| 5118 | return ret |
| 5119 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5120 | |
| 5121 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5122 | queryset = User.objects.select_related().all() |
| 5123 | serializer_class = UserSerializer |
| 5124 | id_serializer_class = UserIdSerializer |
| 5125 | |
| 5126 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5127 | no_hyperlinks=False |
| 5128 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5129 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5130 | if (no_hyperlinks): |
| 5131 | return self.id_serializer_class |
| 5132 | else: |
| 5133 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5134 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5135 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5136 | if (not self.request.user.is_authenticated()): |
| 5137 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5138 | return User.select_by_user(self.request.user) |
| 5139 | |
| 5140 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5141 | |
| 5142 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5143 | |
| 5144 | |
| 5145 | |
| 5146 | class DeploymentList(generics.ListCreateAPIView): |
| 5147 | queryset = Deployment.objects.select_related().all() |
| 5148 | serializer_class = DeploymentSerializer |
| 5149 | id_serializer_class = DeploymentIdSerializer |
| 5150 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5151 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5152 | |
| 5153 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5154 | no_hyperlinks=False |
| 5155 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5156 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5157 | if (no_hyperlinks): |
| 5158 | return self.id_serializer_class |
| 5159 | else: |
| 5160 | return self.serializer_class |
| 5161 | |
| 5162 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5163 | if (not self.request.user.is_authenticated()): |
| 5164 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5165 | return Deployment.select_by_user(self.request.user) |
| 5166 | |
| 5167 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5168 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5169 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5170 | response = {"error": "validation", |
| 5171 | "specific_error": "not serializer.is_valid()",
|
| 5172 | "reasons": serializer.errors}
|
| 5173 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5174 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5175 | obj.caller = request.user |
| 5176 | if obj.can_update(request.user): |
| 5177 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 5178 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5179 | raise Exception("failed obj.can_update") |
| 5180 | |
| 5181 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 5182 | if (ret.status_code%100 != 200): |
| 5183 | raise Exception(ret.data) |
| 5184 | |
| 5185 | return ret |
| 5186 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5187 | |
| 5188 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5189 | queryset = Deployment.objects.select_related().all() |
| 5190 | serializer_class = DeploymentSerializer |
| 5191 | id_serializer_class = DeploymentIdSerializer |
| 5192 | |
| 5193 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5194 | no_hyperlinks=False |
| 5195 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5196 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5197 | if (no_hyperlinks): |
| 5198 | return self.id_serializer_class |
| 5199 | else: |
| 5200 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5201 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5202 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5203 | if (not self.request.user.is_authenticated()): |
| 5204 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5205 | return Deployment.select_by_user(self.request.user) |
| 5206 | |
| 5207 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5208 | |
| 5209 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5210 | |
| 5211 | |
| 5212 | |
| 5213 | class ReservationList(generics.ListCreateAPIView): |
| 5214 | queryset = Reservation.objects.select_related().all() |
| 5215 | serializer_class = ReservationSerializer |
| 5216 | id_serializer_class = ReservationIdSerializer |
| 5217 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5218 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5219 | |
| 5220 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5221 | no_hyperlinks=False |
| 5222 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5223 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5224 | if (no_hyperlinks): |
| 5225 | return self.id_serializer_class |
| 5226 | else: |
| 5227 | return self.serializer_class |
| 5228 | |
| 5229 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5230 | if (not self.request.user.is_authenticated()): |
| 5231 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5232 | return Reservation.select_by_user(self.request.user) |
| 5233 | |
| 5234 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5235 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5236 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5237 | response = {"error": "validation", |
| 5238 | "specific_error": "not serializer.is_valid()",
|
| 5239 | "reasons": serializer.errors}
|
| 5240 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5241 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5242 | obj.caller = request.user |
| 5243 | if obj.can_update(request.user): |
| 5244 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 5245 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5246 | raise Exception("failed obj.can_update") |
| 5247 | |
| 5248 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 5249 | if (ret.status_code%100 != 200): |
| 5250 | raise Exception(ret.data) |
| 5251 | |
| 5252 | return ret |
| 5253 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5254 | |
| 5255 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5256 | queryset = Reservation.objects.select_related().all() |
| 5257 | serializer_class = ReservationSerializer |
| 5258 | id_serializer_class = ReservationIdSerializer |
| 5259 | |
| 5260 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5261 | no_hyperlinks=False |
| 5262 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5263 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5264 | if (no_hyperlinks): |
| 5265 | return self.id_serializer_class |
| 5266 | else: |
| 5267 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5268 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5269 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5270 | if (not self.request.user.is_authenticated()): |
| 5271 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5272 | return Reservation.select_by_user(self.request.user) |
| 5273 | |
| 5274 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5275 | |
| 5276 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5277 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5278 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5279 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5280 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 5281 | queryset = SitePrivilege.objects.select_related().all() |
| 5282 | serializer_class = SitePrivilegeSerializer |
| 5283 | id_serializer_class = SitePrivilegeIdSerializer |
| 5284 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5285 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5286 | |
| 5287 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5288 | no_hyperlinks=False |
| 5289 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5290 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5291 | if (no_hyperlinks): |
| 5292 | return self.id_serializer_class |
| 5293 | else: |
| 5294 | return self.serializer_class |
| 5295 | |
| 5296 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5297 | if (not self.request.user.is_authenticated()): |
| 5298 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5299 | return SitePrivilege.select_by_user(self.request.user) |
| 5300 | |
| 5301 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5302 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5303 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5304 | response = {"error": "validation", |
| 5305 | "specific_error": "not serializer.is_valid()",
|
| 5306 | "reasons": serializer.errors}
|
| 5307 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5308 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5309 | obj.caller = request.user |
| 5310 | if obj.can_update(request.user): |
| 5311 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 5312 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5313 | raise Exception("failed obj.can_update") |
| 5314 | |
| 5315 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 5316 | if (ret.status_code%100 != 200): |
| 5317 | raise Exception(ret.data) |
| 5318 | |
| 5319 | return ret |
| 5320 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5321 | |
| 5322 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5323 | queryset = SitePrivilege.objects.select_related().all() |
| 5324 | serializer_class = SitePrivilegeSerializer |
| 5325 | id_serializer_class = SitePrivilegeIdSerializer |
| 5326 | |
| 5327 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5328 | no_hyperlinks=False |
| 5329 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5330 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5331 | if (no_hyperlinks): |
| 5332 | return self.id_serializer_class |
| 5333 | else: |
| 5334 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5335 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5336 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5337 | if (not self.request.user.is_authenticated()): |
| 5338 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5339 | return SitePrivilege.select_by_user(self.request.user) |
| 5340 | |
| 5341 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5342 | |
| 5343 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5344 | |
| 5345 | |
| 5346 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5347 | class ControllerSliceList(generics.ListCreateAPIView): |
| 5348 | queryset = ControllerSlice.objects.select_related().all() |
| 5349 | serializer_class = ControllerSliceSerializer |
| 5350 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5351 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5352 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5353 | |
| 5354 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5355 | no_hyperlinks=False |
| 5356 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5357 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5358 | if (no_hyperlinks): |
| 5359 | return self.id_serializer_class |
| 5360 | else: |
| 5361 | return self.serializer_class |
| 5362 | |
| 5363 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5364 | if (not self.request.user.is_authenticated()): |
| 5365 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5366 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5367 | |
| 5368 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5369 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5370 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5371 | response = {"error": "validation", |
| 5372 | "specific_error": "not serializer.is_valid()",
|
| 5373 | "reasons": serializer.errors}
|
| 5374 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5375 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5376 | obj.caller = request.user |
| 5377 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5378 | return super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5379 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5380 | raise Exception("failed obj.can_update") |
| 5381 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5382 | ret = super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5383 | if (ret.status_code%100 != 200): |
| 5384 | raise Exception(ret.data) |
| 5385 | |
| 5386 | return ret |
| 5387 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5388 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5389 | class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5390 | queryset = ControllerSlice.objects.select_related().all() |
| 5391 | serializer_class = ControllerSliceSerializer |
| 5392 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5393 | |
| 5394 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5395 | no_hyperlinks=False |
| 5396 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5397 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5398 | if (no_hyperlinks): |
| 5399 | return self.id_serializer_class |
| 5400 | else: |
| 5401 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5402 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5403 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5404 | if (not self.request.user.is_authenticated()): |
| 5405 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5406 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5407 | |
| 5408 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5409 | |
| 5410 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5411 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5412 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5413 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5414 | class ControllerDashboardViewList(generics.ListCreateAPIView): |
| 5415 | queryset = ControllerDashboardView.objects.select_related().all() |
| 5416 | serializer_class = ControllerDashboardViewSerializer |
| 5417 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 5418 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5419 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5420 | |
| 5421 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5422 | no_hyperlinks=False |
| 5423 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5424 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5425 | if (no_hyperlinks): |
| 5426 | return self.id_serializer_class |
| 5427 | else: |
| 5428 | return self.serializer_class |
| 5429 | |
| 5430 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5431 | if (not self.request.user.is_authenticated()): |
| 5432 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5433 | return ControllerDashboardView.select_by_user(self.request.user) |
| 5434 | |
| 5435 | def create(self, request, *args, **kwargs): |
| 5436 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5437 | if not (serializer.is_valid()): |
| 5438 | response = {"error": "validation", |
| 5439 | "specific_error": "not serializer.is_valid()",
|
| 5440 | "reasons": serializer.errors}
|
| 5441 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5442 | obj = serializer.object |
| 5443 | obj.caller = request.user |
| 5444 | if obj.can_update(request.user): |
| 5445 | return super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 5446 | else: |
| 5447 | raise Exception("failed obj.can_update") |
| 5448 | |
| 5449 | ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 5450 | if (ret.status_code%100 != 200): |
| 5451 | raise Exception(ret.data) |
| 5452 | |
| 5453 | return ret |
| 5454 | |
| 5455 | |
| 5456 | class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5457 | queryset = ControllerDashboardView.objects.select_related().all() |
| 5458 | serializer_class = ControllerDashboardViewSerializer |
| 5459 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 5460 | |
| 5461 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5462 | no_hyperlinks=False |
| 5463 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5464 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5465 | if (no_hyperlinks): |
| 5466 | return self.id_serializer_class |
| 5467 | else: |
| 5468 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5469 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5470 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5471 | if (not self.request.user.is_authenticated()): |
| 5472 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5473 | return ControllerDashboardView.select_by_user(self.request.user) |
| 5474 | |
| 5475 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5476 | |
| 5477 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5478 | |
| 5479 | |
| 5480 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5481 | class AccountList(generics.ListCreateAPIView): |
| 5482 | queryset = Account.objects.select_related().all() |
| 5483 | serializer_class = AccountSerializer |
| 5484 | id_serializer_class = AccountIdSerializer |
| 5485 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5486 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5487 | |
| 5488 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5489 | no_hyperlinks=False |
| 5490 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5491 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5492 | if (no_hyperlinks): |
| 5493 | return self.id_serializer_class |
| 5494 | else: |
| 5495 | return self.serializer_class |
| 5496 | |
| 5497 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5498 | if (not self.request.user.is_authenticated()): |
| 5499 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5500 | return Account.select_by_user(self.request.user) |
| 5501 | |
| 5502 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5503 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5504 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5505 | response = {"error": "validation", |
| 5506 | "specific_error": "not serializer.is_valid()",
|
| 5507 | "reasons": serializer.errors}
|
| 5508 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5509 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5510 | obj.caller = request.user |
| 5511 | if obj.can_update(request.user): |
| 5512 | return super(AccountList, self).create(request, *args, **kwargs) |
| 5513 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5514 | raise Exception("failed obj.can_update") |
| 5515 | |
| 5516 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 5517 | if (ret.status_code%100 != 200): |
| 5518 | raise Exception(ret.data) |
| 5519 | |
| 5520 | return ret |
| 5521 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5522 | |
| 5523 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5524 | queryset = Account.objects.select_related().all() |
| 5525 | serializer_class = AccountSerializer |
| 5526 | id_serializer_class = AccountIdSerializer |
| 5527 | |
| 5528 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5529 | no_hyperlinks=False |
| 5530 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5531 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5532 | if (no_hyperlinks): |
| 5533 | return self.id_serializer_class |
| 5534 | else: |
| 5535 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5536 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5537 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5538 | if (not self.request.user.is_authenticated()): |
| 5539 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5540 | return Account.select_by_user(self.request.user) |
| 5541 | |
| 5542 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5543 | |
| 5544 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5545 | |
| 5546 | |
| 5547 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5548 | class ControllerRoleList(generics.ListCreateAPIView): |
| 5549 | queryset = ControllerRole.objects.select_related().all() |
| 5550 | serializer_class = ControllerRoleSerializer |
| 5551 | id_serializer_class = ControllerRoleIdSerializer |
| 5552 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5553 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5554 | |
| 5555 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5556 | no_hyperlinks=False |
| 5557 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5558 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5559 | if (no_hyperlinks): |
| 5560 | return self.id_serializer_class |
| 5561 | else: |
| 5562 | return self.serializer_class |
| 5563 | |
| 5564 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5565 | if (not self.request.user.is_authenticated()): |
| 5566 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5567 | return ControllerRole.select_by_user(self.request.user) |
| 5568 | |
| 5569 | def create(self, request, *args, **kwargs): |
| 5570 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5571 | if not (serializer.is_valid()): |
| 5572 | response = {"error": "validation", |
| 5573 | "specific_error": "not serializer.is_valid()",
|
| 5574 | "reasons": serializer.errors}
|
| 5575 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5576 | obj = serializer.object |
| 5577 | obj.caller = request.user |
| 5578 | if obj.can_update(request.user): |
| 5579 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5580 | else: |
| 5581 | raise Exception("failed obj.can_update") |
| 5582 | |
| 5583 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5584 | if (ret.status_code%100 != 200): |
| 5585 | raise Exception(ret.data) |
| 5586 | |
| 5587 | return ret |
| 5588 | |
| 5589 | |
| 5590 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5591 | queryset = ControllerRole.objects.select_related().all() |
| 5592 | serializer_class = ControllerRoleSerializer |
| 5593 | id_serializer_class = ControllerRoleIdSerializer |
| 5594 | |
| 5595 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5596 | no_hyperlinks=False |
| 5597 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5598 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5599 | if (no_hyperlinks): |
| 5600 | return self.id_serializer_class |
| 5601 | else: |
| 5602 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5603 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5604 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5605 | if (not self.request.user.is_authenticated()): |
| 5606 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5607 | return ControllerRole.select_by_user(self.request.user) |
| 5608 | |
| 5609 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5610 | |
| 5611 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5612 | |
| 5613 | |
| 5614 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5615 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 5616 | queryset = NetworkParameterType.objects.select_related().all() |
| 5617 | serializer_class = NetworkParameterTypeSerializer |
| 5618 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5619 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5620 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5621 | |
| 5622 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5623 | no_hyperlinks=False |
| 5624 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5625 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5626 | if (no_hyperlinks): |
| 5627 | return self.id_serializer_class |
| 5628 | else: |
| 5629 | return self.serializer_class |
| 5630 | |
| 5631 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5632 | if (not self.request.user.is_authenticated()): |
| 5633 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5634 | return NetworkParameterType.select_by_user(self.request.user) |
| 5635 | |
| 5636 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5637 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5638 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5639 | response = {"error": "validation", |
| 5640 | "specific_error": "not serializer.is_valid()",
|
| 5641 | "reasons": serializer.errors}
|
| 5642 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5643 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5644 | obj.caller = request.user |
| 5645 | if obj.can_update(request.user): |
| 5646 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5647 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5648 | raise Exception("failed obj.can_update") |
| 5649 | |
| 5650 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5651 | if (ret.status_code%100 != 200): |
| 5652 | raise Exception(ret.data) |
| 5653 | |
| 5654 | return ret |
| 5655 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5656 | |
| 5657 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5658 | queryset = NetworkParameterType.objects.select_related().all() |
| 5659 | serializer_class = NetworkParameterTypeSerializer |
| 5660 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5661 | |
| 5662 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5663 | no_hyperlinks=False |
| 5664 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5665 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5666 | if (no_hyperlinks): |
| 5667 | return self.id_serializer_class |
| 5668 | else: |
| 5669 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5670 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5671 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5672 | if (not self.request.user.is_authenticated()): |
| 5673 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5674 | return NetworkParameterType.select_by_user(self.request.user) |
| 5675 | |
| 5676 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5677 | |
| 5678 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5679 | |
| 5680 | |
| 5681 | |
| 5682 | class SiteCredentialList(generics.ListCreateAPIView): |
| 5683 | queryset = SiteCredential.objects.select_related().all() |
| 5684 | serializer_class = SiteCredentialSerializer |
| 5685 | id_serializer_class = SiteCredentialIdSerializer |
| 5686 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5687 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5688 | |
| 5689 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5690 | no_hyperlinks=False |
| 5691 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5692 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5693 | if (no_hyperlinks): |
| 5694 | return self.id_serializer_class |
| 5695 | else: |
| 5696 | return self.serializer_class |
| 5697 | |
| 5698 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5699 | if (not self.request.user.is_authenticated()): |
| 5700 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5701 | return SiteCredential.select_by_user(self.request.user) |
| 5702 | |
| 5703 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5704 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5705 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5706 | response = {"error": "validation", |
| 5707 | "specific_error": "not serializer.is_valid()",
|
| 5708 | "reasons": serializer.errors}
|
| 5709 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5710 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5711 | obj.caller = request.user |
| 5712 | if obj.can_update(request.user): |
| 5713 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5714 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5715 | raise Exception("failed obj.can_update") |
| 5716 | |
| 5717 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5718 | if (ret.status_code%100 != 200): |
| 5719 | raise Exception(ret.data) |
| 5720 | |
| 5721 | return ret |
| 5722 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5723 | |
| 5724 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5725 | queryset = SiteCredential.objects.select_related().all() |
| 5726 | serializer_class = SiteCredentialSerializer |
| 5727 | id_serializer_class = SiteCredentialIdSerializer |
| 5728 | |
| 5729 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5730 | no_hyperlinks=False |
| 5731 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5732 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5733 | if (no_hyperlinks): |
| 5734 | return self.id_serializer_class |
| 5735 | else: |
| 5736 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5737 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5738 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5739 | if (not self.request.user.is_authenticated()): |
| 5740 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5741 | return SiteCredential.select_by_user(self.request.user) |
| 5742 | |
| 5743 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5744 | |
| 5745 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5746 | |
| 5747 | |
| 5748 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5749 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 5750 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5751 | serializer_class = DeploymentPrivilegeSerializer |
| 5752 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5753 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5754 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5755 | |
| 5756 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5757 | no_hyperlinks=False |
| 5758 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5759 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5760 | if (no_hyperlinks): |
| 5761 | return self.id_serializer_class |
| 5762 | else: |
| 5763 | return self.serializer_class |
| 5764 | |
| 5765 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5766 | if (not self.request.user.is_authenticated()): |
| 5767 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5768 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5769 | |
| 5770 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5771 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5772 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5773 | response = {"error": "validation", |
| 5774 | "specific_error": "not serializer.is_valid()",
|
| 5775 | "reasons": serializer.errors}
|
| 5776 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5777 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5778 | obj.caller = request.user |
| 5779 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5780 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5781 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5782 | raise Exception("failed obj.can_update") |
| 5783 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5784 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5785 | if (ret.status_code%100 != 200): |
| 5786 | raise Exception(ret.data) |
| 5787 | |
| 5788 | return ret |
| 5789 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5790 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5791 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5792 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5793 | serializer_class = DeploymentPrivilegeSerializer |
| 5794 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5795 | |
| 5796 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5797 | no_hyperlinks=False |
| 5798 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5799 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5800 | if (no_hyperlinks): |
| 5801 | return self.id_serializer_class |
| 5802 | else: |
| 5803 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5804 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5805 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5806 | if (not self.request.user.is_authenticated()): |
| 5807 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5808 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5809 | |
| 5810 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5811 | |
| 5812 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5813 | |
| 5814 | |
| 5815 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5816 | class ControllerSlicePrivilegeList(generics.ListCreateAPIView): |
| 5817 | queryset = ControllerSlicePrivilege.objects.select_related().all() |
| 5818 | serializer_class = ControllerSlicePrivilegeSerializer |
| 5819 | id_serializer_class = ControllerSlicePrivilegeIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5820 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5821 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5822 | |
| 5823 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5824 | no_hyperlinks=False |
| 5825 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5826 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5827 | if (no_hyperlinks): |
| 5828 | return self.id_serializer_class |
| 5829 | else: |
| 5830 | return self.serializer_class |
| 5831 | |
| 5832 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5833 | if (not self.request.user.is_authenticated()): |
| 5834 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5835 | return ControllerSlicePrivilege.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5836 | |
| 5837 | def create(self, request, *args, **kwargs): |
| 5838 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5839 | if not (serializer.is_valid()): |
| 5840 | response = {"error": "validation", |
| 5841 | "specific_error": "not serializer.is_valid()",
|
| 5842 | "reasons": serializer.errors}
|
| 5843 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5844 | obj = serializer.object |
| 5845 | obj.caller = request.user |
| 5846 | if obj.can_update(request.user): |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5847 | return super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5848 | else: |
| 5849 | raise Exception("failed obj.can_update") |
| 5850 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5851 | ret = super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5852 | if (ret.status_code%100 != 200): |
| 5853 | raise Exception(ret.data) |
| 5854 | |
| 5855 | return ret |
| 5856 | |
| 5857 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5858 | class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5859 | queryset = ControllerSlicePrivilege.objects.select_related().all() |
| 5860 | serializer_class = ControllerSlicePrivilegeSerializer |
| 5861 | id_serializer_class = ControllerSlicePrivilegeIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5862 | |
| 5863 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5864 | no_hyperlinks=False |
| 5865 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5866 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5867 | if (no_hyperlinks): |
| 5868 | return self.id_serializer_class |
| 5869 | else: |
| 5870 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5871 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5872 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5873 | if (not self.request.user.is_authenticated()): |
| 5874 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5875 | return ControllerSlicePrivilege.select_by_user(self.request.user) |
| 5876 | |
| 5877 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5878 | |
| 5879 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5880 | |
| 5881 | |
| 5882 | |
| 5883 | class SiteDeploymentList(generics.ListCreateAPIView): |
| 5884 | queryset = SiteDeployment.objects.select_related().all() |
| 5885 | serializer_class = SiteDeploymentSerializer |
| 5886 | id_serializer_class = SiteDeploymentIdSerializer |
| 5887 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5888 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5889 | |
| 5890 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5891 | no_hyperlinks=False |
| 5892 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5893 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5894 | if (no_hyperlinks): |
| 5895 | return self.id_serializer_class |
| 5896 | else: |
| 5897 | return self.serializer_class |
| 5898 | |
| 5899 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5900 | if (not self.request.user.is_authenticated()): |
| 5901 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5902 | return SiteDeployment.select_by_user(self.request.user) |
| 5903 | |
| 5904 | def create(self, request, *args, **kwargs): |
| 5905 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5906 | if not (serializer.is_valid()): |
| 5907 | response = {"error": "validation", |
| 5908 | "specific_error": "not serializer.is_valid()",
|
| 5909 | "reasons": serializer.errors}
|
| 5910 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5911 | obj = serializer.object |
| 5912 | obj.caller = request.user |
| 5913 | if obj.can_update(request.user): |
| 5914 | return super(SiteDeploymentList, self).create(request, *args, **kwargs) |
| 5915 | else: |
| 5916 | raise Exception("failed obj.can_update") |
| 5917 | |
| 5918 | ret = super(SiteDeploymentList, self).create(request, *args, **kwargs) |
| 5919 | if (ret.status_code%100 != 200): |
| 5920 | raise Exception(ret.data) |
| 5921 | |
| 5922 | return ret |
| 5923 | |
| 5924 | |
| 5925 | class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5926 | queryset = SiteDeployment.objects.select_related().all() |
| 5927 | serializer_class = SiteDeploymentSerializer |
| 5928 | id_serializer_class = SiteDeploymentIdSerializer |
| 5929 | |
| 5930 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5931 | no_hyperlinks=False |
| 5932 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5933 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5934 | if (no_hyperlinks): |
| 5935 | return self.id_serializer_class |
| 5936 | else: |
| 5937 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5938 | |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5939 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5940 | if (not self.request.user.is_authenticated()): |
| 5941 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 191f9b2 | 2015-01-12 13:16:39 -0800 | [diff] [blame] | 5942 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5943 | |
| 5944 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5945 | |
| 5946 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5947 | |
| 5948 | |
| 5949 | |
| 5950 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 5951 | queryset = DeploymentRole.objects.select_related().all() |
| 5952 | serializer_class = DeploymentRoleSerializer |
| 5953 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5954 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5955 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5956 | |
| 5957 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5958 | no_hyperlinks=False |
| 5959 | if hasattr(self.request,"QUERY_PARAMS"): |
| 5960 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5961 | if (no_hyperlinks): |
| 5962 | return self.id_serializer_class |
| 5963 | else: |
| 5964 | return self.serializer_class |
| 5965 | |
| 5966 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 5967 | if (not self.request.user.is_authenticated()): |
| 5968 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5969 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5970 | |
| 5971 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5972 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5973 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5974 | response = {"error": "validation", |
| 5975 | "specific_error": "not serializer.is_valid()",
|
| 5976 | "reasons": serializer.errors}
|
| 5977 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5978 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5979 | obj.caller = request.user |
| 5980 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5981 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5982 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5983 | raise Exception("failed obj.can_update") |
| 5984 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5985 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5986 | if (ret.status_code%100 != 200): |
| 5987 | raise Exception(ret.data) |
| 5988 | |
| 5989 | return ret |
| 5990 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5991 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5992 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5993 | queryset = DeploymentRole.objects.select_related().all() |
| 5994 | serializer_class = DeploymentRoleSerializer |
| 5995 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5996 | |
| 5997 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 5998 | no_hyperlinks=False |
| 5999 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6000 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6001 | if (no_hyperlinks): |
| 6002 | return self.id_serializer_class |
| 6003 | else: |
| 6004 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6005 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6006 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6007 | if (not self.request.user.is_authenticated()): |
| 6008 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 6009 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6010 | |
| 6011 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 6012 | |
| 6013 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 6014 | |
| 6015 | |
| 6016 | |
| 6017 | class UserCredentialList(generics.ListCreateAPIView): |
| 6018 | queryset = UserCredential.objects.select_related().all() |
| 6019 | serializer_class = UserCredentialSerializer |
| 6020 | id_serializer_class = UserCredentialIdSerializer |
| 6021 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6022 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6023 | |
| 6024 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6025 | no_hyperlinks=False |
| 6026 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6027 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6028 | if (no_hyperlinks): |
| 6029 | return self.id_serializer_class |
| 6030 | else: |
| 6031 | return self.serializer_class |
| 6032 | |
| 6033 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6034 | if (not self.request.user.is_authenticated()): |
| 6035 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6036 | return UserCredential.select_by_user(self.request.user) |
| 6037 | |
| 6038 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6039 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6040 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6041 | response = {"error": "validation", |
| 6042 | "specific_error": "not serializer.is_valid()",
|
| 6043 | "reasons": serializer.errors}
|
| 6044 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6045 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6046 | obj.caller = request.user |
| 6047 | if obj.can_update(request.user): |
| 6048 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 6049 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6050 | raise Exception("failed obj.can_update") |
| 6051 | |
| 6052 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 6053 | if (ret.status_code%100 != 200): |
| 6054 | raise Exception(ret.data) |
| 6055 | |
| 6056 | return ret |
| 6057 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6058 | |
| 6059 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 6060 | queryset = UserCredential.objects.select_related().all() |
| 6061 | serializer_class = UserCredentialSerializer |
| 6062 | id_serializer_class = UserCredentialIdSerializer |
| 6063 | |
| 6064 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6065 | no_hyperlinks=False |
| 6066 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6067 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6068 | if (no_hyperlinks): |
| 6069 | return self.id_serializer_class |
| 6070 | else: |
| 6071 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6072 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6073 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6074 | if (not self.request.user.is_authenticated()): |
| 6075 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6076 | return UserCredential.select_by_user(self.request.user) |
| 6077 | |
| 6078 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 6079 | |
| 6080 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 6081 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6082 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6083 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6084 | class SliceTagList(generics.ListCreateAPIView): |
| 6085 | queryset = SliceTag.objects.select_related().all() |
| 6086 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6087 | id_serializer_class = SliceTagIdSerializer |
| 6088 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6089 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6090 | |
| 6091 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6092 | no_hyperlinks=False |
| 6093 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6094 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6095 | if (no_hyperlinks): |
| 6096 | return self.id_serializer_class |
| 6097 | else: |
| 6098 | return self.serializer_class |
| 6099 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6100 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6101 | if (not self.request.user.is_authenticated()): |
| 6102 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6103 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6104 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6105 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6106 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6107 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6108 | response = {"error": "validation", |
| 6109 | "specific_error": "not serializer.is_valid()",
|
| 6110 | "reasons": serializer.errors}
|
| 6111 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6112 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6113 | obj.caller = request.user |
| 6114 | if obj.can_update(request.user): |
| 6115 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 6116 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6117 | raise Exception("failed obj.can_update") |
| 6118 | |
| 6119 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 6120 | if (ret.status_code%100 != 200): |
| 6121 | raise Exception(ret.data) |
| 6122 | |
| 6123 | return ret |
| 6124 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6125 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6126 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6127 | queryset = SliceTag.objects.select_related().all() |
| 6128 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6129 | id_serializer_class = SliceTagIdSerializer |
| 6130 | |
| 6131 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6132 | no_hyperlinks=False |
| 6133 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6134 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6135 | if (no_hyperlinks): |
| 6136 | return self.id_serializer_class |
| 6137 | else: |
| 6138 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6139 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6140 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6141 | if (not self.request.user.is_authenticated()): |
| 6142 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6143 | return SliceTag.select_by_user(self.request.user) |
| 6144 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6145 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6146 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6147 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6148 | |
| 6149 | |
| 6150 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6151 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 6152 | queryset = NetworkTemplate.objects.select_related().all() |
| 6153 | serializer_class = NetworkTemplateSerializer |
| 6154 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6155 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6156 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6157 | |
| 6158 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6159 | no_hyperlinks=False |
| 6160 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6161 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6162 | if (no_hyperlinks): |
| 6163 | return self.id_serializer_class |
| 6164 | else: |
| 6165 | return self.serializer_class |
| 6166 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6167 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6168 | if (not self.request.user.is_authenticated()): |
| 6169 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6170 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6171 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6172 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6173 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6174 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6175 | response = {"error": "validation", |
| 6176 | "specific_error": "not serializer.is_valid()",
|
| 6177 | "reasons": serializer.errors}
|
| 6178 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6179 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6180 | obj.caller = request.user |
| 6181 | if obj.can_update(request.user): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6182 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6183 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6184 | raise Exception("failed obj.can_update") |
| 6185 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6186 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6187 | if (ret.status_code%100 != 200): |
| 6188 | raise Exception(ret.data) |
| 6189 | |
| 6190 | return ret |
| 6191 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6192 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6193 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 6194 | queryset = NetworkTemplate.objects.select_related().all() |
| 6195 | serializer_class = NetworkTemplateSerializer |
| 6196 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6197 | |
| 6198 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6199 | no_hyperlinks=False |
| 6200 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6201 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6202 | if (no_hyperlinks): |
| 6203 | return self.id_serializer_class |
| 6204 | else: |
| 6205 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6206 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6207 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6208 | if (not self.request.user.is_authenticated()): |
| 6209 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 6210 | return NetworkTemplate.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6211 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6212 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6213 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6214 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6215 | |
| 6216 | |
| 6217 | |
| 6218 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6219 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6220 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6221 | id_serializer_class = RouterIdSerializer |
| 6222 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6223 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6224 | |
| 6225 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6226 | no_hyperlinks=False |
| 6227 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6228 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6229 | if (no_hyperlinks): |
| 6230 | return self.id_serializer_class |
| 6231 | else: |
| 6232 | return self.serializer_class |
| 6233 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6234 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6235 | if (not self.request.user.is_authenticated()): |
| 6236 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6237 | return Router.select_by_user(self.request.user) |
| 6238 | |
| 6239 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6240 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6241 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6242 | response = {"error": "validation", |
| 6243 | "specific_error": "not serializer.is_valid()",
|
| 6244 | "reasons": serializer.errors}
|
| 6245 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6246 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6247 | obj.caller = request.user |
| 6248 | if obj.can_update(request.user): |
| 6249 | return super(RouterList, self).create(request, *args, **kwargs) |
| 6250 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6251 | raise Exception("failed obj.can_update") |
| 6252 | |
| 6253 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 6254 | if (ret.status_code%100 != 200): |
| 6255 | raise Exception(ret.data) |
| 6256 | |
| 6257 | return ret |
| 6258 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6259 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6260 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6261 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6262 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6263 | id_serializer_class = RouterIdSerializer |
| 6264 | |
| 6265 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6266 | no_hyperlinks=False |
| 6267 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6268 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6269 | if (no_hyperlinks): |
| 6270 | return self.id_serializer_class |
| 6271 | else: |
| 6272 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6273 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6274 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6275 | if (not self.request.user.is_authenticated()): |
| 6276 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6277 | return Router.select_by_user(self.request.user) |
| 6278 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6279 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6280 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6281 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6282 | |
| 6283 | |
| 6284 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6285 | class ServiceResourceList(generics.ListCreateAPIView): |
| 6286 | queryset = ServiceResource.objects.select_related().all() |
| 6287 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6288 | id_serializer_class = ServiceResourceIdSerializer |
| 6289 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6290 | filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6291 | |
| 6292 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6293 | no_hyperlinks=False |
| 6294 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6295 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6296 | if (no_hyperlinks): |
| 6297 | return self.id_serializer_class |
| 6298 | else: |
| 6299 | return self.serializer_class |
| 6300 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6301 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6302 | if (not self.request.user.is_authenticated()): |
| 6303 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6304 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6305 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6306 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6307 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 6308 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 6309 | response = {"error": "validation", |
| 6310 | "specific_error": "not serializer.is_valid()",
|
| 6311 | "reasons": serializer.errors}
|
| 6312 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 6313 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6314 | obj.caller = request.user |
| 6315 | if obj.can_update(request.user): |
| 6316 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 6317 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 6318 | raise Exception("failed obj.can_update") |
| 6319 | |
| 6320 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 6321 | if (ret.status_code%100 != 200): |
| 6322 | raise Exception(ret.data) |
| 6323 | |
| 6324 | return ret |
| 6325 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6326 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6327 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6328 | queryset = ServiceResource.objects.select_related().all() |
| 6329 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6330 | id_serializer_class = ServiceResourceIdSerializer |
| 6331 | |
| 6332 | def get_serializer_class(self): |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6333 | no_hyperlinks=False |
| 6334 | if hasattr(self.request,"QUERY_PARAMS"): |
| 6335 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 6336 | if (no_hyperlinks): |
| 6337 | return self.id_serializer_class |
| 6338 | else: |
| 6339 | return self.serializer_class |
Scott Baker | 84cf39e | 2015-01-30 15:41:39 -0800 | [diff] [blame] | 6340 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6341 | def get_queryset(self): |
Scott Baker | 20101af | 2015-02-02 10:41:12 -0800 | [diff] [blame] | 6342 | if (not self.request.user.is_authenticated()): |
| 6343 | raise PermissionDenied("You must be authenticated in order to use this API") |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6344 | return ServiceResource.select_by_user(self.request.user) |
| 6345 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6346 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 6347 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6348 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6349 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 6350 | |
| 6351 | |