Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1 | from rest_framework.decorators import api_view |
| 2 | from rest_framework.response import Response |
| 3 | from rest_framework.reverse import reverse |
| 4 | from rest_framework import serializers |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5 | from rest_framework import generics |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 7 | from rest_framework.generics import GenericAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 8 | from core.models import * |
| 9 | from django.forms import widgets |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 10 | from rest_framework import filters |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 11 | from django.conf.urls import patterns, url |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 12 | |
| 13 | """ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 14 | Schema of the generator object: |
| 15 | all: Set of all Model objects |
| 16 | all_if(regex): Set of Model objects that match regex |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 17 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 18 | Model object: |
| 19 | plural: English plural of object name |
| 20 | camel: CamelCase version of object name |
| 21 | refs: list of references to other Model objects |
| 22 | props: list of properties minus refs |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 23 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 24 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 25 | """ |
| 26 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 27 | def get_REST_patterns(): |
| 28 | return patterns('', |
| 29 | url(r'^plstackapi/$', api_root), |
| 30 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 31 | url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 32 | url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
| 33 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 34 | url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 35 | url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
| 36 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 37 | url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'), |
| 38 | url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'), |
| 39 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 40 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 41 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
| 42 | |
| 43 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 44 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
| 45 | |
| 46 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 47 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
| 48 | |
| 49 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 50 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
| 51 | |
| 52 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 53 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
| 54 | |
| 55 | url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 56 | url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
| 57 | |
| 58 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 59 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
| 60 | |
| 61 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 62 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
| 63 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 64 | url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'), |
| 65 | url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'), |
| 66 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 67 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 68 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
| 69 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 70 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 71 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 72 | |
| 73 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 74 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 75 | |
| 76 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 77 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 78 | |
| 79 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 80 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 81 | |
| 82 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 83 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 84 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 85 | url(r'plstackapi/controllernetworks/$', ControllerNetworksList.as_view(), name='controllernetworks-list'), |
| 86 | url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworksDetail.as_view(), name ='controllernetworks-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 87 | |
| 88 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 89 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 90 | |
| 91 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 92 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 93 | |
| 94 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 95 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 96 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 97 | url(r'plstackapi/controllersitedeploymentses/$', ControllerSiteDeploymentsList.as_view(), name='controllersitedeployments-list'), |
| 98 | url(r'plstackapi/controllersitedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDeploymentsDetail.as_view(), name ='controllersitedeployments-detail'), |
| 99 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 100 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 101 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 102 | |
| 103 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 104 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 105 | |
| 106 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 107 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 108 | |
| 109 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 110 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 111 | |
| 112 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 113 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 114 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 115 | url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 116 | 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] | 117 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 118 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 119 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 120 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 121 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 122 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 123 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 124 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 125 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 126 | |
| 127 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 128 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 129 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 130 | url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'), |
| 131 | url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
| 132 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 133 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 134 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 135 | |
| 136 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 137 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 138 | |
| 139 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 140 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
| 141 | |
| 142 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 143 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 144 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 145 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 146 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 147 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 148 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 149 | 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] | 150 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 151 | url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'), |
| 152 | url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'), |
| 153 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 154 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 155 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 156 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 157 | url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 158 | url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
| 159 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 160 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 161 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 162 | |
| 163 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 164 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 165 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 166 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 167 | 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] | 168 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 169 | url(r'plstackapi/controllerusers/$', ControllerUsersList.as_view(), name='controllerusers-list'), |
| 170 | url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUsersDetail.as_view(), name ='controllerusers-detail'), |
| 171 | |
| 172 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 173 | 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] | 174 | |
| 175 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 176 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 177 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 178 | url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'), |
| 179 | url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 180 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 181 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 182 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 183 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 184 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 185 | 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] | 186 | |
| 187 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 188 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 189 | |
| 190 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 191 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 192 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 193 | url(r'plstackapi/controllerslices/$', ControllerSlicesList.as_view(), name='controllerslices-list'), |
| 194 | url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicesDetail.as_view(), name ='controllerslices-detail'), |
| 195 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 196 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 197 | |
| 198 | @api_view(['GET']) |
| 199 | def api_root(request, format=None): |
| 200 | return Response({ |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 201 | 'flavors': reverse('flavor-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 202 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 203 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 204 | 'images': reverse('image-list', request=request, format=format), |
| 205 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 206 | 'sites': reverse('site-list', request=request, format=format), |
| 207 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 208 | 'tags': reverse('tag-list', request=request, format=format), |
| 209 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 210 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 211 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 212 | 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 213 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 214 | 'projects': reverse('project-list', request=request, format=format), |
| 215 | 'slices': reverse('slice-list', request=request, format=format), |
| 216 | 'networks': reverse('network-list', request=request, format=format), |
| 217 | 'services': reverse('service-list', request=request, format=format), |
| 218 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 219 | 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 220 | 'charges': reverse('charge-list', request=request, format=format), |
| 221 | 'roles': reverse('role-list', request=request, format=format), |
| 222 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 223 | 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 224 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 225 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 226 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 227 | 'nodes': reverse('node-list', request=request, format=format), |
| 228 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 229 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 230 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 231 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 232 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 233 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 234 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 235 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 236 | 'users': reverse('user-list', request=request, format=format), |
| 237 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 238 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 239 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 240 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 241 | 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 242 | 'accounts': reverse('account-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 243 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 244 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 245 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 246 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 247 | 'controlleruserses': reverse('controllerusers-list', request=request, format=format), |
| 248 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 249 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 250 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 251 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 252 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 253 | 'routers': reverse('router-list', request=request, format=format), |
| 254 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 255 | 'controllersliceses': reverse('controllerslices-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 256 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 257 | }) |
| 258 | |
| 259 | # Based on serializers.py |
| 260 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 261 | class XOSModelSerializer(serializers.ModelSerializer): |
| 262 | def save_object(self, obj, **kwargs): |
| 263 | |
| 264 | """ rest_framework can't deal with ManyToMany relations that have a |
| 265 | through table. In plstackapi, most of the through tables we have |
| 266 | use defaults or blank fields, so there's no reason why we shouldn't |
| 267 | be able to save these objects. |
| 268 | |
| 269 | So, let's strip out these m2m relations, and deal with them ourself. |
| 270 | """ |
| 271 | obj._complex_m2m_data={};
|
| 272 | if getattr(obj, '_m2m_data', None):
|
| 273 | for relatedObject in obj._meta.get_all_related_many_to_many_objects():
|
| 274 | if (relatedObject.field.rel.through._meta.auto_created):
|
| 275 | # These are non-trough ManyToMany relations and
|
| 276 | # can be updated just fine
|
| 277 | continue
|
| 278 | fieldName = relatedObject.get_accessor_name()
|
| 279 | if fieldName in obj._m2m_data.keys():
|
| 280 | obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
|
| 281 | del obj._m2m_data[fieldName]
|
| 282 |
|
| 283 | serializers.ModelSerializer.save_object(self, obj, **kwargs); |
| 284 | |
| 285 | for (accessor, stuff) in obj._complex_m2m_data.items(): |
| 286 | (relatedObject, data) = stuff |
| 287 | through = relatedObject.field.rel.through |
| 288 | local_fieldName = relatedObject.field.m2m_reverse_field_name() |
| 289 | remote_fieldName = relatedObject.field.m2m_field_name() |
| 290 | |
| 291 | # get the current set of existing relations |
| 292 | existing = through.objects.filter(**{local_fieldName: obj}); |
| 293 | |
| 294 | data_ids = [item.id for item in data] |
| 295 | existing_ids = [getattr(item,remote_fieldName).id for item in existing] |
| 296 | |
| 297 | #print "data_ids", data_ids |
| 298 | #print "existing_ids", existing_ids |
| 299 | |
| 300 | # remove relations that are in 'existing' but not in 'data' |
| 301 | for item in list(existing): |
| 302 | if (getattr(item,remote_fieldName).id not in data_ids): |
| 303 | print "delete", getattr(item,remote_fieldName) |
| 304 | item.delete() #(purge=True) |
| 305 | |
| 306 | # add relations that are in 'data' but not in 'existing' |
| 307 | for item in data: |
| 308 | if (item.id not in existing_ids): |
| 309 | #print "add", item |
| 310 | newModel = through(**{local_fieldName: obj, remote_fieldName: item}) |
| 311 | newModel.save() |
| 312 | |
| 313 | |
| 314 | |
| 315 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
| 316 | id = serializers.Field() |
| 317 | |
| 318 | |
| 319 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 320 | |
| 321 | |
| 322 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 323 | validators = serializers.SerializerMethodField("getValidators") |
| 324 | def getHumanReadableName(self, obj):
|
| 325 | return str(obj) |
| 326 | def getValidators(self, obj): |
| 327 | try: |
| 328 | return obj.getValidators() |
| 329 | except: |
| 330 | return None |
| 331 | class Meta: |
| 332 | model = Flavor |
| 333 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 334 | |
| 335 | class FlavorIdSerializer(XOSModelSerializer): |
| 336 | id = serializers.Field() |
| 337 | |
| 338 | |
| 339 | deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail') |
| 340 | |
| 341 | |
| 342 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 343 | validators = serializers.SerializerMethodField("getValidators") |
| 344 | def getHumanReadableName(self, obj):
|
| 345 | return str(obj)
|
| 346 | def getValidators(self, obj):
|
| 347 | try: |
| 348 | return obj.getValidators() |
| 349 | except: |
| 350 | return None
|
| 351 | class Meta:
|
| 352 | model = Flavor |
| 353 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 354 | |
| 355 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 356 | |
| 357 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 358 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 359 | id = serializers.Field() |
| 360 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 361 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 362 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 363 | def getHumanReadableName(self, obj):
|
| 364 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 365 | def getValidators(self, obj): |
| 366 | try: |
| 367 | return obj.getValidators() |
| 368 | except: |
| 369 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 370 | class Meta: |
| 371 | model = ServiceAttribute |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 372 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 373 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 374 | class ServiceAttributeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 375 | id = serializers.Field() |
| 376 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 377 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 378 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 379 | def getHumanReadableName(self, obj):
|
| 380 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 381 | def getValidators(self, obj):
|
| 382 | try: |
| 383 | return obj.getValidators() |
| 384 | except: |
| 385 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 386 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 387 | model = ServiceAttribute |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 388 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 389 | |
| 390 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 391 | |
| 392 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 393 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
| 394 | id = serializers.Field() |
| 395 | |
| 396 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 397 | validators = serializers.SerializerMethodField("getValidators") |
| 398 | def getHumanReadableName(self, obj):
|
| 399 | return str(obj) |
| 400 | def getValidators(self, obj): |
| 401 | try: |
| 402 | return obj.getValidators() |
| 403 | except: |
| 404 | return None |
| 405 | class Meta: |
| 406 | model = ControllerImages |
| 407 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 408 | |
| 409 | class ControllerImagesIdSerializer(XOSModelSerializer): |
| 410 | id = serializers.Field() |
| 411 | |
| 412 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 413 | validators = serializers.SerializerMethodField("getValidators") |
| 414 | def getHumanReadableName(self, obj):
|
| 415 | return str(obj)
|
| 416 | def getValidators(self, obj):
|
| 417 | try: |
| 418 | return obj.getValidators() |
| 419 | except: |
| 420 | return None
|
| 421 | class Meta:
|
| 422 | model = ControllerImages |
| 423 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 428 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 429 | id = serializers.Field() |
| 430 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 431 | |
| 432 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 433 | |
| 434 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 435 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 436 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 437 | def getHumanReadableName(self, obj):
|
| 438 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 439 | def getValidators(self, obj): |
| 440 | try: |
| 441 | return obj.getValidators() |
| 442 | except: |
| 443 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 444 | class Meta: |
| 445 | model = Image |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 446 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 447 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 448 | class ImageIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 449 | id = serializers.Field() |
| 450 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 451 | |
| 452 | deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail') |
| 453 | |
| 454 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 455 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 456 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 457 | def getHumanReadableName(self, obj):
|
| 458 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 459 | def getValidators(self, obj):
|
| 460 | try: |
| 461 | return obj.getValidators() |
| 462 | except: |
| 463 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 464 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 465 | model = Image |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 466 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 467 | |
| 468 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 469 | |
| 470 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 471 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 472 | id = serializers.Field() |
| 473 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 474 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 475 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 476 | def getHumanReadableName(self, obj):
|
| 477 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 478 | def getValidators(self, obj): |
| 479 | try: |
| 480 | return obj.getValidators() |
| 481 | except: |
| 482 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 483 | class Meta: |
| 484 | model = NetworkParameter |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 485 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 486 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 487 | class NetworkParameterIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 488 | id = serializers.Field() |
| 489 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 490 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 491 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 492 | def getHumanReadableName(self, obj):
|
| 493 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 494 | def getValidators(self, obj):
|
| 495 | try: |
| 496 | return obj.getValidators() |
| 497 | except: |
| 498 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 499 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 500 | model = NetworkParameter |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 501 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 502 | |
| 503 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 504 | |
| 505 | |
| 506 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 507 | id = serializers.Field() |
| 508 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 509 | |
| 510 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 511 | |
| 512 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 513 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 514 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 515 | def getHumanReadableName(self, obj):
|
| 516 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 517 | def getValidators(self, obj): |
| 518 | try: |
| 519 | return obj.getValidators() |
| 520 | except: |
| 521 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 522 | class Meta: |
| 523 | model = Site |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 524 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 525 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 526 | class SiteIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 527 | id = serializers.Field() |
| 528 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 529 | |
| 530 | deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail') |
| 531 | |
| 532 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 533 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 534 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 535 | def getHumanReadableName(self, obj):
|
| 536 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 537 | def getValidators(self, obj):
|
| 538 | try: |
| 539 | return obj.getValidators() |
| 540 | except: |
| 541 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 542 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 543 | model = Site |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 544 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 545 | |
| 546 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 547 | |
| 548 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 549 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 550 | id = serializers.Field() |
| 551 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 552 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 553 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 554 | def getHumanReadableName(self, obj):
|
| 555 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 556 | def getValidators(self, obj): |
| 557 | try: |
| 558 | return obj.getValidators() |
| 559 | except: |
| 560 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 561 | class Meta: |
| 562 | model = SliceRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 563 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 564 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 565 | class SliceRoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 566 | id = serializers.Field() |
| 567 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 568 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 569 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 570 | def getHumanReadableName(self, obj):
|
| 571 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 572 | def getValidators(self, obj):
|
| 573 | try: |
| 574 | return obj.getValidators() |
| 575 | except: |
| 576 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 577 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 578 | model = SliceRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 579 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 580 | |
| 581 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 582 | |
| 583 | |
| 584 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 585 | id = serializers.Field() |
| 586 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 587 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 588 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 589 | def getHumanReadableName(self, obj):
|
| 590 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 591 | def getValidators(self, obj): |
| 592 | try: |
| 593 | return obj.getValidators() |
| 594 | except: |
| 595 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 596 | class Meta: |
| 597 | model = Tag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 598 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 599 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 600 | class TagIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 601 | id = serializers.Field() |
| 602 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 603 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 604 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 605 | def getHumanReadableName(self, obj):
|
| 606 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 607 | def getValidators(self, obj):
|
| 608 | try: |
| 609 | return obj.getValidators() |
| 610 | except: |
| 611 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 612 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 613 | model = Tag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 614 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 615 | |
| 616 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 617 | |
| 618 | |
| 619 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 620 | id = serializers.Field() |
| 621 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 622 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 623 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 624 | def getHumanReadableName(self, obj):
|
| 625 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 626 | def getValidators(self, obj): |
| 627 | try: |
| 628 | return obj.getValidators() |
| 629 | except: |
| 630 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 631 | class Meta: |
| 632 | model = Invoice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 633 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 634 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 635 | class InvoiceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 636 | id = serializers.Field() |
| 637 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 638 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 639 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 640 | def getHumanReadableName(self, obj):
|
| 641 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 642 | def getValidators(self, obj):
|
| 643 | try: |
| 644 | return obj.getValidators() |
| 645 | except: |
| 646 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 647 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 648 | model = Invoice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 649 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 650 | |
| 651 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 652 | |
| 653 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 654 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 655 | id = serializers.Field() |
| 656 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 657 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 658 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 659 | def getHumanReadableName(self, obj):
|
| 660 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 661 | def getValidators(self, obj): |
| 662 | try: |
| 663 | return obj.getValidators() |
| 664 | except: |
| 665 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 666 | class Meta: |
| 667 | model = SlicePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 668 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 669 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 670 | class SlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 671 | id = serializers.Field() |
| 672 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 673 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 674 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 675 | def getHumanReadableName(self, obj):
|
| 676 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 677 | def getValidators(self, obj):
|
| 678 | try: |
| 679 | return obj.getValidators() |
| 680 | except: |
| 681 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 682 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 683 | model = SlicePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 684 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 685 | |
| 686 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 687 | |
| 688 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 689 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 690 | id = serializers.Field() |
| 691 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 692 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 693 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 694 | def getHumanReadableName(self, obj):
|
| 695 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 696 | def getValidators(self, obj): |
| 697 | try: |
| 698 | return obj.getValidators() |
| 699 | except: |
| 700 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 701 | class Meta: |
| 702 | model = PlanetStackRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 703 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 704 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 705 | class PlanetStackRoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 706 | id = serializers.Field() |
| 707 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 708 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 709 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 710 | def getHumanReadableName(self, obj):
|
| 711 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 712 | def getValidators(self, obj):
|
| 713 | try: |
| 714 | return obj.getValidators() |
| 715 | except: |
| 716 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 717 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 718 | model = PlanetStackRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 719 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 720 | |
| 721 | |
| 722 | |
| 723 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 724 | class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 725 | id = serializers.Field() |
| 726 | |
| 727 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 728 | validators = serializers.SerializerMethodField("getValidators") |
| 729 | def getHumanReadableName(self, obj):
|
| 730 | return str(obj) |
| 731 | def getValidators(self, obj): |
| 732 | try: |
| 733 | return obj.getValidators() |
| 734 | except: |
| 735 | return None |
| 736 | class Meta: |
| 737 | model = ControllerPrivilege |
| 738 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 739 | |
| 740 | class ControllerPrivilegeIdSerializer(XOSModelSerializer): |
| 741 | id = serializers.Field() |
| 742 | |
| 743 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 744 | validators = serializers.SerializerMethodField("getValidators") |
| 745 | def getHumanReadableName(self, obj):
|
| 746 | return str(obj)
|
| 747 | def getValidators(self, obj):
|
| 748 | try: |
| 749 | return obj.getValidators() |
| 750 | except: |
| 751 | return None
|
| 752 | class Meta:
|
| 753 | model = ControllerPrivilege |
| 754 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 755 | |
| 756 | |
| 757 | |
| 758 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 759 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 760 | id = serializers.Field() |
| 761 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 762 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 763 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 764 | def getHumanReadableName(self, obj):
|
| 765 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 766 | def getValidators(self, obj): |
| 767 | try: |
| 768 | return obj.getValidators() |
| 769 | except: |
| 770 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 771 | class Meta: |
| 772 | model = NetworkSliver |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 773 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 774 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 775 | class NetworkSliverIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 776 | id = serializers.Field() |
| 777 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 778 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 779 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 780 | def getHumanReadableName(self, obj):
|
| 781 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 782 | def getValidators(self, obj):
|
| 783 | try: |
| 784 | return obj.getValidators() |
| 785 | except: |
| 786 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 787 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 788 | model = NetworkSliver |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 789 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 790 | |
| 791 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 792 | |
| 793 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 794 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 795 | id = serializers.Field() |
| 796 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 797 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 798 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 799 | def getHumanReadableName(self, obj):
|
| 800 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 801 | def getValidators(self, obj): |
| 802 | try: |
| 803 | return obj.getValidators() |
| 804 | except: |
| 805 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 806 | class Meta: |
| 807 | model = Project |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 808 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 809 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 810 | class ProjectIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 811 | id = serializers.Field() |
| 812 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 813 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 814 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 815 | def getHumanReadableName(self, obj):
|
| 816 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 817 | def getValidators(self, obj):
|
| 818 | try: |
| 819 | return obj.getValidators() |
| 820 | except: |
| 821 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 822 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 823 | model = Project |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 824 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 825 | |
| 826 | |
| 827 | |
| 828 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 829 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 830 | id = serializers.Field() |
| 831 | |
| 832 | |
| 833 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 834 | |
| 835 | |
| 836 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 837 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 838 | |
| 839 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 840 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 841 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 842 | def getHumanReadableName(self, obj):
|
| 843 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 844 | def getValidators(self, obj): |
| 845 | try: |
| 846 | return obj.getValidators() |
| 847 | except: |
| 848 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 849 | class Meta: |
| 850 | model = Slice |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 851 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 852 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 853 | class SliceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 854 | id = serializers.Field() |
| 855 | |
| 856 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 857 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 858 | |
| 859 | |
| 860 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 861 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 862 | |
| 863 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 864 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 865 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 866 | def getHumanReadableName(self, obj):
|
| 867 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 868 | def getValidators(self, obj):
|
| 869 | try: |
| 870 | return obj.getValidators() |
| 871 | except: |
| 872 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 873 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 874 | model = Slice |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 875 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 876 | |
| 877 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 878 | |
| 879 | |
| 880 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 881 | id = serializers.Field() |
| 882 | |
| 883 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 884 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 885 | |
| 886 | |
| 887 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 888 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 889 | |
| 890 | |
| 891 | |
| 892 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 893 | |
| 894 | |
| 895 | |
| 896 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 897 | |
| 898 | |
| 899 | |
| 900 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 901 | |
| 902 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 903 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 904 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 905 | def getHumanReadableName(self, obj):
|
| 906 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 907 | def getValidators(self, obj): |
| 908 | try: |
| 909 | return obj.getValidators() |
| 910 | except: |
| 911 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 912 | class Meta: |
| 913 | model = Network |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 914 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 915 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 916 | class NetworkIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 917 | id = serializers.Field() |
| 918 | |
| 919 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 920 | slices = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 921 | |
| 922 | |
| 923 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 924 | slices = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 925 | |
| 926 | |
| 927 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 928 | slivers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='sliver-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 929 | |
| 930 | |
| 931 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 932 | routers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='router-detail') |
| 933 | |
| 934 | |
| 935 | |
| 936 | routers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='router-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 937 | |
| 938 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 939 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 940 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 941 | def getHumanReadableName(self, obj):
|
| 942 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 943 | def getValidators(self, obj):
|
| 944 | try: |
| 945 | return obj.getValidators() |
| 946 | except: |
| 947 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 948 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 949 | model = Network |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 950 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 951 | |
| 952 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 953 | |
| 954 | |
| 955 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 956 | id = serializers.Field() |
| 957 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 958 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 959 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 960 | def getHumanReadableName(self, obj):
|
| 961 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 962 | def getValidators(self, obj): |
| 963 | try: |
| 964 | return obj.getValidators() |
| 965 | except: |
| 966 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 967 | class Meta: |
| 968 | model = Service |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 969 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 970 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 971 | class ServiceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 972 | id = serializers.Field() |
| 973 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 974 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 975 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 976 | def getHumanReadableName(self, obj):
|
| 977 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 978 | def getValidators(self, obj):
|
| 979 | try: |
| 980 | return obj.getValidators() |
| 981 | except: |
| 982 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 983 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 984 | model = Service |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 985 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 986 | |
| 987 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 988 | |
| 989 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 990 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 991 | id = serializers.Field() |
| 992 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 993 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 994 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 995 | def getHumanReadableName(self, obj):
|
| 996 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 997 | def getValidators(self, obj): |
| 998 | try: |
| 999 | return obj.getValidators() |
| 1000 | except: |
| 1001 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1002 | class Meta: |
| 1003 | model = ServiceClass |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1004 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1005 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1006 | class ServiceClassIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1007 | id = serializers.Field() |
| 1008 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1009 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1010 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1011 | def getHumanReadableName(self, obj):
|
| 1012 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1013 | def getValidators(self, obj):
|
| 1014 | try: |
| 1015 | return obj.getValidators() |
| 1016 | except: |
| 1017 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1018 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1019 | model = ServiceClass |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1020 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1021 | |
| 1022 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1023 | |
| 1024 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1025 | class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1026 | id = serializers.Field() |
| 1027 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1028 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1029 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1030 | def getHumanReadableName(self, obj):
|
| 1031 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1032 | def getValidators(self, obj): |
| 1033 | try: |
| 1034 | return obj.getValidators() |
| 1035 | except: |
| 1036 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1037 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1038 | model = ControllerNetworks |
| 1039 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1040 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1041 | class ControllerNetworksIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1042 | id = serializers.Field() |
| 1043 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1044 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1045 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1046 | def getHumanReadableName(self, obj):
|
| 1047 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1048 | def getValidators(self, obj):
|
| 1049 | try: |
| 1050 | return obj.getValidators() |
| 1051 | except: |
| 1052 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1053 | class Meta:
|
| 1054 | model = ControllerNetworks |
| 1055 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1056 | |
| 1057 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1058 | |
| 1059 | |
| 1060 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1061 | id = serializers.Field() |
| 1062 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1063 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1064 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1065 | def getHumanReadableName(self, obj):
|
| 1066 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1067 | def getValidators(self, obj): |
| 1068 | try: |
| 1069 | return obj.getValidators() |
| 1070 | except: |
| 1071 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1072 | class Meta: |
| 1073 | model = Charge |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1074 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1075 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1076 | class ChargeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1077 | id = serializers.Field() |
| 1078 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1079 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1080 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1081 | def getHumanReadableName(self, obj):
|
| 1082 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1083 | def getValidators(self, obj):
|
| 1084 | try: |
| 1085 | return obj.getValidators() |
| 1086 | except: |
| 1087 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1088 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1089 | model = Charge |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1090 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1091 | |
| 1092 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1093 | |
| 1094 | |
| 1095 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1096 | id = serializers.Field() |
| 1097 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1098 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1099 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1100 | def getHumanReadableName(self, obj):
|
| 1101 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1102 | def getValidators(self, obj): |
| 1103 | try: |
| 1104 | return obj.getValidators() |
| 1105 | except: |
| 1106 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1107 | class Meta: |
| 1108 | model = Role |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1109 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1110 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1111 | class RoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1112 | id = serializers.Field() |
| 1113 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1114 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1115 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1116 | def getHumanReadableName(self, obj):
|
| 1117 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1118 | def getValidators(self, obj):
|
| 1119 | try: |
| 1120 | return obj.getValidators() |
| 1121 | except: |
| 1122 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1123 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1124 | model = Role |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1125 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1126 | |
| 1127 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1128 | |
| 1129 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1130 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1131 | id = serializers.Field() |
| 1132 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1133 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1134 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1135 | def getHumanReadableName(self, obj):
|
| 1136 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1137 | def getValidators(self, obj): |
| 1138 | try: |
| 1139 | return obj.getValidators() |
| 1140 | except: |
| 1141 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1142 | class Meta: |
| 1143 | model = UsableObject |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1144 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1145 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1146 | class UsableObjectIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1147 | id = serializers.Field() |
| 1148 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1149 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1150 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1151 | def getHumanReadableName(self, obj):
|
| 1152 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1153 | def getValidators(self, obj):
|
| 1154 | try: |
| 1155 | return obj.getValidators() |
| 1156 | except: |
| 1157 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1158 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1159 | model = UsableObject |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1160 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1161 | |
| 1162 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1163 | |
| 1164 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1165 | class ControllerSiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 1166 | id = serializers.Field() |
| 1167 | |
| 1168 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1169 | validators = serializers.SerializerMethodField("getValidators") |
| 1170 | def getHumanReadableName(self, obj):
|
| 1171 | return str(obj) |
| 1172 | def getValidators(self, obj): |
| 1173 | try: |
| 1174 | return obj.getValidators() |
| 1175 | except: |
| 1176 | return None |
| 1177 | class Meta: |
| 1178 | model = ControllerSiteDeployments |
| 1179 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 1180 | |
| 1181 | class ControllerSiteDeploymentsIdSerializer(XOSModelSerializer): |
| 1182 | id = serializers.Field() |
| 1183 | |
| 1184 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1185 | validators = serializers.SerializerMethodField("getValidators") |
| 1186 | def getHumanReadableName(self, obj):
|
| 1187 | return str(obj)
|
| 1188 | def getValidators(self, obj):
|
| 1189 | try: |
| 1190 | return obj.getValidators() |
| 1191 | except: |
| 1192 | return None
|
| 1193 | class Meta:
|
| 1194 | model = ControllerSiteDeployments |
| 1195 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 1196 | |
| 1197 | |
| 1198 | |
| 1199 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1200 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1201 | id = serializers.Field() |
| 1202 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1203 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1204 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1205 | def getHumanReadableName(self, obj):
|
| 1206 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1207 | def getValidators(self, obj): |
| 1208 | try: |
| 1209 | return obj.getValidators() |
| 1210 | except: |
| 1211 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1212 | class Meta: |
| 1213 | model = SiteRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1214 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1215 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1216 | class SiteRoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1217 | id = serializers.Field() |
| 1218 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1219 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1220 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1221 | def getHumanReadableName(self, obj):
|
| 1222 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1223 | def getValidators(self, obj):
|
| 1224 | try: |
| 1225 | return obj.getValidators() |
| 1226 | except: |
| 1227 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1228 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1229 | model = SiteRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1230 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1231 | |
| 1232 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1233 | |
| 1234 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1235 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1236 | id = serializers.Field() |
| 1237 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1238 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1239 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1240 | def getHumanReadableName(self, obj):
|
| 1241 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1242 | def getValidators(self, obj): |
| 1243 | try: |
| 1244 | return obj.getValidators() |
| 1245 | except: |
| 1246 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1247 | class Meta: |
| 1248 | model = SliceCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1249 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1250 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1251 | class SliceCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1252 | id = serializers.Field() |
| 1253 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1254 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1255 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1256 | def getHumanReadableName(self, obj):
|
| 1257 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1258 | def getValidators(self, obj):
|
| 1259 | try: |
| 1260 | return obj.getValidators() |
| 1261 | except: |
| 1262 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1263 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1264 | model = SliceCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1265 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1266 | |
| 1267 | |
| 1268 | |
| 1269 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1270 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1271 | id = serializers.Field() |
| 1272 | |
| 1273 | |
| 1274 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1275 | |
| 1276 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1277 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1278 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1279 | def getHumanReadableName(self, obj):
|
| 1280 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1281 | def getValidators(self, obj): |
| 1282 | try: |
| 1283 | return obj.getValidators() |
| 1284 | except: |
| 1285 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1286 | class Meta: |
| 1287 | model = Sliver |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1288 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1289 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1290 | class SliverIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1291 | id = serializers.Field() |
| 1292 | |
| 1293 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1294 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1295 | |
| 1296 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1297 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1298 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1299 | def getHumanReadableName(self, obj):
|
| 1300 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1301 | def getValidators(self, obj):
|
| 1302 | try: |
| 1303 | return obj.getValidators() |
| 1304 | except: |
| 1305 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1306 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1307 | model = Sliver |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1308 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1309 | |
| 1310 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1311 | |
| 1312 | |
| 1313 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1314 | id = serializers.Field() |
| 1315 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1316 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1317 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1318 | def getHumanReadableName(self, obj):
|
| 1319 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1320 | def getValidators(self, obj): |
| 1321 | try: |
| 1322 | return obj.getValidators() |
| 1323 | except: |
| 1324 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1325 | class Meta: |
| 1326 | model = Node |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1327 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1328 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1329 | class NodeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1330 | id = serializers.Field() |
| 1331 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1332 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1333 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1334 | def getHumanReadableName(self, obj):
|
| 1335 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1336 | def getValidators(self, obj):
|
| 1337 | try: |
| 1338 | return obj.getValidators() |
| 1339 | except: |
| 1340 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1341 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1342 | model = Node |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1343 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1344 | |
| 1345 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1346 | |
| 1347 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1348 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1349 | id = serializers.Field() |
| 1350 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1351 | |
| 1352 | controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail') |
| 1353 | |
| 1354 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1355 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1356 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1357 | def getHumanReadableName(self, obj):
|
| 1358 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1359 | def getValidators(self, obj): |
| 1360 | try: |
| 1361 | return obj.getValidators() |
| 1362 | except: |
| 1363 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1364 | class Meta: |
| 1365 | model = DashboardView |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1366 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1367 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1368 | class DashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1369 | id = serializers.Field() |
| 1370 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1371 | |
| 1372 | controllers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='controller-detail') |
| 1373 | |
| 1374 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1375 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1376 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1377 | def getHumanReadableName(self, obj):
|
| 1378 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1379 | def getValidators(self, obj):
|
| 1380 | try: |
| 1381 | return obj.getValidators() |
| 1382 | except: |
| 1383 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1384 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1385 | model = DashboardView |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1386 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1387 | |
| 1388 | |
| 1389 | |
| 1390 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1391 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1392 | id = serializers.Field() |
| 1393 | |
| 1394 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1395 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1396 | def getHumanReadableName(self, obj):
|
| 1397 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1398 | def getValidators(self, obj): |
| 1399 | try: |
| 1400 | return obj.getValidators() |
| 1401 | except: |
| 1402 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1403 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1404 | model = ImageDeployments |
| 1405 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1406 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1407 | class ImageDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1408 | id = serializers.Field() |
| 1409 | |
| 1410 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1411 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1412 | def getHumanReadableName(self, obj):
|
| 1413 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1414 | def getValidators(self, obj):
|
| 1415 | try: |
| 1416 | return obj.getValidators() |
| 1417 | except: |
| 1418 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1419 | class Meta:
|
| 1420 | model = ImageDeployments |
| 1421 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1422 | |
| 1423 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1424 | |
| 1425 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1426 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1427 | id = serializers.Field() |
| 1428 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1429 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1430 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1431 | def getHumanReadableName(self, obj):
|
| 1432 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1433 | def getValidators(self, obj): |
| 1434 | try: |
| 1435 | return obj.getValidators() |
| 1436 | except: |
| 1437 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1438 | class Meta: |
| 1439 | model = ReservedResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1440 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1441 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1442 | class ReservedResourceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1443 | id = serializers.Field() |
| 1444 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1445 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1446 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1447 | def getHumanReadableName(self, obj):
|
| 1448 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1449 | def getValidators(self, obj):
|
| 1450 | try: |
| 1451 | return obj.getValidators() |
| 1452 | except: |
| 1453 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1454 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1455 | model = ReservedResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1456 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1457 | |
| 1458 | |
| 1459 | |
| 1460 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1461 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
| 1462 | id = serializers.Field() |
| 1463 | |
| 1464 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1465 | validators = serializers.SerializerMethodField("getValidators") |
| 1466 | def getHumanReadableName(self, obj):
|
| 1467 | return str(obj) |
| 1468 | def getValidators(self, obj): |
| 1469 | try: |
| 1470 | return obj.getValidators() |
| 1471 | except: |
| 1472 | return None |
| 1473 | class Meta: |
| 1474 | model = Payment |
| 1475 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1476 | |
| 1477 | class PaymentIdSerializer(XOSModelSerializer): |
| 1478 | id = serializers.Field() |
| 1479 | |
| 1480 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1481 | validators = serializers.SerializerMethodField("getValidators") |
| 1482 | def getHumanReadableName(self, obj):
|
| 1483 | return str(obj)
|
| 1484 | def getValidators(self, obj):
|
| 1485 | try: |
| 1486 | return obj.getValidators() |
| 1487 | except: |
| 1488 | return None
|
| 1489 | class Meta:
|
| 1490 | model = Payment |
| 1491 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1492 | |
| 1493 | |
| 1494 | |
| 1495 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1496 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1497 | id = serializers.Field() |
| 1498 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1499 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1500 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1501 | def getHumanReadableName(self, obj):
|
| 1502 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1503 | def getValidators(self, obj): |
| 1504 | try: |
| 1505 | return obj.getValidators() |
| 1506 | except: |
| 1507 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1508 | class Meta: |
| 1509 | model = NetworkSlice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1510 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1511 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1512 | class NetworkSliceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1513 | id = serializers.Field() |
| 1514 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1515 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1516 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1517 | def getHumanReadableName(self, obj):
|
| 1518 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1519 | def getValidators(self, obj):
|
| 1520 | try: |
| 1521 | return obj.getValidators() |
| 1522 | except: |
| 1523 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1524 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1525 | model = NetworkSlice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1526 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1527 | |
| 1528 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1529 | |
| 1530 | |
| 1531 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1532 | id = serializers.Field() |
| 1533 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1534 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1535 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1536 | def getHumanReadableName(self, obj):
|
| 1537 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1538 | def getValidators(self, obj): |
| 1539 | try: |
| 1540 | return obj.getValidators() |
| 1541 | except: |
| 1542 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1543 | class Meta: |
| 1544 | model = UserDashboardView |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1545 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1546 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1547 | class UserDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1548 | id = serializers.Field() |
| 1549 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1550 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1551 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1552 | def getHumanReadableName(self, obj):
|
| 1553 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1554 | def getValidators(self, obj):
|
| 1555 | try: |
| 1556 | return obj.getValidators() |
| 1557 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1558 | return None
|
| 1559 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1560 | model = UserDashboardView |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1561 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1562 | |
| 1563 | |
| 1564 | |
| 1565 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1566 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1567 | id = serializers.Field() |
| 1568 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1569 | |
| 1570 | dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail') |
| 1571 | |
| 1572 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1573 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1574 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1575 | def getHumanReadableName(self, obj):
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1576 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1577 | def getValidators(self, obj): |
| 1578 | try: |
| 1579 | return obj.getValidators() |
| 1580 | except: |
| 1581 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1582 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1583 | model = Controller |
| 1584 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1585 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1586 | class ControllerIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1587 | id = serializers.Field() |
| 1588 | |
| 1589 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1590 | dashboardviews = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='dashboardview-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1591 | |
| 1592 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1593 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1594 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1595 | def getHumanReadableName(self, obj):
|
| 1596 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1597 | def getValidators(self, obj):
|
| 1598 | try: |
| 1599 | return obj.getValidators() |
| 1600 | except: |
| 1601 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1602 | class Meta:
|
| 1603 | model = Controller |
| 1604 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 1605 | |
| 1606 | |
| 1607 | |
| 1608 | |
| 1609 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 1610 | id = serializers.Field() |
| 1611 | |
| 1612 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1613 | validators = serializers.SerializerMethodField("getValidators") |
| 1614 | def getHumanReadableName(self, obj):
|
| 1615 | return str(obj) |
| 1616 | def getValidators(self, obj): |
| 1617 | try: |
| 1618 | return obj.getValidators() |
| 1619 | except: |
| 1620 | return None |
| 1621 | class Meta: |
| 1622 | model = PlanetStackPrivilege |
| 1623 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1624 | |
| 1625 | class PlanetStackPrivilegeIdSerializer(XOSModelSerializer): |
| 1626 | id = serializers.Field() |
| 1627 | |
| 1628 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1629 | validators = serializers.SerializerMethodField("getValidators") |
| 1630 | def getHumanReadableName(self, obj):
|
| 1631 | return str(obj)
|
| 1632 | def getValidators(self, obj):
|
| 1633 | try: |
| 1634 | return obj.getValidators() |
| 1635 | except: |
| 1636 | return None
|
| 1637 | class Meta:
|
| 1638 | model = PlanetStackPrivilege |
| 1639 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1640 | |
| 1641 | |
| 1642 | |
| 1643 | |
| 1644 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
| 1645 | id = serializers.Field() |
| 1646 | |
| 1647 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1648 | validators = serializers.SerializerMethodField("getValidators") |
| 1649 | def getHumanReadableName(self, obj):
|
| 1650 | return str(obj) |
| 1651 | def getValidators(self, obj): |
| 1652 | try: |
| 1653 | return obj.getValidators() |
| 1654 | except: |
| 1655 | return None |
| 1656 | class Meta: |
| 1657 | model = User |
| 1658 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',) |
| 1659 | |
| 1660 | class UserIdSerializer(XOSModelSerializer): |
| 1661 | id = serializers.Field() |
| 1662 | |
| 1663 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1664 | validators = serializers.SerializerMethodField("getValidators") |
| 1665 | def getHumanReadableName(self, obj):
|
| 1666 | return str(obj)
|
| 1667 | def getValidators(self, obj):
|
| 1668 | try: |
| 1669 | return obj.getValidators() |
| 1670 | except: |
| 1671 | return None
|
| 1672 | class Meta:
|
| 1673 | model = User |
| 1674 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',) |
| 1675 | |
| 1676 | |
| 1677 | |
| 1678 | |
| 1679 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
| 1680 | id = serializers.Field() |
| 1681 | |
| 1682 | |
| 1683 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1684 | |
| 1685 | |
| 1686 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1687 | images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail') |
| 1688 | |
| 1689 | |
| 1690 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1691 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1692 | |
| 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 |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1703 | class Meta: |
| 1704 | model = Deployment |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1705 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1706 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1707 | class DeploymentIdSerializer(XOSModelSerializer): |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1708 | id = serializers.Field() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1709 | |
| 1710 | |
| 1711 | flavors = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='flavor-detail') |
| 1712 | |
| 1713 | |
| 1714 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1715 | images = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='image-detail') |
| 1716 | |
| 1717 | |
| 1718 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1719 | sites = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='site-detail') |
| 1720 | |
| 1721 | |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1722 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1723 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1724 | def getHumanReadableName(self, obj):
|
| 1725 | return str(obj)
|
| 1726 | def getValidators(self, obj):
|
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1727 | try: |
| 1728 | return obj.getValidators() |
| 1729 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1730 | return None
|
| 1731 | class Meta:
|
| 1732 | model = Deployment |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1733 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',) |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1734 | |
| 1735 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1736 | |
| 1737 | |
| 1738 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1739 | id = serializers.Field() |
| 1740 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1741 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1742 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1743 | def getHumanReadableName(self, obj):
|
| 1744 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1745 | def getValidators(self, obj): |
| 1746 | try: |
| 1747 | return obj.getValidators() |
| 1748 | except: |
| 1749 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1750 | class Meta: |
| 1751 | model = Reservation |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1752 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1753 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1754 | class ReservationIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1755 | id = serializers.Field() |
| 1756 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1757 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1758 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1759 | def getHumanReadableName(self, obj):
|
| 1760 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1761 | def getValidators(self, obj):
|
| 1762 | try: |
| 1763 | return obj.getValidators() |
| 1764 | except: |
| 1765 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1766 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1767 | model = Reservation |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1768 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1769 | |
| 1770 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1771 | |
| 1772 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1773 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 1774 | id = serializers.Field() |
| 1775 | |
| 1776 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1777 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1778 | def getHumanReadableName(self, obj):
|
| 1779 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1780 | def getValidators(self, obj): |
| 1781 | try: |
| 1782 | return obj.getValidators() |
| 1783 | except: |
| 1784 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1785 | class Meta: |
| 1786 | model = SitePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1787 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1788 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1789 | class SitePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1790 | id = serializers.Field() |
| 1791 | |
| 1792 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1793 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1794 | def getHumanReadableName(self, obj):
|
| 1795 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1796 | def getValidators(self, obj):
|
| 1797 | try: |
| 1798 | return obj.getValidators() |
| 1799 | except: |
| 1800 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1801 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1802 | model = SitePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1803 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1804 | |
| 1805 | |
| 1806 | |
| 1807 | |
| 1808 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
| 1809 | id = serializers.Field() |
| 1810 | |
| 1811 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1812 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1813 | def getHumanReadableName(self, obj):
|
| 1814 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1815 | def getValidators(self, obj): |
| 1816 | try: |
| 1817 | return obj.getValidators() |
| 1818 | except: |
| 1819 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1820 | class Meta: |
| 1821 | model = PlanetStack |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1822 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1823 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1824 | class PlanetStackIdSerializer(XOSModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1825 | id = serializers.Field() |
| 1826 | |
| 1827 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1828 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1829 | def getHumanReadableName(self, obj):
|
| 1830 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1831 | def getValidators(self, obj):
|
| 1832 | try: |
| 1833 | return obj.getValidators() |
| 1834 | except: |
| 1835 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1836 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1837 | model = PlanetStack |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1838 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1839 | |
| 1840 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1841 | |
| 1842 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1843 | class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
| 1844 | id = serializers.Field() |
| 1845 | |
| 1846 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1847 | validators = serializers.SerializerMethodField("getValidators") |
| 1848 | def getHumanReadableName(self, obj):
|
| 1849 | return str(obj) |
| 1850 | def getValidators(self, obj): |
| 1851 | try: |
| 1852 | return obj.getValidators() |
| 1853 | except: |
| 1854 | return None |
| 1855 | class Meta: |
| 1856 | model = ControllerDashboardView |
| 1857 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1858 | |
| 1859 | class ControllerDashboardViewIdSerializer(XOSModelSerializer): |
| 1860 | id = serializers.Field() |
| 1861 | |
| 1862 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1863 | validators = serializers.SerializerMethodField("getValidators") |
| 1864 | def getHumanReadableName(self, obj):
|
| 1865 | return str(obj)
|
| 1866 | def getValidators(self, obj):
|
| 1867 | try: |
| 1868 | return obj.getValidators() |
| 1869 | except: |
| 1870 | return None
|
| 1871 | class Meta:
|
| 1872 | model = ControllerDashboardView |
| 1873 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1874 | |
| 1875 | |
| 1876 | |
| 1877 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1878 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1879 | id = serializers.Field() |
| 1880 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1881 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1882 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1883 | def getHumanReadableName(self, obj):
|
| 1884 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1885 | def getValidators(self, obj): |
| 1886 | try: |
| 1887 | return obj.getValidators() |
| 1888 | except: |
| 1889 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1890 | class Meta: |
| 1891 | model = Account |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1892 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1893 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1894 | class AccountIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1895 | id = serializers.Field() |
| 1896 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1897 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1898 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1899 | def getHumanReadableName(self, obj):
|
| 1900 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1901 | def getValidators(self, obj):
|
| 1902 | try: |
| 1903 | return obj.getValidators() |
| 1904 | except: |
| 1905 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1906 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1907 | model = Account |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1908 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1909 | |
| 1910 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1911 | |
| 1912 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1913 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
| 1914 | id = serializers.Field() |
| 1915 | |
| 1916 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1917 | validators = serializers.SerializerMethodField("getValidators") |
| 1918 | def getHumanReadableName(self, obj):
|
| 1919 | return str(obj) |
| 1920 | def getValidators(self, obj): |
| 1921 | try: |
| 1922 | return obj.getValidators() |
| 1923 | except: |
| 1924 | return None |
| 1925 | class Meta: |
| 1926 | model = ControllerRole |
| 1927 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1928 | |
| 1929 | class ControllerRoleIdSerializer(XOSModelSerializer): |
| 1930 | id = serializers.Field() |
| 1931 | |
| 1932 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1933 | validators = serializers.SerializerMethodField("getValidators") |
| 1934 | def getHumanReadableName(self, obj):
|
| 1935 | return str(obj)
|
| 1936 | def getValidators(self, obj):
|
| 1937 | try: |
| 1938 | return obj.getValidators() |
| 1939 | except: |
| 1940 | return None
|
| 1941 | class Meta:
|
| 1942 | model = ControllerRole |
| 1943 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1944 | |
| 1945 | |
| 1946 | |
| 1947 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1948 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1949 | id = serializers.Field() |
| 1950 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1951 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1952 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1953 | def getHumanReadableName(self, obj):
|
| 1954 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1955 | def getValidators(self, obj): |
| 1956 | try: |
| 1957 | return obj.getValidators() |
| 1958 | except: |
| 1959 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1960 | class Meta: |
| 1961 | model = NetworkParameterType |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1962 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1963 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1964 | class NetworkParameterTypeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1965 | id = serializers.Field() |
| 1966 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1967 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1968 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1969 | def getHumanReadableName(self, obj):
|
| 1970 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1971 | def getValidators(self, obj):
|
| 1972 | try: |
| 1973 | return obj.getValidators() |
| 1974 | except: |
| 1975 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1976 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1977 | model = NetworkParameterType |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1978 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1979 | |
| 1980 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1981 | |
| 1982 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1983 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1984 | id = serializers.Field() |
| 1985 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1986 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1987 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1988 | def getHumanReadableName(self, obj):
|
| 1989 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1990 | def getValidators(self, obj): |
| 1991 | try: |
| 1992 | return obj.getValidators() |
| 1993 | except: |
| 1994 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1995 | class Meta: |
| 1996 | model = SiteCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1997 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1998 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1999 | class SiteCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2000 | id = serializers.Field() |
| 2001 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2002 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2003 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2004 | def getHumanReadableName(self, obj):
|
| 2005 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2006 | def getValidators(self, obj):
|
| 2007 | try: |
| 2008 | return obj.getValidators() |
| 2009 | except: |
| 2010 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2011 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2012 | model = SiteCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2013 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2014 | |
| 2015 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2016 | |
| 2017 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2018 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2019 | id = serializers.Field() |
| 2020 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2021 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2022 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2023 | def getHumanReadableName(self, obj):
|
| 2024 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2025 | def getValidators(self, obj): |
| 2026 | try: |
| 2027 | return obj.getValidators() |
| 2028 | except: |
| 2029 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2030 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2031 | model = DeploymentPrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2032 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2033 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2034 | class DeploymentPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2035 | id = serializers.Field() |
| 2036 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2037 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2038 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2039 | def getHumanReadableName(self, obj):
|
| 2040 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2041 | def getValidators(self, obj):
|
| 2042 | try: |
| 2043 | return obj.getValidators() |
| 2044 | except: |
| 2045 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2046 | class Meta:
|
| 2047 | model = DeploymentPrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2048 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2049 | |
| 2050 | |
| 2051 | |
| 2052 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2053 | class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2054 | id = serializers.Field() |
| 2055 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2056 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2057 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2058 | def getHumanReadableName(self, obj):
|
| 2059 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2060 | def getValidators(self, obj): |
| 2061 | try: |
| 2062 | return obj.getValidators() |
| 2063 | except: |
| 2064 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2065 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2066 | model = ControllerUsers |
| 2067 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2068 | |
| 2069 | class ControllerUsersIdSerializer(XOSModelSerializer): |
| 2070 | id = serializers.Field() |
| 2071 | |
| 2072 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2073 | validators = serializers.SerializerMethodField("getValidators") |
| 2074 | def getHumanReadableName(self, obj):
|
| 2075 | return str(obj)
|
| 2076 | def getValidators(self, obj):
|
| 2077 | try: |
| 2078 | return obj.getValidators() |
| 2079 | except: |
| 2080 | return None
|
| 2081 | class Meta:
|
| 2082 | model = ControllerUsers |
| 2083 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2084 | |
| 2085 | |
| 2086 | |
| 2087 | |
| 2088 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
| 2089 | id = serializers.Field() |
| 2090 | |
| 2091 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2092 | validators = serializers.SerializerMethodField("getValidators") |
| 2093 | def getHumanReadableName(self, obj):
|
| 2094 | return str(obj) |
| 2095 | def getValidators(self, obj): |
| 2096 | try: |
| 2097 | return obj.getValidators() |
| 2098 | except: |
| 2099 | return None |
| 2100 | class Meta: |
| 2101 | model = DeploymentRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2102 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2103 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2104 | class DeploymentRoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2105 | id = serializers.Field() |
| 2106 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2107 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2108 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2109 | def getHumanReadableName(self, obj):
|
| 2110 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2111 | def getValidators(self, obj):
|
| 2112 | try: |
| 2113 | return obj.getValidators() |
| 2114 | except: |
| 2115 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2116 | class Meta:
|
| 2117 | model = DeploymentRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2118 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2119 | |
| 2120 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2121 | |
| 2122 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2123 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2124 | id = serializers.Field() |
| 2125 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2126 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2127 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2128 | def getHumanReadableName(self, obj):
|
| 2129 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2130 | def getValidators(self, obj): |
| 2131 | try: |
| 2132 | return obj.getValidators() |
| 2133 | except: |
| 2134 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2135 | class Meta: |
| 2136 | model = UserCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2137 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2138 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2139 | class UserCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2140 | id = serializers.Field() |
| 2141 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2142 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2143 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2144 | def getHumanReadableName(self, obj):
|
| 2145 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2146 | def getValidators(self, obj):
|
| 2147 | try: |
| 2148 | return obj.getValidators() |
| 2149 | except: |
| 2150 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2151 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2152 | model = UserCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2153 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2154 | |
| 2155 | |
| 2156 | |
| 2157 | |
| 2158 | class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 2159 | id = serializers.Field() |
| 2160 | |
| 2161 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2162 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2163 | def getHumanReadableName(self, obj):
|
| 2164 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2165 | def getValidators(self, obj): |
| 2166 | try: |
| 2167 | return obj.getValidators() |
| 2168 | except: |
| 2169 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2170 | class Meta: |
| 2171 | model = SiteDeployments |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2172 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2173 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2174 | class SiteDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2175 | id = serializers.Field() |
| 2176 | |
| 2177 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2178 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2179 | def getHumanReadableName(self, obj):
|
| 2180 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2181 | def getValidators(self, obj):
|
| 2182 | try: |
| 2183 | return obj.getValidators() |
| 2184 | except: |
| 2185 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2186 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2187 | model = SiteDeployments |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2188 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
| 2189 | |
| 2190 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2191 | |
| 2192 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2193 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2194 | id = serializers.Field() |
| 2195 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2196 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2197 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2198 | def getHumanReadableName(self, obj):
|
| 2199 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2200 | def getValidators(self, obj): |
| 2201 | try: |
| 2202 | return obj.getValidators() |
| 2203 | except: |
| 2204 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2205 | class Meta: |
| 2206 | model = SliceTag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2207 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2208 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2209 | class SliceTagIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2210 | id = serializers.Field() |
| 2211 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2212 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2213 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2214 | def getHumanReadableName(self, obj):
|
| 2215 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2216 | def getValidators(self, obj):
|
| 2217 | try: |
| 2218 | return obj.getValidators() |
| 2219 | except: |
| 2220 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2221 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2222 | model = SliceTag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2223 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2224 | |
| 2225 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2226 | |
| 2227 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2228 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2229 | id = serializers.Field() |
| 2230 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2231 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2232 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2233 | def getHumanReadableName(self, obj):
|
| 2234 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2235 | def getValidators(self, obj): |
| 2236 | try: |
| 2237 | return obj.getValidators() |
| 2238 | except: |
| 2239 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2240 | class Meta: |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2241 | model = NetworkTemplate |
| 2242 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2243 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2244 | class NetworkTemplateIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2245 | id = serializers.Field() |
| 2246 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2247 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2248 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2249 | def getHumanReadableName(self, obj):
|
| 2250 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2251 | def getValidators(self, obj):
|
| 2252 | try: |
| 2253 | return obj.getValidators() |
| 2254 | except: |
| 2255 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2256 | class Meta:
|
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2257 | model = NetworkTemplate |
| 2258 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2259 | |
| 2260 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2261 | |
| 2262 | |
| 2263 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2264 | id = serializers.Field() |
| 2265 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2266 | |
| 2267 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2268 | |
| 2269 | |
| 2270 | |
| 2271 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2272 | |
| 2273 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2274 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2275 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2276 | def getHumanReadableName(self, obj):
|
| 2277 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2278 | def getValidators(self, obj): |
| 2279 | try: |
| 2280 | return obj.getValidators() |
| 2281 | except: |
| 2282 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2283 | class Meta: |
| 2284 | model = Router |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2285 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2286 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2287 | class RouterIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2288 | id = serializers.Field() |
| 2289 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2290 | |
| 2291 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
| 2292 | |
| 2293 | |
| 2294 | |
| 2295 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
| 2296 | |
| 2297 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2298 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2299 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2300 | def getHumanReadableName(self, obj):
|
| 2301 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2302 | def getValidators(self, obj):
|
| 2303 | try: |
| 2304 | return obj.getValidators() |
| 2305 | except: |
| 2306 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2307 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2308 | model = Router |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2309 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2310 | |
| 2311 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2312 | |
| 2313 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2314 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2315 | id = serializers.Field() |
| 2316 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2317 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2318 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2319 | def getHumanReadableName(self, obj):
|
| 2320 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2321 | def getValidators(self, obj): |
| 2322 | try: |
| 2323 | return obj.getValidators() |
| 2324 | except: |
| 2325 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2326 | class Meta: |
| 2327 | model = ServiceResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2328 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2329 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2330 | class ServiceResourceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2331 | id = serializers.Field() |
| 2332 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2333 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2334 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2335 | def getHumanReadableName(self, obj):
|
| 2336 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2337 | def getValidators(self, obj):
|
| 2338 | try: |
| 2339 | return obj.getValidators() |
| 2340 | except: |
| 2341 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2342 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2343 | model = ServiceResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2344 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2345 | |
| 2346 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2347 | |
| 2348 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2349 | class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer): |
| 2350 | id = serializers.Field() |
| 2351 | |
| 2352 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2353 | validators = serializers.SerializerMethodField("getValidators") |
| 2354 | def getHumanReadableName(self, obj):
|
| 2355 | return str(obj) |
| 2356 | def getValidators(self, obj): |
| 2357 | try: |
| 2358 | return obj.getValidators() |
| 2359 | except: |
| 2360 | return None |
| 2361 | class Meta: |
| 2362 | model = ControllerSlices |
| 2363 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2364 | |
| 2365 | class ControllerSlicesIdSerializer(XOSModelSerializer): |
| 2366 | id = serializers.Field() |
| 2367 | |
| 2368 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2369 | validators = serializers.SerializerMethodField("getValidators") |
| 2370 | def getHumanReadableName(self, obj):
|
| 2371 | return str(obj)
|
| 2372 | def getValidators(self, obj):
|
| 2373 | try: |
| 2374 | return obj.getValidators() |
| 2375 | except: |
| 2376 | return None
|
| 2377 | class Meta:
|
| 2378 | model = ControllerSlices |
| 2379 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2380 | |
| 2381 | |
| 2382 | |
| 2383 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2384 | serializerLookUp = { |
| 2385 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2386 | Flavor: FlavorSerializer, |
| 2387 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2388 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2389 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2390 | ControllerImages: ControllerImagesSerializer, |
| 2391 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2392 | Image: ImageSerializer, |
| 2393 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2394 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2395 | |
| 2396 | Site: SiteSerializer, |
| 2397 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2398 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2399 | |
| 2400 | Tag: TagSerializer, |
| 2401 | |
| 2402 | Invoice: InvoiceSerializer, |
| 2403 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2404 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2405 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2406 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2407 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2408 | ControllerPrivilege: ControllerPrivilegeSerializer, |
| 2409 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2410 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2411 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2412 | Project: ProjectSerializer, |
| 2413 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2414 | Slice: SliceSerializer, |
| 2415 | |
| 2416 | Network: NetworkSerializer, |
| 2417 | |
| 2418 | Service: ServiceSerializer, |
| 2419 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2420 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2421 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2422 | ControllerNetworks: ControllerNetworksSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2423 | |
| 2424 | Charge: ChargeSerializer, |
| 2425 | |
| 2426 | Role: RoleSerializer, |
| 2427 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2428 | UsableObject: UsableObjectSerializer, |
| 2429 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2430 | ControllerSiteDeployments: ControllerSiteDeploymentsSerializer, |
| 2431 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2432 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2433 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2434 | SliceCredential: SliceCredentialSerializer, |
| 2435 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2436 | Sliver: SliverSerializer, |
| 2437 | |
| 2438 | Node: NodeSerializer, |
| 2439 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2440 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2441 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2442 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2443 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2444 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2445 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2446 | Payment: PaymentSerializer, |
| 2447 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2448 | NetworkSlice: NetworkSliceSerializer, |
| 2449 | |
| 2450 | UserDashboardView: UserDashboardViewSerializer, |
| 2451 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2452 | Controller: ControllerSerializer, |
| 2453 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2454 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2455 | |
| 2456 | User: UserSerializer, |
| 2457 | |
| 2458 | Deployment: DeploymentSerializer, |
| 2459 | |
| 2460 | Reservation: ReservationSerializer, |
| 2461 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2462 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2463 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2464 | PlanetStack: PlanetStackSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2465 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2466 | ControllerDashboardView: ControllerDashboardViewSerializer, |
| 2467 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2468 | Account: AccountSerializer, |
| 2469 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2470 | ControllerRole: ControllerRoleSerializer, |
| 2471 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2472 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2473 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2474 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2475 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2476 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2477 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2478 | ControllerUsers: ControllerUsersSerializer, |
| 2479 | |
| 2480 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2481 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2482 | UserCredential: UserCredentialSerializer, |
| 2483 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2484 | SiteDeployments: SiteDeploymentsSerializer, |
| 2485 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2486 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2487 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2488 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2489 | |
| 2490 | Router: RouterSerializer, |
| 2491 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2492 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2493 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2494 | ControllerSlices: ControllerSlicesSerializer, |
| 2495 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2496 | None: None, |
| 2497 | } |
| 2498 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2499 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2500 | |
| 2501 | # To handle fine-grained field permissions, we have to check can_update |
| 2502 | # the object has been updated but before it has been saved. |
| 2503 | |
| 2504 | def update(self, request, *args, **kwargs):
|
| 2505 | partial = kwargs.pop('partial', False)
|
| 2506 | self.object = self.get_object_or_none()
|
| 2507 |
|
| 2508 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2509 | files=request.FILES, partial=partial)
|
| 2510 |
|
| 2511 | if not serializer.is_valid():
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2512 | response = {"error": "validation",
|
| 2513 | "specific_error": "not serializer.is_valid()",
|
| 2514 | "reasons": serializer.errors}
|
| 2515 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2516 |
|
| 2517 | try:
|
| 2518 | self.pre_save(serializer.object)
|
| 2519 | except ValidationError as err:
|
| 2520 | # full_clean on model instance may be called in pre_save,
|
| 2521 | # so we have to handle eventual errors.
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2522 | response = {"error": "validation",
|
| 2523 | "specific_error": "ValidationError in pre_save",
|
| 2524 | "reasons": err.message_dict}
|
| 2525 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2526 |
|
| 2527 | if serializer.object is not None:
|
| 2528 | if not serializer.object.can_update(request.user):
|
| 2529 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2530 |
|
| 2531 | if self.object is None:
|
| 2532 | self.object = serializer.save(force_insert=True)
|
| 2533 | self.post_save(self.object, created=True)
|
| 2534 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2535 |
|
| 2536 | self.object = serializer.save(force_update=True)
|
| 2537 | self.post_save(self.object, created=False)
|
| 2538 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2539 | |
| 2540 | def destroy(self, request, *args, **kwargs): |
| 2541 | obj = self.get_object() |
| 2542 | if obj.can_update(request.user): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2543 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2544 | else: |
| 2545 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2546 | |
| 2547 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2548 | # Based on core/views/*.py |
| 2549 | |
| 2550 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2551 | class FlavorList(generics.ListCreateAPIView): |
| 2552 | queryset = Flavor.objects.select_related().all() |
| 2553 | serializer_class = FlavorSerializer |
| 2554 | id_serializer_class = FlavorIdSerializer |
| 2555 | filter_backends = (filters.DjangoFilterBackend,) |
| 2556 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 2557 | |
| 2558 | def get_serializer_class(self): |
| 2559 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2560 | if (no_hyperlinks): |
| 2561 | return self.id_serializer_class |
| 2562 | else: |
| 2563 | return self.serializer_class |
| 2564 | |
| 2565 | def get_queryset(self): |
| 2566 | return Flavor.select_by_user(self.request.user) |
| 2567 | |
| 2568 | def create(self, request, *args, **kwargs): |
| 2569 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2570 | if not (serializer.is_valid()): |
| 2571 | response = {"error": "validation", |
| 2572 | "specific_error": "not serializer.is_valid()",
|
| 2573 | "reasons": serializer.errors}
|
| 2574 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2575 | obj = serializer.object |
| 2576 | obj.caller = request.user |
| 2577 | if obj.can_update(request.user): |
| 2578 | return super(FlavorList, self).create(request, *args, **kwargs) |
| 2579 | else: |
| 2580 | raise Exception("failed obj.can_update") |
| 2581 | |
| 2582 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 2583 | if (ret.status_code%100 != 200): |
| 2584 | raise Exception(ret.data) |
| 2585 | |
| 2586 | return ret |
| 2587 | |
| 2588 | |
| 2589 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2590 | queryset = Flavor.objects.select_related().all() |
| 2591 | serializer_class = FlavorSerializer |
| 2592 | id_serializer_class = FlavorIdSerializer |
| 2593 | |
| 2594 | def get_serializer_class(self): |
| 2595 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2596 | if (no_hyperlinks): |
| 2597 | return self.id_serializer_class |
| 2598 | else: |
| 2599 | return self.serializer_class |
| 2600 | |
| 2601 | def get_queryset(self): |
| 2602 | return Flavor.select_by_user(self.request.user) |
| 2603 | |
| 2604 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2605 | |
| 2606 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2607 | |
| 2608 | |
| 2609 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2610 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 2611 | queryset = ServiceAttribute.objects.select_related().all() |
| 2612 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2613 | id_serializer_class = ServiceAttributeIdSerializer |
| 2614 | filter_backends = (filters.DjangoFilterBackend,) |
| 2615 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 2616 | |
| 2617 | def get_serializer_class(self): |
| 2618 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2619 | if (no_hyperlinks): |
| 2620 | return self.id_serializer_class |
| 2621 | else: |
| 2622 | return self.serializer_class |
| 2623 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2624 | def get_queryset(self): |
| 2625 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2626 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2627 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2628 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2629 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2630 | response = {"error": "validation", |
| 2631 | "specific_error": "not serializer.is_valid()",
|
| 2632 | "reasons": serializer.errors}
|
| 2633 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2634 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2635 | obj.caller = request.user |
| 2636 | if obj.can_update(request.user): |
| 2637 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2638 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2639 | raise Exception("failed obj.can_update") |
| 2640 | |
| 2641 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2642 | if (ret.status_code%100 != 200): |
| 2643 | raise Exception(ret.data) |
| 2644 | |
| 2645 | return ret |
| 2646 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2647 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2648 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2649 | queryset = ServiceAttribute.objects.select_related().all() |
| 2650 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2651 | id_serializer_class = ServiceAttributeIdSerializer |
| 2652 | |
| 2653 | def get_serializer_class(self): |
| 2654 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2655 | if (no_hyperlinks): |
| 2656 | return self.id_serializer_class |
| 2657 | else: |
| 2658 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2659 | |
| 2660 | def get_queryset(self): |
| 2661 | return ServiceAttribute.select_by_user(self.request.user) |
| 2662 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2663 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2664 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2665 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2666 | |
| 2667 | |
| 2668 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2669 | class ControllerImagesList(generics.ListCreateAPIView): |
| 2670 | queryset = ControllerImages.objects.select_related().all() |
| 2671 | serializer_class = ControllerImagesSerializer |
| 2672 | id_serializer_class = ControllerImagesIdSerializer |
| 2673 | filter_backends = (filters.DjangoFilterBackend,) |
| 2674 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 2675 | |
| 2676 | def get_serializer_class(self): |
| 2677 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2678 | if (no_hyperlinks): |
| 2679 | return self.id_serializer_class |
| 2680 | else: |
| 2681 | return self.serializer_class |
| 2682 | |
| 2683 | def get_queryset(self): |
| 2684 | return ControllerImages.select_by_user(self.request.user) |
| 2685 | |
| 2686 | def create(self, request, *args, **kwargs): |
| 2687 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2688 | if not (serializer.is_valid()): |
| 2689 | response = {"error": "validation", |
| 2690 | "specific_error": "not serializer.is_valid()",
|
| 2691 | "reasons": serializer.errors}
|
| 2692 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2693 | obj = serializer.object |
| 2694 | obj.caller = request.user |
| 2695 | if obj.can_update(request.user): |
| 2696 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2697 | else: |
| 2698 | raise Exception("failed obj.can_update") |
| 2699 | |
| 2700 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2701 | if (ret.status_code%100 != 200): |
| 2702 | raise Exception(ret.data) |
| 2703 | |
| 2704 | return ret |
| 2705 | |
| 2706 | |
| 2707 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2708 | queryset = ControllerImages.objects.select_related().all() |
| 2709 | serializer_class = ControllerImagesSerializer |
| 2710 | id_serializer_class = ControllerImagesIdSerializer |
| 2711 | |
| 2712 | def get_serializer_class(self): |
| 2713 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2714 | if (no_hyperlinks): |
| 2715 | return self.id_serializer_class |
| 2716 | else: |
| 2717 | return self.serializer_class |
| 2718 | |
| 2719 | def get_queryset(self): |
| 2720 | return ControllerImages.select_by_user(self.request.user) |
| 2721 | |
| 2722 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2723 | |
| 2724 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2725 | |
| 2726 | |
| 2727 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2728 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2729 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2730 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2731 | id_serializer_class = ImageIdSerializer |
| 2732 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 2733 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2734 | |
| 2735 | def get_serializer_class(self): |
| 2736 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2737 | if (no_hyperlinks): |
| 2738 | return self.id_serializer_class |
| 2739 | else: |
| 2740 | return self.serializer_class |
| 2741 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2742 | def get_queryset(self): |
| 2743 | return Image.select_by_user(self.request.user) |
| 2744 | |
| 2745 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2746 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2747 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2748 | response = {"error": "validation", |
| 2749 | "specific_error": "not serializer.is_valid()",
|
| 2750 | "reasons": serializer.errors}
|
| 2751 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2752 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2753 | obj.caller = request.user |
| 2754 | if obj.can_update(request.user): |
| 2755 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2756 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2757 | raise Exception("failed obj.can_update") |
| 2758 | |
| 2759 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2760 | if (ret.status_code%100 != 200): |
| 2761 | raise Exception(ret.data) |
| 2762 | |
| 2763 | return ret |
| 2764 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2765 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2766 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2767 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2768 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2769 | id_serializer_class = ImageIdSerializer |
| 2770 | |
| 2771 | def get_serializer_class(self): |
| 2772 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2773 | if (no_hyperlinks): |
| 2774 | return self.id_serializer_class |
| 2775 | else: |
| 2776 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2777 | |
| 2778 | def get_queryset(self): |
| 2779 | return Image.select_by_user(self.request.user) |
| 2780 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2781 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2782 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2783 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2784 | |
| 2785 | |
| 2786 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2787 | class NetworkParameterList(generics.ListCreateAPIView): |
| 2788 | queryset = NetworkParameter.objects.select_related().all() |
| 2789 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2790 | id_serializer_class = NetworkParameterIdSerializer |
| 2791 | filter_backends = (filters.DjangoFilterBackend,) |
| 2792 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 2793 | |
| 2794 | def get_serializer_class(self): |
| 2795 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2796 | if (no_hyperlinks): |
| 2797 | return self.id_serializer_class |
| 2798 | else: |
| 2799 | return self.serializer_class |
| 2800 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2801 | def get_queryset(self): |
| 2802 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2803 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2804 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2805 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2806 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2807 | response = {"error": "validation", |
| 2808 | "specific_error": "not serializer.is_valid()",
|
| 2809 | "reasons": serializer.errors}
|
| 2810 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2811 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2812 | obj.caller = request.user |
| 2813 | if obj.can_update(request.user): |
| 2814 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2815 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2816 | raise Exception("failed obj.can_update") |
| 2817 | |
| 2818 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2819 | if (ret.status_code%100 != 200): |
| 2820 | raise Exception(ret.data) |
| 2821 | |
| 2822 | return ret |
| 2823 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2824 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2825 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2826 | queryset = NetworkParameter.objects.select_related().all() |
| 2827 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2828 | id_serializer_class = NetworkParameterIdSerializer |
| 2829 | |
| 2830 | def get_serializer_class(self): |
| 2831 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2832 | if (no_hyperlinks): |
| 2833 | return self.id_serializer_class |
| 2834 | else: |
| 2835 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2836 | |
| 2837 | def get_queryset(self): |
| 2838 | return NetworkParameter.select_by_user(self.request.user) |
| 2839 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2840 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2841 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2842 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2843 | |
| 2844 | |
| 2845 | |
| 2846 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2847 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2848 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2849 | id_serializer_class = SiteIdSerializer |
| 2850 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2851 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2852 | |
| 2853 | def get_serializer_class(self): |
| 2854 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2855 | if (no_hyperlinks): |
| 2856 | return self.id_serializer_class |
| 2857 | else: |
| 2858 | return self.serializer_class |
| 2859 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2860 | def get_queryset(self): |
| 2861 | return Site.select_by_user(self.request.user) |
| 2862 | |
| 2863 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2864 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2865 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2866 | response = {"error": "validation", |
| 2867 | "specific_error": "not serializer.is_valid()",
|
| 2868 | "reasons": serializer.errors}
|
| 2869 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2870 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2871 | obj.caller = request.user |
| 2872 | if obj.can_update(request.user): |
| 2873 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2874 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2875 | raise Exception("failed obj.can_update") |
| 2876 | |
| 2877 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2878 | if (ret.status_code%100 != 200): |
| 2879 | raise Exception(ret.data) |
| 2880 | |
| 2881 | return ret |
| 2882 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2883 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2884 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2885 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2886 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2887 | id_serializer_class = SiteIdSerializer |
| 2888 | |
| 2889 | def get_serializer_class(self): |
| 2890 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2891 | if (no_hyperlinks): |
| 2892 | return self.id_serializer_class |
| 2893 | else: |
| 2894 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2895 | |
| 2896 | def get_queryset(self): |
| 2897 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2898 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2899 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2900 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2901 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2902 | |
| 2903 | |
| 2904 | |
| 2905 | class SliceRoleList(generics.ListCreateAPIView): |
| 2906 | queryset = SliceRole.objects.select_related().all() |
| 2907 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2908 | id_serializer_class = SliceRoleIdSerializer |
| 2909 | filter_backends = (filters.DjangoFilterBackend,) |
| 2910 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2911 | |
| 2912 | def get_serializer_class(self): |
| 2913 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2914 | if (no_hyperlinks): |
| 2915 | return self.id_serializer_class |
| 2916 | else: |
| 2917 | return self.serializer_class |
| 2918 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2919 | def get_queryset(self): |
| 2920 | return SliceRole.select_by_user(self.request.user) |
| 2921 | |
| 2922 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2923 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2924 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2925 | response = {"error": "validation", |
| 2926 | "specific_error": "not serializer.is_valid()",
|
| 2927 | "reasons": serializer.errors}
|
| 2928 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2929 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2930 | obj.caller = request.user |
| 2931 | if obj.can_update(request.user): |
| 2932 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2933 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2934 | raise Exception("failed obj.can_update") |
| 2935 | |
| 2936 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2937 | if (ret.status_code%100 != 200): |
| 2938 | raise Exception(ret.data) |
| 2939 | |
| 2940 | return ret |
| 2941 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2942 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2943 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2944 | queryset = SliceRole.objects.select_related().all() |
| 2945 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2946 | id_serializer_class = SliceRoleIdSerializer |
| 2947 | |
| 2948 | def get_serializer_class(self): |
| 2949 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2950 | if (no_hyperlinks): |
| 2951 | return self.id_serializer_class |
| 2952 | else: |
| 2953 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2954 | |
| 2955 | def get_queryset(self): |
| 2956 | return SliceRole.select_by_user(self.request.user) |
| 2957 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2958 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2959 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2960 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2961 | |
| 2962 | |
| 2963 | |
| 2964 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2965 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2966 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2967 | id_serializer_class = TagIdSerializer |
| 2968 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2969 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2970 | |
| 2971 | def get_serializer_class(self): |
| 2972 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2973 | if (no_hyperlinks): |
| 2974 | return self.id_serializer_class |
| 2975 | else: |
| 2976 | return self.serializer_class |
| 2977 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2978 | def get_queryset(self): |
| 2979 | return Tag.select_by_user(self.request.user) |
| 2980 | |
| 2981 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2982 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2983 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2984 | response = {"error": "validation", |
| 2985 | "specific_error": "not serializer.is_valid()",
|
| 2986 | "reasons": serializer.errors}
|
| 2987 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2988 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2989 | obj.caller = request.user |
| 2990 | if obj.can_update(request.user): |
| 2991 | return super(TagList, self).create(request, *args, **kwargs) |
| 2992 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2993 | raise Exception("failed obj.can_update") |
| 2994 | |
| 2995 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 2996 | if (ret.status_code%100 != 200): |
| 2997 | raise Exception(ret.data) |
| 2998 | |
| 2999 | return ret |
| 3000 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3001 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3002 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3003 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3004 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3005 | id_serializer_class = TagIdSerializer |
| 3006 | |
| 3007 | def get_serializer_class(self): |
| 3008 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3009 | if (no_hyperlinks): |
| 3010 | return self.id_serializer_class |
| 3011 | else: |
| 3012 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3013 | |
| 3014 | def get_queryset(self): |
| 3015 | return Tag.select_by_user(self.request.user) |
| 3016 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3017 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3018 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3019 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3020 | |
| 3021 | |
| 3022 | |
| 3023 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3024 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3025 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3026 | id_serializer_class = InvoiceIdSerializer |
| 3027 | filter_backends = (filters.DjangoFilterBackend,) |
| 3028 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 3029 | |
| 3030 | def get_serializer_class(self): |
| 3031 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3032 | if (no_hyperlinks): |
| 3033 | return self.id_serializer_class |
| 3034 | else: |
| 3035 | return self.serializer_class |
| 3036 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3037 | def get_queryset(self): |
| 3038 | return Invoice.select_by_user(self.request.user) |
| 3039 | |
| 3040 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3041 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3042 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3043 | response = {"error": "validation", |
| 3044 | "specific_error": "not serializer.is_valid()",
|
| 3045 | "reasons": serializer.errors}
|
| 3046 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3047 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3048 | obj.caller = request.user |
| 3049 | if obj.can_update(request.user): |
| 3050 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 3051 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3052 | raise Exception("failed obj.can_update") |
| 3053 | |
| 3054 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 3055 | if (ret.status_code%100 != 200): |
| 3056 | raise Exception(ret.data) |
| 3057 | |
| 3058 | return ret |
| 3059 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3060 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3061 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3062 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3063 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3064 | id_serializer_class = InvoiceIdSerializer |
| 3065 | |
| 3066 | def get_serializer_class(self): |
| 3067 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3068 | if (no_hyperlinks): |
| 3069 | return self.id_serializer_class |
| 3070 | else: |
| 3071 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3072 | |
| 3073 | def get_queryset(self): |
| 3074 | return Invoice.select_by_user(self.request.user) |
| 3075 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3076 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3077 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3078 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3079 | |
| 3080 | |
| 3081 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3082 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 3083 | queryset = SlicePrivilege.objects.select_related().all() |
| 3084 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3085 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3086 | filter_backends = (filters.DjangoFilterBackend,) |
| 3087 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 3088 | |
| 3089 | def get_serializer_class(self): |
| 3090 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3091 | if (no_hyperlinks): |
| 3092 | return self.id_serializer_class |
| 3093 | else: |
| 3094 | return self.serializer_class |
| 3095 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3096 | def get_queryset(self): |
| 3097 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3098 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3099 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3100 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3101 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3102 | response = {"error": "validation", |
| 3103 | "specific_error": "not serializer.is_valid()",
|
| 3104 | "reasons": serializer.errors}
|
| 3105 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3106 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3107 | obj.caller = request.user |
| 3108 | if obj.can_update(request.user): |
| 3109 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3110 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3111 | raise Exception("failed obj.can_update") |
| 3112 | |
| 3113 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3114 | if (ret.status_code%100 != 200): |
| 3115 | raise Exception(ret.data) |
| 3116 | |
| 3117 | return ret |
| 3118 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3119 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3120 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3121 | queryset = SlicePrivilege.objects.select_related().all() |
| 3122 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3123 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3124 | |
| 3125 | def get_serializer_class(self): |
| 3126 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3127 | if (no_hyperlinks): |
| 3128 | return self.id_serializer_class |
| 3129 | else: |
| 3130 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3131 | |
| 3132 | def get_queryset(self): |
| 3133 | return SlicePrivilege.select_by_user(self.request.user) |
| 3134 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3135 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3136 | |
| 3137 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3138 | |
| 3139 | |
| 3140 | |
| 3141 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 3142 | queryset = PlanetStackRole.objects.select_related().all() |
| 3143 | serializer_class = PlanetStackRoleSerializer |
| 3144 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3145 | filter_backends = (filters.DjangoFilterBackend,) |
| 3146 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3147 | |
| 3148 | def get_serializer_class(self): |
| 3149 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3150 | if (no_hyperlinks): |
| 3151 | return self.id_serializer_class |
| 3152 | else: |
| 3153 | return self.serializer_class |
| 3154 | |
| 3155 | def get_queryset(self): |
| 3156 | return PlanetStackRole.select_by_user(self.request.user) |
| 3157 | |
| 3158 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3159 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3160 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3161 | response = {"error": "validation", |
| 3162 | "specific_error": "not serializer.is_valid()",
|
| 3163 | "reasons": serializer.errors}
|
| 3164 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3165 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3166 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3167 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3168 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3169 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3170 | raise Exception("failed obj.can_update") |
| 3171 | |
| 3172 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 3173 | if (ret.status_code%100 != 200): |
| 3174 | raise Exception(ret.data) |
| 3175 | |
| 3176 | return ret |
| 3177 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3178 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3179 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3180 | queryset = PlanetStackRole.objects.select_related().all() |
| 3181 | serializer_class = PlanetStackRoleSerializer |
| 3182 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3183 | |
| 3184 | def get_serializer_class(self): |
| 3185 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3186 | if (no_hyperlinks): |
| 3187 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3188 | else: |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3189 | return self.serializer_class |
| 3190 | |
| 3191 | def get_queryset(self): |
| 3192 | return PlanetStackRole.select_by_user(self.request.user) |
| 3193 | |
| 3194 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3195 | |
| 3196 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3197 | |
| 3198 | |
| 3199 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3200 | class ControllerPrivilegeList(generics.ListCreateAPIView): |
| 3201 | queryset = ControllerPrivilege.objects.select_related().all() |
| 3202 | serializer_class = ControllerPrivilegeSerializer |
| 3203 | id_serializer_class = ControllerPrivilegeIdSerializer |
| 3204 | filter_backends = (filters.DjangoFilterBackend,) |
| 3205 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 3206 | |
| 3207 | def get_serializer_class(self): |
| 3208 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3209 | if (no_hyperlinks): |
| 3210 | return self.id_serializer_class |
| 3211 | else: |
| 3212 | return self.serializer_class |
| 3213 | |
| 3214 | def get_queryset(self): |
| 3215 | return ControllerPrivilege.select_by_user(self.request.user) |
| 3216 | |
| 3217 | def create(self, request, *args, **kwargs): |
| 3218 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3219 | if not (serializer.is_valid()): |
| 3220 | response = {"error": "validation", |
| 3221 | "specific_error": "not serializer.is_valid()",
|
| 3222 | "reasons": serializer.errors}
|
| 3223 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3224 | obj = serializer.object |
| 3225 | obj.caller = request.user |
| 3226 | if obj.can_update(request.user): |
| 3227 | return super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
| 3228 | else: |
| 3229 | raise Exception("failed obj.can_update") |
| 3230 | |
| 3231 | ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
| 3232 | if (ret.status_code%100 != 200): |
| 3233 | raise Exception(ret.data) |
| 3234 | |
| 3235 | return ret |
| 3236 | |
| 3237 | |
| 3238 | class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3239 | queryset = ControllerPrivilege.objects.select_related().all() |
| 3240 | serializer_class = ControllerPrivilegeSerializer |
| 3241 | id_serializer_class = ControllerPrivilegeIdSerializer |
| 3242 | |
| 3243 | def get_serializer_class(self): |
| 3244 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3245 | if (no_hyperlinks): |
| 3246 | return self.id_serializer_class |
| 3247 | else: |
| 3248 | return self.serializer_class |
| 3249 | |
| 3250 | def get_queryset(self): |
| 3251 | return ControllerPrivilege.select_by_user(self.request.user) |
| 3252 | |
| 3253 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3254 | |
| 3255 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3256 | |
| 3257 | |
| 3258 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3259 | class NetworkSliverList(generics.ListCreateAPIView): |
| 3260 | queryset = NetworkSliver.objects.select_related().all() |
| 3261 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3262 | id_serializer_class = NetworkSliverIdSerializer |
| 3263 | filter_backends = (filters.DjangoFilterBackend,) |
| 3264 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 3265 | |
| 3266 | def get_serializer_class(self): |
| 3267 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3268 | if (no_hyperlinks): |
| 3269 | return self.id_serializer_class |
| 3270 | else: |
| 3271 | return self.serializer_class |
| 3272 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3273 | def get_queryset(self): |
| 3274 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3275 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3276 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3277 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3278 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3279 | response = {"error": "validation", |
| 3280 | "specific_error": "not serializer.is_valid()",
|
| 3281 | "reasons": serializer.errors}
|
| 3282 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3283 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3284 | obj.caller = request.user |
| 3285 | if obj.can_update(request.user): |
| 3286 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3287 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3288 | raise Exception("failed obj.can_update") |
| 3289 | |
| 3290 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3291 | if (ret.status_code%100 != 200): |
| 3292 | raise Exception(ret.data) |
| 3293 | |
| 3294 | return ret |
| 3295 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3296 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3297 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3298 | queryset = NetworkSliver.objects.select_related().all() |
| 3299 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3300 | id_serializer_class = NetworkSliverIdSerializer |
| 3301 | |
| 3302 | def get_serializer_class(self): |
| 3303 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3304 | if (no_hyperlinks): |
| 3305 | return self.id_serializer_class |
| 3306 | else: |
| 3307 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3308 | |
| 3309 | def get_queryset(self): |
| 3310 | return NetworkSliver.select_by_user(self.request.user) |
| 3311 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3312 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3313 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3314 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3315 | |
| 3316 | |
| 3317 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3318 | class ProjectList(generics.ListCreateAPIView): |
| 3319 | queryset = Project.objects.select_related().all() |
| 3320 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3321 | id_serializer_class = ProjectIdSerializer |
| 3322 | filter_backends = (filters.DjangoFilterBackend,) |
| 3323 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3324 | |
| 3325 | def get_serializer_class(self): |
| 3326 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3327 | if (no_hyperlinks): |
| 3328 | return self.id_serializer_class |
| 3329 | else: |
| 3330 | return self.serializer_class |
| 3331 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3332 | def get_queryset(self): |
| 3333 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3334 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3335 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3336 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3337 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3338 | response = {"error": "validation", |
| 3339 | "specific_error": "not serializer.is_valid()",
|
| 3340 | "reasons": serializer.errors}
|
| 3341 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3342 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3343 | obj.caller = request.user |
| 3344 | if obj.can_update(request.user): |
| 3345 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 3346 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3347 | raise Exception("failed obj.can_update") |
| 3348 | |
| 3349 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 3350 | if (ret.status_code%100 != 200): |
| 3351 | raise Exception(ret.data) |
| 3352 | |
| 3353 | return ret |
| 3354 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3355 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3356 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3357 | queryset = Project.objects.select_related().all() |
| 3358 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3359 | id_serializer_class = ProjectIdSerializer |
| 3360 | |
| 3361 | def get_serializer_class(self): |
| 3362 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3363 | if (no_hyperlinks): |
| 3364 | return self.id_serializer_class |
| 3365 | else: |
| 3366 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3367 | |
| 3368 | def get_queryset(self): |
| 3369 | return Project.select_by_user(self.request.user) |
| 3370 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3371 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3372 | |
| 3373 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3374 | |
| 3375 | |
| 3376 | |
| 3377 | class SliceList(generics.ListCreateAPIView): |
| 3378 | queryset = Slice.objects.select_related().all() |
| 3379 | serializer_class = SliceSerializer |
| 3380 | id_serializer_class = SliceIdSerializer |
| 3381 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3382 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3383 | |
| 3384 | def get_serializer_class(self): |
| 3385 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3386 | if (no_hyperlinks): |
| 3387 | return self.id_serializer_class |
| 3388 | else: |
| 3389 | return self.serializer_class |
| 3390 | |
| 3391 | def get_queryset(self): |
| 3392 | return Slice.select_by_user(self.request.user) |
| 3393 | |
| 3394 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3395 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3396 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3397 | response = {"error": "validation", |
| 3398 | "specific_error": "not serializer.is_valid()",
|
| 3399 | "reasons": serializer.errors}
|
| 3400 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3401 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3402 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3403 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3404 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3405 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3406 | raise Exception("failed obj.can_update") |
| 3407 | |
| 3408 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3409 | if (ret.status_code%100 != 200): |
| 3410 | raise Exception(ret.data) |
| 3411 | |
| 3412 | return ret |
| 3413 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3414 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3415 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3416 | queryset = Slice.objects.select_related().all() |
| 3417 | serializer_class = SliceSerializer |
| 3418 | id_serializer_class = SliceIdSerializer |
| 3419 | |
| 3420 | def get_serializer_class(self): |
| 3421 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3422 | if (no_hyperlinks): |
| 3423 | return self.id_serializer_class |
| 3424 | else: |
| 3425 | return self.serializer_class |
| 3426 | |
| 3427 | def get_queryset(self): |
| 3428 | return Slice.select_by_user(self.request.user) |
| 3429 | |
| 3430 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3431 | |
| 3432 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3433 | |
| 3434 | |
| 3435 | |
| 3436 | class NetworkList(generics.ListCreateAPIView): |
| 3437 | queryset = Network.objects.select_related().all() |
| 3438 | serializer_class = NetworkSerializer |
| 3439 | id_serializer_class = NetworkIdSerializer |
| 3440 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3441 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3442 | |
| 3443 | def get_serializer_class(self): |
| 3444 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3445 | if (no_hyperlinks): |
| 3446 | return self.id_serializer_class |
| 3447 | else: |
| 3448 | return self.serializer_class |
| 3449 | |
| 3450 | def get_queryset(self): |
| 3451 | return Network.select_by_user(self.request.user) |
| 3452 | |
| 3453 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3454 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3455 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3456 | response = {"error": "validation", |
| 3457 | "specific_error": "not serializer.is_valid()",
|
| 3458 | "reasons": serializer.errors}
|
| 3459 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3460 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3461 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3462 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3463 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3464 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3465 | raise Exception("failed obj.can_update") |
| 3466 | |
| 3467 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3468 | if (ret.status_code%100 != 200): |
| 3469 | raise Exception(ret.data) |
| 3470 | |
| 3471 | return ret |
| 3472 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3473 | |
| 3474 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3475 | queryset = Network.objects.select_related().all() |
| 3476 | serializer_class = NetworkSerializer |
| 3477 | id_serializer_class = NetworkIdSerializer |
| 3478 | |
| 3479 | def get_serializer_class(self): |
| 3480 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3481 | if (no_hyperlinks): |
| 3482 | return self.id_serializer_class |
| 3483 | else: |
| 3484 | return self.serializer_class |
| 3485 | |
| 3486 | def get_queryset(self): |
| 3487 | return Network.select_by_user(self.request.user) |
| 3488 | |
| 3489 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3490 | |
| 3491 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3492 | |
| 3493 | |
| 3494 | |
| 3495 | class ServiceList(generics.ListCreateAPIView): |
| 3496 | queryset = Service.objects.select_related().all() |
| 3497 | serializer_class = ServiceSerializer |
| 3498 | id_serializer_class = ServiceIdSerializer |
| 3499 | filter_backends = (filters.DjangoFilterBackend,) |
| 3500 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 3501 | |
| 3502 | def get_serializer_class(self): |
| 3503 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3504 | if (no_hyperlinks): |
| 3505 | return self.id_serializer_class |
| 3506 | else: |
| 3507 | return self.serializer_class |
| 3508 | |
| 3509 | def get_queryset(self): |
| 3510 | return Service.select_by_user(self.request.user) |
| 3511 | |
| 3512 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3513 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3514 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3515 | response = {"error": "validation", |
| 3516 | "specific_error": "not serializer.is_valid()",
|
| 3517 | "reasons": serializer.errors}
|
| 3518 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3519 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3520 | obj.caller = request.user |
| 3521 | if obj.can_update(request.user): |
| 3522 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3523 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3524 | raise Exception("failed obj.can_update") |
| 3525 | |
| 3526 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3527 | if (ret.status_code%100 != 200): |
| 3528 | raise Exception(ret.data) |
| 3529 | |
| 3530 | return ret |
| 3531 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3532 | |
| 3533 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3534 | queryset = Service.objects.select_related().all() |
| 3535 | serializer_class = ServiceSerializer |
| 3536 | id_serializer_class = ServiceIdSerializer |
| 3537 | |
| 3538 | def get_serializer_class(self): |
| 3539 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3540 | if (no_hyperlinks): |
| 3541 | return self.id_serializer_class |
| 3542 | else: |
| 3543 | return self.serializer_class |
| 3544 | |
| 3545 | def get_queryset(self): |
| 3546 | return Service.select_by_user(self.request.user) |
| 3547 | |
| 3548 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3549 | |
| 3550 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3551 | |
| 3552 | |
| 3553 | |
| 3554 | class ServiceClassList(generics.ListCreateAPIView): |
| 3555 | queryset = ServiceClass.objects.select_related().all() |
| 3556 | serializer_class = ServiceClassSerializer |
| 3557 | id_serializer_class = ServiceClassIdSerializer |
| 3558 | filter_backends = (filters.DjangoFilterBackend,) |
| 3559 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 3560 | |
| 3561 | def get_serializer_class(self): |
| 3562 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3563 | if (no_hyperlinks): |
| 3564 | return self.id_serializer_class |
| 3565 | else: |
| 3566 | return self.serializer_class |
| 3567 | |
| 3568 | def get_queryset(self): |
| 3569 | return ServiceClass.select_by_user(self.request.user) |
| 3570 | |
| 3571 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3572 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3573 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3574 | response = {"error": "validation", |
| 3575 | "specific_error": "not serializer.is_valid()",
|
| 3576 | "reasons": serializer.errors}
|
| 3577 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3578 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3579 | obj.caller = request.user |
| 3580 | if obj.can_update(request.user): |
| 3581 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3582 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3583 | raise Exception("failed obj.can_update") |
| 3584 | |
| 3585 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3586 | if (ret.status_code%100 != 200): |
| 3587 | raise Exception(ret.data) |
| 3588 | |
| 3589 | return ret |
| 3590 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3591 | |
| 3592 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3593 | queryset = ServiceClass.objects.select_related().all() |
| 3594 | serializer_class = ServiceClassSerializer |
| 3595 | id_serializer_class = ServiceClassIdSerializer |
| 3596 | |
| 3597 | def get_serializer_class(self): |
| 3598 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3599 | if (no_hyperlinks): |
| 3600 | return self.id_serializer_class |
| 3601 | else: |
| 3602 | return self.serializer_class |
| 3603 | |
| 3604 | def get_queryset(self): |
| 3605 | return ServiceClass.select_by_user(self.request.user) |
| 3606 | |
| 3607 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3608 | |
| 3609 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3610 | |
| 3611 | |
| 3612 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3613 | class ControllerNetworksList(generics.ListCreateAPIView): |
| 3614 | queryset = ControllerNetworks.objects.select_related().all() |
| 3615 | serializer_class = ControllerNetworksSerializer |
| 3616 | id_serializer_class = ControllerNetworksIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3617 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3618 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3619 | |
| 3620 | def get_serializer_class(self): |
| 3621 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3622 | if (no_hyperlinks): |
| 3623 | return self.id_serializer_class |
| 3624 | else: |
| 3625 | return self.serializer_class |
| 3626 | |
| 3627 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3628 | return ControllerNetworks.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3629 | |
| 3630 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3631 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3632 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3633 | response = {"error": "validation", |
| 3634 | "specific_error": "not serializer.is_valid()",
|
| 3635 | "reasons": serializer.errors}
|
| 3636 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3637 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3638 | obj.caller = request.user |
| 3639 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3640 | return super(ControllerNetworksList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3641 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3642 | raise Exception("failed obj.can_update") |
| 3643 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3644 | ret = super(ControllerNetworksList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3645 | if (ret.status_code%100 != 200): |
| 3646 | raise Exception(ret.data) |
| 3647 | |
| 3648 | return ret |
| 3649 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3650 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3651 | class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3652 | queryset = ControllerNetworks.objects.select_related().all() |
| 3653 | serializer_class = ControllerNetworksSerializer |
| 3654 | id_serializer_class = ControllerNetworksIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3655 | |
| 3656 | def get_serializer_class(self): |
| 3657 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3658 | if (no_hyperlinks): |
| 3659 | return self.id_serializer_class |
| 3660 | else: |
| 3661 | return self.serializer_class |
| 3662 | |
| 3663 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3664 | return ControllerNetworks.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3665 | |
| 3666 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3667 | |
| 3668 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3669 | |
| 3670 | |
| 3671 | |
| 3672 | class ChargeList(generics.ListCreateAPIView): |
| 3673 | queryset = Charge.objects.select_related().all() |
| 3674 | serializer_class = ChargeSerializer |
| 3675 | id_serializer_class = ChargeIdSerializer |
| 3676 | filter_backends = (filters.DjangoFilterBackend,) |
| 3677 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 3678 | |
| 3679 | def get_serializer_class(self): |
| 3680 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3681 | if (no_hyperlinks): |
| 3682 | return self.id_serializer_class |
| 3683 | else: |
| 3684 | return self.serializer_class |
| 3685 | |
| 3686 | def get_queryset(self): |
| 3687 | return Charge.select_by_user(self.request.user) |
| 3688 | |
| 3689 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3690 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3691 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3692 | response = {"error": "validation", |
| 3693 | "specific_error": "not serializer.is_valid()",
|
| 3694 | "reasons": serializer.errors}
|
| 3695 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3696 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3697 | obj.caller = request.user |
| 3698 | if obj.can_update(request.user): |
| 3699 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3700 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3701 | raise Exception("failed obj.can_update") |
| 3702 | |
| 3703 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3704 | if (ret.status_code%100 != 200): |
| 3705 | raise Exception(ret.data) |
| 3706 | |
| 3707 | return ret |
| 3708 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3709 | |
| 3710 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3711 | queryset = Charge.objects.select_related().all() |
| 3712 | serializer_class = ChargeSerializer |
| 3713 | id_serializer_class = ChargeIdSerializer |
| 3714 | |
| 3715 | def get_serializer_class(self): |
| 3716 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3717 | if (no_hyperlinks): |
| 3718 | return self.id_serializer_class |
| 3719 | else: |
| 3720 | return self.serializer_class |
| 3721 | |
| 3722 | def get_queryset(self): |
| 3723 | return Charge.select_by_user(self.request.user) |
| 3724 | |
| 3725 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3726 | |
| 3727 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3728 | |
| 3729 | |
| 3730 | |
| 3731 | class RoleList(generics.ListCreateAPIView): |
| 3732 | queryset = Role.objects.select_related().all() |
| 3733 | serializer_class = RoleSerializer |
| 3734 | id_serializer_class = RoleIdSerializer |
| 3735 | filter_backends = (filters.DjangoFilterBackend,) |
| 3736 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 3737 | |
| 3738 | def get_serializer_class(self): |
| 3739 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3740 | if (no_hyperlinks): |
| 3741 | return self.id_serializer_class |
| 3742 | else: |
| 3743 | return self.serializer_class |
| 3744 | |
| 3745 | def get_queryset(self): |
| 3746 | return Role.select_by_user(self.request.user) |
| 3747 | |
| 3748 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3749 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3750 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3751 | response = {"error": "validation", |
| 3752 | "specific_error": "not serializer.is_valid()",
|
| 3753 | "reasons": serializer.errors}
|
| 3754 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3755 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3756 | obj.caller = request.user |
| 3757 | if obj.can_update(request.user): |
| 3758 | return super(RoleList, self).create(request, *args, **kwargs) |
| 3759 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3760 | raise Exception("failed obj.can_update") |
| 3761 | |
| 3762 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 3763 | if (ret.status_code%100 != 200): |
| 3764 | raise Exception(ret.data) |
| 3765 | |
| 3766 | return ret |
| 3767 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3768 | |
| 3769 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3770 | queryset = Role.objects.select_related().all() |
| 3771 | serializer_class = RoleSerializer |
| 3772 | id_serializer_class = RoleIdSerializer |
| 3773 | |
| 3774 | def get_serializer_class(self): |
| 3775 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3776 | if (no_hyperlinks): |
| 3777 | return self.id_serializer_class |
| 3778 | else: |
| 3779 | return self.serializer_class |
| 3780 | |
| 3781 | def get_queryset(self): |
| 3782 | return Role.select_by_user(self.request.user) |
| 3783 | |
| 3784 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3785 | |
| 3786 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3787 | |
| 3788 | |
| 3789 | |
| 3790 | class UsableObjectList(generics.ListCreateAPIView): |
| 3791 | queryset = UsableObject.objects.select_related().all() |
| 3792 | serializer_class = UsableObjectSerializer |
| 3793 | id_serializer_class = UsableObjectIdSerializer |
| 3794 | filter_backends = (filters.DjangoFilterBackend,) |
| 3795 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3796 | |
| 3797 | def get_serializer_class(self): |
| 3798 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3799 | if (no_hyperlinks): |
| 3800 | return self.id_serializer_class |
| 3801 | else: |
| 3802 | return self.serializer_class |
| 3803 | |
| 3804 | def get_queryset(self): |
| 3805 | return UsableObject.select_by_user(self.request.user) |
| 3806 | |
| 3807 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3808 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3809 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3810 | response = {"error": "validation", |
| 3811 | "specific_error": "not serializer.is_valid()",
|
| 3812 | "reasons": serializer.errors}
|
| 3813 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3814 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3815 | obj.caller = request.user |
| 3816 | if obj.can_update(request.user): |
| 3817 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3818 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3819 | raise Exception("failed obj.can_update") |
| 3820 | |
| 3821 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3822 | if (ret.status_code%100 != 200): |
| 3823 | raise Exception(ret.data) |
| 3824 | |
| 3825 | return ret |
| 3826 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3827 | |
| 3828 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3829 | queryset = UsableObject.objects.select_related().all() |
| 3830 | serializer_class = UsableObjectSerializer |
| 3831 | id_serializer_class = UsableObjectIdSerializer |
| 3832 | |
| 3833 | def get_serializer_class(self): |
| 3834 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3835 | if (no_hyperlinks): |
| 3836 | return self.id_serializer_class |
| 3837 | else: |
| 3838 | return self.serializer_class |
| 3839 | |
| 3840 | def get_queryset(self): |
| 3841 | return UsableObject.select_by_user(self.request.user) |
| 3842 | |
| 3843 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3844 | |
| 3845 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3846 | |
| 3847 | |
| 3848 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3849 | class ControllerSiteDeploymentsList(generics.ListCreateAPIView): |
| 3850 | queryset = ControllerSiteDeployments.objects.select_related().all() |
| 3851 | serializer_class = ControllerSiteDeploymentsSerializer |
| 3852 | id_serializer_class = ControllerSiteDeploymentsIdSerializer |
| 3853 | filter_backends = (filters.DjangoFilterBackend,) |
| 3854 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 3855 | |
| 3856 | def get_serializer_class(self): |
| 3857 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3858 | if (no_hyperlinks): |
| 3859 | return self.id_serializer_class |
| 3860 | else: |
| 3861 | return self.serializer_class |
| 3862 | |
| 3863 | def get_queryset(self): |
| 3864 | return ControllerSiteDeployments.select_by_user(self.request.user) |
| 3865 | |
| 3866 | def create(self, request, *args, **kwargs): |
| 3867 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3868 | if not (serializer.is_valid()): |
| 3869 | response = {"error": "validation", |
| 3870 | "specific_error": "not serializer.is_valid()",
|
| 3871 | "reasons": serializer.errors}
|
| 3872 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3873 | obj = serializer.object |
| 3874 | obj.caller = request.user |
| 3875 | if obj.can_update(request.user): |
| 3876 | return super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs) |
| 3877 | else: |
| 3878 | raise Exception("failed obj.can_update") |
| 3879 | |
| 3880 | ret = super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs) |
| 3881 | if (ret.status_code%100 != 200): |
| 3882 | raise Exception(ret.data) |
| 3883 | |
| 3884 | return ret |
| 3885 | |
| 3886 | |
| 3887 | class ControllerSiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3888 | queryset = ControllerSiteDeployments.objects.select_related().all() |
| 3889 | serializer_class = ControllerSiteDeploymentsSerializer |
| 3890 | id_serializer_class = ControllerSiteDeploymentsIdSerializer |
| 3891 | |
| 3892 | def get_serializer_class(self): |
| 3893 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3894 | if (no_hyperlinks): |
| 3895 | return self.id_serializer_class |
| 3896 | else: |
| 3897 | return self.serializer_class |
| 3898 | |
| 3899 | def get_queryset(self): |
| 3900 | return ControllerSiteDeployments.select_by_user(self.request.user) |
| 3901 | |
| 3902 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3903 | |
| 3904 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3905 | |
| 3906 | |
| 3907 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3908 | class SiteRoleList(generics.ListCreateAPIView): |
| 3909 | queryset = SiteRole.objects.select_related().all() |
| 3910 | serializer_class = SiteRoleSerializer |
| 3911 | id_serializer_class = SiteRoleIdSerializer |
| 3912 | filter_backends = (filters.DjangoFilterBackend,) |
| 3913 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3914 | |
| 3915 | def get_serializer_class(self): |
| 3916 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3917 | if (no_hyperlinks): |
| 3918 | return self.id_serializer_class |
| 3919 | else: |
| 3920 | return self.serializer_class |
| 3921 | |
| 3922 | def get_queryset(self): |
| 3923 | return SiteRole.select_by_user(self.request.user) |
| 3924 | |
| 3925 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3926 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3927 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3928 | response = {"error": "validation", |
| 3929 | "specific_error": "not serializer.is_valid()",
|
| 3930 | "reasons": serializer.errors}
|
| 3931 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3932 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3933 | obj.caller = request.user |
| 3934 | if obj.can_update(request.user): |
| 3935 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3936 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3937 | raise Exception("failed obj.can_update") |
| 3938 | |
| 3939 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3940 | if (ret.status_code%100 != 200): |
| 3941 | raise Exception(ret.data) |
| 3942 | |
| 3943 | return ret |
| 3944 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3945 | |
| 3946 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3947 | queryset = SiteRole.objects.select_related().all() |
| 3948 | serializer_class = SiteRoleSerializer |
| 3949 | id_serializer_class = SiteRoleIdSerializer |
| 3950 | |
| 3951 | def get_serializer_class(self): |
| 3952 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3953 | if (no_hyperlinks): |
| 3954 | return self.id_serializer_class |
| 3955 | else: |
| 3956 | return self.serializer_class |
| 3957 | |
| 3958 | def get_queryset(self): |
| 3959 | return SiteRole.select_by_user(self.request.user) |
| 3960 | |
| 3961 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3962 | |
| 3963 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3964 | |
| 3965 | |
| 3966 | |
| 3967 | class SliceCredentialList(generics.ListCreateAPIView): |
| 3968 | queryset = SliceCredential.objects.select_related().all() |
| 3969 | serializer_class = SliceCredentialSerializer |
| 3970 | id_serializer_class = SliceCredentialIdSerializer |
| 3971 | filter_backends = (filters.DjangoFilterBackend,) |
| 3972 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 3973 | |
| 3974 | def get_serializer_class(self): |
| 3975 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3976 | if (no_hyperlinks): |
| 3977 | return self.id_serializer_class |
| 3978 | else: |
| 3979 | return self.serializer_class |
| 3980 | |
| 3981 | def get_queryset(self): |
| 3982 | return SliceCredential.select_by_user(self.request.user) |
| 3983 | |
| 3984 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3985 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3986 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3987 | response = {"error": "validation", |
| 3988 | "specific_error": "not serializer.is_valid()",
|
| 3989 | "reasons": serializer.errors}
|
| 3990 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3991 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3992 | obj.caller = request.user |
| 3993 | if obj.can_update(request.user): |
| 3994 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3995 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3996 | raise Exception("failed obj.can_update") |
| 3997 | |
| 3998 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3999 | if (ret.status_code%100 != 200): |
| 4000 | raise Exception(ret.data) |
| 4001 | |
| 4002 | return ret |
| 4003 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4004 | |
| 4005 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4006 | queryset = SliceCredential.objects.select_related().all() |
| 4007 | serializer_class = SliceCredentialSerializer |
| 4008 | id_serializer_class = SliceCredentialIdSerializer |
| 4009 | |
| 4010 | def get_serializer_class(self): |
| 4011 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4012 | if (no_hyperlinks): |
| 4013 | return self.id_serializer_class |
| 4014 | else: |
| 4015 | return self.serializer_class |
| 4016 | |
| 4017 | def get_queryset(self): |
| 4018 | return SliceCredential.select_by_user(self.request.user) |
| 4019 | |
| 4020 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4021 | |
| 4022 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4023 | |
| 4024 | |
| 4025 | |
| 4026 | class SliverList(generics.ListCreateAPIView): |
| 4027 | queryset = Sliver.objects.select_related().all() |
| 4028 | serializer_class = SliverSerializer |
| 4029 | id_serializer_class = SliverIdSerializer |
| 4030 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4031 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4032 | |
| 4033 | def get_serializer_class(self): |
| 4034 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4035 | if (no_hyperlinks): |
| 4036 | return self.id_serializer_class |
| 4037 | else: |
| 4038 | return self.serializer_class |
| 4039 | |
| 4040 | def get_queryset(self): |
| 4041 | return Sliver.select_by_user(self.request.user) |
| 4042 | |
| 4043 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4044 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4045 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4046 | response = {"error": "validation", |
| 4047 | "specific_error": "not serializer.is_valid()",
|
| 4048 | "reasons": serializer.errors}
|
| 4049 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4050 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4051 | obj.caller = request.user |
| 4052 | if obj.can_update(request.user): |
| 4053 | return super(SliverList, self).create(request, *args, **kwargs) |
| 4054 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4055 | raise Exception("failed obj.can_update") |
| 4056 | |
| 4057 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 4058 | if (ret.status_code%100 != 200): |
| 4059 | raise Exception(ret.data) |
| 4060 | |
| 4061 | return ret |
| 4062 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4063 | |
| 4064 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4065 | queryset = Sliver.objects.select_related().all() |
| 4066 | serializer_class = SliverSerializer |
| 4067 | id_serializer_class = SliverIdSerializer |
| 4068 | |
| 4069 | def get_serializer_class(self): |
| 4070 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4071 | if (no_hyperlinks): |
| 4072 | return self.id_serializer_class |
| 4073 | else: |
| 4074 | return self.serializer_class |
| 4075 | |
| 4076 | def get_queryset(self): |
| 4077 | return Sliver.select_by_user(self.request.user) |
| 4078 | |
| 4079 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4080 | |
| 4081 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4082 | |
| 4083 | |
| 4084 | |
| 4085 | class NodeList(generics.ListCreateAPIView): |
| 4086 | queryset = Node.objects.select_related().all() |
| 4087 | serializer_class = NodeSerializer |
| 4088 | id_serializer_class = NodeIdSerializer |
| 4089 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4090 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4091 | |
| 4092 | def get_serializer_class(self): |
| 4093 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4094 | if (no_hyperlinks): |
| 4095 | return self.id_serializer_class |
| 4096 | else: |
| 4097 | return self.serializer_class |
| 4098 | |
| 4099 | def get_queryset(self): |
| 4100 | return Node.select_by_user(self.request.user) |
| 4101 | |
| 4102 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4103 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4104 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4105 | response = {"error": "validation", |
| 4106 | "specific_error": "not serializer.is_valid()",
|
| 4107 | "reasons": serializer.errors}
|
| 4108 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4109 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4110 | obj.caller = request.user |
| 4111 | if obj.can_update(request.user): |
| 4112 | return super(NodeList, self).create(request, *args, **kwargs) |
| 4113 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4114 | raise Exception("failed obj.can_update") |
| 4115 | |
| 4116 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 4117 | if (ret.status_code%100 != 200): |
| 4118 | raise Exception(ret.data) |
| 4119 | |
| 4120 | return ret |
| 4121 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4122 | |
| 4123 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4124 | queryset = Node.objects.select_related().all() |
| 4125 | serializer_class = NodeSerializer |
| 4126 | id_serializer_class = NodeIdSerializer |
| 4127 | |
| 4128 | def get_serializer_class(self): |
| 4129 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4130 | if (no_hyperlinks): |
| 4131 | return self.id_serializer_class |
| 4132 | else: |
| 4133 | return self.serializer_class |
| 4134 | |
| 4135 | def get_queryset(self): |
| 4136 | return Node.select_by_user(self.request.user) |
| 4137 | |
| 4138 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4139 | |
| 4140 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4141 | |
| 4142 | |
| 4143 | |
| 4144 | class DashboardViewList(generics.ListCreateAPIView): |
| 4145 | queryset = DashboardView.objects.select_related().all() |
| 4146 | serializer_class = DashboardViewSerializer |
| 4147 | id_serializer_class = DashboardViewIdSerializer |
| 4148 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4149 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4150 | |
| 4151 | def get_serializer_class(self): |
| 4152 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4153 | if (no_hyperlinks): |
| 4154 | return self.id_serializer_class |
| 4155 | else: |
| 4156 | return self.serializer_class |
| 4157 | |
| 4158 | def get_queryset(self): |
| 4159 | return DashboardView.select_by_user(self.request.user) |
| 4160 | |
| 4161 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4162 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4163 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4164 | response = {"error": "validation", |
| 4165 | "specific_error": "not serializer.is_valid()",
|
| 4166 | "reasons": serializer.errors}
|
| 4167 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4168 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4169 | obj.caller = request.user |
| 4170 | if obj.can_update(request.user): |
| 4171 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4172 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4173 | raise Exception("failed obj.can_update") |
| 4174 | |
| 4175 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4176 | if (ret.status_code%100 != 200): |
| 4177 | raise Exception(ret.data) |
| 4178 | |
| 4179 | return ret |
| 4180 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4181 | |
| 4182 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4183 | queryset = DashboardView.objects.select_related().all() |
| 4184 | serializer_class = DashboardViewSerializer |
| 4185 | id_serializer_class = DashboardViewIdSerializer |
| 4186 | |
| 4187 | def get_serializer_class(self): |
| 4188 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4189 | if (no_hyperlinks): |
| 4190 | return self.id_serializer_class |
| 4191 | else: |
| 4192 | return self.serializer_class |
| 4193 | |
| 4194 | def get_queryset(self): |
| 4195 | return DashboardView.select_by_user(self.request.user) |
| 4196 | |
| 4197 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4198 | |
| 4199 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4200 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4201 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4202 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4203 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 4204 | queryset = ImageDeployments.objects.select_related().all() |
| 4205 | serializer_class = ImageDeploymentsSerializer |
| 4206 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4207 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4208 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4209 | |
| 4210 | def get_serializer_class(self): |
| 4211 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4212 | if (no_hyperlinks): |
| 4213 | return self.id_serializer_class |
| 4214 | else: |
| 4215 | return self.serializer_class |
| 4216 | |
| 4217 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4218 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4219 | |
| 4220 | def create(self, request, *args, **kwargs): |
| 4221 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4222 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4223 | response = {"error": "validation", |
| 4224 | "specific_error": "not serializer.is_valid()",
|
| 4225 | "reasons": serializer.errors}
|
| 4226 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4227 | obj = serializer.object |
| 4228 | obj.caller = request.user |
| 4229 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4230 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4231 | else: |
| 4232 | raise Exception("failed obj.can_update") |
| 4233 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4234 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4235 | if (ret.status_code%100 != 200): |
| 4236 | raise Exception(ret.data) |
| 4237 | |
| 4238 | return ret |
| 4239 | |
| 4240 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4241 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4242 | queryset = ImageDeployments.objects.select_related().all() |
| 4243 | serializer_class = ImageDeploymentsSerializer |
| 4244 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4245 | |
| 4246 | def get_serializer_class(self): |
| 4247 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4248 | if (no_hyperlinks): |
| 4249 | return self.id_serializer_class |
| 4250 | else: |
| 4251 | return self.serializer_class |
| 4252 | |
| 4253 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4254 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4255 | |
| 4256 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4257 | |
| 4258 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4259 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4260 | |
| 4261 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4262 | class ReservedResourceList(generics.ListCreateAPIView): |
| 4263 | queryset = ReservedResource.objects.select_related().all() |
| 4264 | serializer_class = ReservedResourceSerializer |
| 4265 | id_serializer_class = ReservedResourceIdSerializer |
| 4266 | filter_backends = (filters.DjangoFilterBackend,) |
| 4267 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 4268 | |
| 4269 | def get_serializer_class(self): |
| 4270 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4271 | if (no_hyperlinks): |
| 4272 | return self.id_serializer_class |
| 4273 | else: |
| 4274 | return self.serializer_class |
| 4275 | |
| 4276 | def get_queryset(self): |
| 4277 | return ReservedResource.select_by_user(self.request.user) |
| 4278 | |
| 4279 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4280 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4281 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4282 | response = {"error": "validation", |
| 4283 | "specific_error": "not serializer.is_valid()",
|
| 4284 | "reasons": serializer.errors}
|
| 4285 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4286 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4287 | obj.caller = request.user |
| 4288 | if obj.can_update(request.user): |
| 4289 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4290 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4291 | raise Exception("failed obj.can_update") |
| 4292 | |
| 4293 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4294 | if (ret.status_code%100 != 200): |
| 4295 | raise Exception(ret.data) |
| 4296 | |
| 4297 | return ret |
| 4298 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4299 | |
| 4300 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4301 | queryset = ReservedResource.objects.select_related().all() |
| 4302 | serializer_class = ReservedResourceSerializer |
| 4303 | id_serializer_class = ReservedResourceIdSerializer |
| 4304 | |
| 4305 | def get_serializer_class(self): |
| 4306 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4307 | if (no_hyperlinks): |
| 4308 | return self.id_serializer_class |
| 4309 | else: |
| 4310 | return self.serializer_class |
| 4311 | |
| 4312 | def get_queryset(self): |
| 4313 | return ReservedResource.select_by_user(self.request.user) |
| 4314 | |
| 4315 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4316 | |
| 4317 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4318 | |
| 4319 | |
| 4320 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4321 | class PaymentList(generics.ListCreateAPIView): |
| 4322 | queryset = Payment.objects.select_related().all() |
| 4323 | serializer_class = PaymentSerializer |
| 4324 | id_serializer_class = PaymentIdSerializer |
| 4325 | filter_backends = (filters.DjangoFilterBackend,) |
| 4326 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 4327 | |
| 4328 | def get_serializer_class(self): |
| 4329 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4330 | if (no_hyperlinks): |
| 4331 | return self.id_serializer_class |
| 4332 | else: |
| 4333 | return self.serializer_class |
| 4334 | |
| 4335 | def get_queryset(self): |
| 4336 | return Payment.select_by_user(self.request.user) |
| 4337 | |
| 4338 | def create(self, request, *args, **kwargs): |
| 4339 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4340 | if not (serializer.is_valid()): |
| 4341 | response = {"error": "validation", |
| 4342 | "specific_error": "not serializer.is_valid()",
|
| 4343 | "reasons": serializer.errors}
|
| 4344 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4345 | obj = serializer.object |
| 4346 | obj.caller = request.user |
| 4347 | if obj.can_update(request.user): |
| 4348 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 4349 | else: |
| 4350 | raise Exception("failed obj.can_update") |
| 4351 | |
| 4352 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 4353 | if (ret.status_code%100 != 200): |
| 4354 | raise Exception(ret.data) |
| 4355 | |
| 4356 | return ret |
| 4357 | |
| 4358 | |
| 4359 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4360 | queryset = Payment.objects.select_related().all() |
| 4361 | serializer_class = PaymentSerializer |
| 4362 | id_serializer_class = PaymentIdSerializer |
| 4363 | |
| 4364 | def get_serializer_class(self): |
| 4365 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4366 | if (no_hyperlinks): |
| 4367 | return self.id_serializer_class |
| 4368 | else: |
| 4369 | return self.serializer_class |
| 4370 | |
| 4371 | def get_queryset(self): |
| 4372 | return Payment.select_by_user(self.request.user) |
| 4373 | |
| 4374 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4375 | |
| 4376 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4377 | |
| 4378 | |
| 4379 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4380 | class NetworkSliceList(generics.ListCreateAPIView): |
| 4381 | queryset = NetworkSlice.objects.select_related().all() |
| 4382 | serializer_class = NetworkSliceSerializer |
| 4383 | id_serializer_class = NetworkSliceIdSerializer |
| 4384 | filter_backends = (filters.DjangoFilterBackend,) |
| 4385 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 4386 | |
| 4387 | def get_serializer_class(self): |
| 4388 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4389 | if (no_hyperlinks): |
| 4390 | return self.id_serializer_class |
| 4391 | else: |
| 4392 | return self.serializer_class |
| 4393 | |
| 4394 | def get_queryset(self): |
| 4395 | return NetworkSlice.select_by_user(self.request.user) |
| 4396 | |
| 4397 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4398 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4399 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4400 | response = {"error": "validation", |
| 4401 | "specific_error": "not serializer.is_valid()",
|
| 4402 | "reasons": serializer.errors}
|
| 4403 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4404 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4405 | obj.caller = request.user |
| 4406 | if obj.can_update(request.user): |
| 4407 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4408 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4409 | raise Exception("failed obj.can_update") |
| 4410 | |
| 4411 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4412 | if (ret.status_code%100 != 200): |
| 4413 | raise Exception(ret.data) |
| 4414 | |
| 4415 | return ret |
| 4416 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4417 | |
| 4418 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4419 | queryset = NetworkSlice.objects.select_related().all() |
| 4420 | serializer_class = NetworkSliceSerializer |
| 4421 | id_serializer_class = NetworkSliceIdSerializer |
| 4422 | |
| 4423 | def get_serializer_class(self): |
| 4424 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4425 | if (no_hyperlinks): |
| 4426 | return self.id_serializer_class |
| 4427 | else: |
| 4428 | return self.serializer_class |
| 4429 | |
| 4430 | def get_queryset(self): |
| 4431 | return NetworkSlice.select_by_user(self.request.user) |
| 4432 | |
| 4433 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4434 | |
| 4435 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4436 | |
| 4437 | |
| 4438 | |
| 4439 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 4440 | queryset = UserDashboardView.objects.select_related().all() |
| 4441 | serializer_class = UserDashboardViewSerializer |
| 4442 | id_serializer_class = UserDashboardViewIdSerializer |
| 4443 | filter_backends = (filters.DjangoFilterBackend,) |
| 4444 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 4445 | |
| 4446 | def get_serializer_class(self): |
| 4447 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4448 | if (no_hyperlinks): |
| 4449 | return self.id_serializer_class |
| 4450 | else: |
| 4451 | return self.serializer_class |
| 4452 | |
| 4453 | def get_queryset(self): |
| 4454 | return UserDashboardView.select_by_user(self.request.user) |
| 4455 | |
| 4456 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4457 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4458 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4459 | response = {"error": "validation", |
| 4460 | "specific_error": "not serializer.is_valid()",
|
| 4461 | "reasons": serializer.errors}
|
| 4462 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4463 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4464 | obj.caller = request.user |
| 4465 | if obj.can_update(request.user): |
| 4466 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4467 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4468 | raise Exception("failed obj.can_update") |
| 4469 | |
| 4470 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4471 | if (ret.status_code%100 != 200): |
| 4472 | raise Exception(ret.data) |
| 4473 | |
| 4474 | return ret |
| 4475 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4476 | |
| 4477 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4478 | queryset = UserDashboardView.objects.select_related().all() |
| 4479 | serializer_class = UserDashboardViewSerializer |
| 4480 | id_serializer_class = UserDashboardViewIdSerializer |
| 4481 | |
| 4482 | def get_serializer_class(self): |
| 4483 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4484 | if (no_hyperlinks): |
| 4485 | return self.id_serializer_class |
| 4486 | else: |
| 4487 | return self.serializer_class |
| 4488 | |
| 4489 | def get_queryset(self): |
| 4490 | return UserDashboardView.select_by_user(self.request.user) |
| 4491 | |
| 4492 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4493 | |
| 4494 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4495 | |
| 4496 | |
| 4497 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4498 | class ControllerList(generics.ListCreateAPIView): |
| 4499 | queryset = Controller.objects.select_related().all() |
| 4500 | serializer_class = ControllerSerializer |
| 4501 | id_serializer_class = ControllerIdSerializer |
| 4502 | filter_backends = (filters.DjangoFilterBackend,) |
| 4503 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 4504 | |
| 4505 | def get_serializer_class(self): |
| 4506 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4507 | if (no_hyperlinks): |
| 4508 | return self.id_serializer_class |
| 4509 | else: |
| 4510 | return self.serializer_class |
| 4511 | |
| 4512 | def get_queryset(self): |
| 4513 | return Controller.select_by_user(self.request.user) |
| 4514 | |
| 4515 | def create(self, request, *args, **kwargs): |
| 4516 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4517 | if not (serializer.is_valid()): |
| 4518 | response = {"error": "validation", |
| 4519 | "specific_error": "not serializer.is_valid()",
|
| 4520 | "reasons": serializer.errors}
|
| 4521 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4522 | obj = serializer.object |
| 4523 | obj.caller = request.user |
| 4524 | if obj.can_update(request.user): |
| 4525 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4526 | else: |
| 4527 | raise Exception("failed obj.can_update") |
| 4528 | |
| 4529 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 4530 | if (ret.status_code%100 != 200): |
| 4531 | raise Exception(ret.data) |
| 4532 | |
| 4533 | return ret |
| 4534 | |
| 4535 | |
| 4536 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4537 | queryset = Controller.objects.select_related().all() |
| 4538 | serializer_class = ControllerSerializer |
| 4539 | id_serializer_class = ControllerIdSerializer |
| 4540 | |
| 4541 | def get_serializer_class(self): |
| 4542 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4543 | if (no_hyperlinks): |
| 4544 | return self.id_serializer_class |
| 4545 | else: |
| 4546 | return self.serializer_class |
| 4547 | |
| 4548 | def get_queryset(self): |
| 4549 | return Controller.select_by_user(self.request.user) |
| 4550 | |
| 4551 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4552 | |
| 4553 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4554 | |
| 4555 | |
| 4556 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4557 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 4558 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4559 | serializer_class = PlanetStackPrivilegeSerializer |
| 4560 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4561 | filter_backends = (filters.DjangoFilterBackend,) |
| 4562 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 4563 | |
| 4564 | def get_serializer_class(self): |
| 4565 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4566 | if (no_hyperlinks): |
| 4567 | return self.id_serializer_class |
| 4568 | else: |
| 4569 | return self.serializer_class |
| 4570 | |
| 4571 | def get_queryset(self): |
| 4572 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4573 | |
| 4574 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4575 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4576 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4577 | response = {"error": "validation", |
| 4578 | "specific_error": "not serializer.is_valid()",
|
| 4579 | "reasons": serializer.errors}
|
| 4580 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4581 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4582 | obj.caller = request.user |
| 4583 | if obj.can_update(request.user): |
| 4584 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4585 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4586 | raise Exception("failed obj.can_update") |
| 4587 | |
| 4588 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4589 | if (ret.status_code%100 != 200): |
| 4590 | raise Exception(ret.data) |
| 4591 | |
| 4592 | return ret |
| 4593 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4594 | |
| 4595 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4596 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4597 | serializer_class = PlanetStackPrivilegeSerializer |
| 4598 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4599 | |
| 4600 | def get_serializer_class(self): |
| 4601 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4602 | if (no_hyperlinks): |
| 4603 | return self.id_serializer_class |
| 4604 | else: |
| 4605 | return self.serializer_class |
| 4606 | |
| 4607 | def get_queryset(self): |
| 4608 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4609 | |
| 4610 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4611 | |
| 4612 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4613 | |
| 4614 | |
| 4615 | |
| 4616 | class UserList(generics.ListCreateAPIView): |
| 4617 | queryset = User.objects.select_related().all() |
| 4618 | serializer_class = UserSerializer |
| 4619 | id_serializer_class = UserIdSerializer |
| 4620 | filter_backends = (filters.DjangoFilterBackend,) |
| 4621 | filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',) |
| 4622 | |
| 4623 | def get_serializer_class(self): |
| 4624 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4625 | if (no_hyperlinks): |
| 4626 | return self.id_serializer_class |
| 4627 | else: |
| 4628 | return self.serializer_class |
| 4629 | |
| 4630 | def get_queryset(self): |
| 4631 | return User.select_by_user(self.request.user) |
| 4632 | |
| 4633 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4634 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4635 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4636 | response = {"error": "validation", |
| 4637 | "specific_error": "not serializer.is_valid()",
|
| 4638 | "reasons": serializer.errors}
|
| 4639 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4640 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4641 | obj.caller = request.user |
| 4642 | if obj.can_update(request.user): |
| 4643 | return super(UserList, self).create(request, *args, **kwargs) |
| 4644 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4645 | raise Exception("failed obj.can_update") |
| 4646 | |
| 4647 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 4648 | if (ret.status_code%100 != 200): |
| 4649 | raise Exception(ret.data) |
| 4650 | |
| 4651 | return ret |
| 4652 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4653 | |
| 4654 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4655 | queryset = User.objects.select_related().all() |
| 4656 | serializer_class = UserSerializer |
| 4657 | id_serializer_class = UserIdSerializer |
| 4658 | |
| 4659 | def get_serializer_class(self): |
| 4660 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4661 | if (no_hyperlinks): |
| 4662 | return self.id_serializer_class |
| 4663 | else: |
| 4664 | return self.serializer_class |
| 4665 | |
| 4666 | def get_queryset(self): |
| 4667 | return User.select_by_user(self.request.user) |
| 4668 | |
| 4669 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4670 | |
| 4671 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4672 | |
| 4673 | |
| 4674 | |
| 4675 | class DeploymentList(generics.ListCreateAPIView): |
| 4676 | queryset = Deployment.objects.select_related().all() |
| 4677 | serializer_class = DeploymentSerializer |
| 4678 | id_serializer_class = DeploymentIdSerializer |
| 4679 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 4680 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4681 | |
| 4682 | def get_serializer_class(self): |
| 4683 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4684 | if (no_hyperlinks): |
| 4685 | return self.id_serializer_class |
| 4686 | else: |
| 4687 | return self.serializer_class |
| 4688 | |
| 4689 | def get_queryset(self): |
| 4690 | return Deployment.select_by_user(self.request.user) |
| 4691 | |
| 4692 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4693 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4694 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4695 | response = {"error": "validation", |
| 4696 | "specific_error": "not serializer.is_valid()",
|
| 4697 | "reasons": serializer.errors}
|
| 4698 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4699 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4700 | obj.caller = request.user |
| 4701 | if obj.can_update(request.user): |
| 4702 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 4703 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4704 | raise Exception("failed obj.can_update") |
| 4705 | |
| 4706 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 4707 | if (ret.status_code%100 != 200): |
| 4708 | raise Exception(ret.data) |
| 4709 | |
| 4710 | return ret |
| 4711 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4712 | |
| 4713 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4714 | queryset = Deployment.objects.select_related().all() |
| 4715 | serializer_class = DeploymentSerializer |
| 4716 | id_serializer_class = DeploymentIdSerializer |
| 4717 | |
| 4718 | def get_serializer_class(self): |
| 4719 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4720 | if (no_hyperlinks): |
| 4721 | return self.id_serializer_class |
| 4722 | else: |
| 4723 | return self.serializer_class |
| 4724 | |
| 4725 | def get_queryset(self): |
| 4726 | return Deployment.select_by_user(self.request.user) |
| 4727 | |
| 4728 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4729 | |
| 4730 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4731 | |
| 4732 | |
| 4733 | |
| 4734 | class ReservationList(generics.ListCreateAPIView): |
| 4735 | queryset = Reservation.objects.select_related().all() |
| 4736 | serializer_class = ReservationSerializer |
| 4737 | id_serializer_class = ReservationIdSerializer |
| 4738 | filter_backends = (filters.DjangoFilterBackend,) |
| 4739 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 4740 | |
| 4741 | def get_serializer_class(self): |
| 4742 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4743 | if (no_hyperlinks): |
| 4744 | return self.id_serializer_class |
| 4745 | else: |
| 4746 | return self.serializer_class |
| 4747 | |
| 4748 | def get_queryset(self): |
| 4749 | return Reservation.select_by_user(self.request.user) |
| 4750 | |
| 4751 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4752 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4753 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4754 | response = {"error": "validation", |
| 4755 | "specific_error": "not serializer.is_valid()",
|
| 4756 | "reasons": serializer.errors}
|
| 4757 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4758 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4759 | obj.caller = request.user |
| 4760 | if obj.can_update(request.user): |
| 4761 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 4762 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4763 | raise Exception("failed obj.can_update") |
| 4764 | |
| 4765 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 4766 | if (ret.status_code%100 != 200): |
| 4767 | raise Exception(ret.data) |
| 4768 | |
| 4769 | return ret |
| 4770 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4771 | |
| 4772 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4773 | queryset = Reservation.objects.select_related().all() |
| 4774 | serializer_class = ReservationSerializer |
| 4775 | id_serializer_class = ReservationIdSerializer |
| 4776 | |
| 4777 | def get_serializer_class(self): |
| 4778 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4779 | if (no_hyperlinks): |
| 4780 | return self.id_serializer_class |
| 4781 | else: |
| 4782 | return self.serializer_class |
| 4783 | |
| 4784 | def get_queryset(self): |
| 4785 | return Reservation.select_by_user(self.request.user) |
| 4786 | |
| 4787 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4788 | |
| 4789 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4790 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4791 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4792 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4793 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 4794 | queryset = SitePrivilege.objects.select_related().all() |
| 4795 | serializer_class = SitePrivilegeSerializer |
| 4796 | id_serializer_class = SitePrivilegeIdSerializer |
| 4797 | filter_backends = (filters.DjangoFilterBackend,) |
| 4798 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 4799 | |
| 4800 | def get_serializer_class(self): |
| 4801 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4802 | if (no_hyperlinks): |
| 4803 | return self.id_serializer_class |
| 4804 | else: |
| 4805 | return self.serializer_class |
| 4806 | |
| 4807 | def get_queryset(self): |
| 4808 | return SitePrivilege.select_by_user(self.request.user) |
| 4809 | |
| 4810 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4811 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4812 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4813 | response = {"error": "validation", |
| 4814 | "specific_error": "not serializer.is_valid()",
|
| 4815 | "reasons": serializer.errors}
|
| 4816 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4817 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4818 | obj.caller = request.user |
| 4819 | if obj.can_update(request.user): |
| 4820 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4821 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4822 | raise Exception("failed obj.can_update") |
| 4823 | |
| 4824 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4825 | if (ret.status_code%100 != 200): |
| 4826 | raise Exception(ret.data) |
| 4827 | |
| 4828 | return ret |
| 4829 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4830 | |
| 4831 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4832 | queryset = SitePrivilege.objects.select_related().all() |
| 4833 | serializer_class = SitePrivilegeSerializer |
| 4834 | id_serializer_class = SitePrivilegeIdSerializer |
| 4835 | |
| 4836 | def get_serializer_class(self): |
| 4837 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4838 | if (no_hyperlinks): |
| 4839 | return self.id_serializer_class |
| 4840 | else: |
| 4841 | return self.serializer_class |
| 4842 | |
| 4843 | def get_queryset(self): |
| 4844 | return SitePrivilege.select_by_user(self.request.user) |
| 4845 | |
| 4846 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4847 | |
| 4848 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4849 | |
| 4850 | |
| 4851 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4852 | class PlanetStackList(generics.ListCreateAPIView): |
| 4853 | queryset = PlanetStack.objects.select_related().all() |
| 4854 | serializer_class = PlanetStackSerializer |
| 4855 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4856 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4857 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4858 | |
| 4859 | def get_serializer_class(self): |
| 4860 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4861 | if (no_hyperlinks): |
| 4862 | return self.id_serializer_class |
| 4863 | else: |
| 4864 | return self.serializer_class |
| 4865 | |
| 4866 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4867 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4868 | |
| 4869 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4870 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4871 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4872 | response = {"error": "validation", |
| 4873 | "specific_error": "not serializer.is_valid()",
|
| 4874 | "reasons": serializer.errors}
|
| 4875 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4876 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4877 | obj.caller = request.user |
| 4878 | if obj.can_update(request.user): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4879 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4880 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4881 | raise Exception("failed obj.can_update") |
| 4882 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4883 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4884 | if (ret.status_code%100 != 200): |
| 4885 | raise Exception(ret.data) |
| 4886 | |
| 4887 | return ret |
| 4888 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4889 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4890 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4891 | queryset = PlanetStack.objects.select_related().all() |
| 4892 | serializer_class = PlanetStackSerializer |
| 4893 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4894 | |
| 4895 | def get_serializer_class(self): |
| 4896 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4897 | if (no_hyperlinks): |
| 4898 | return self.id_serializer_class |
| 4899 | else: |
| 4900 | return self.serializer_class |
| 4901 | |
| 4902 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4903 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4904 | |
| 4905 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4906 | |
| 4907 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4908 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4909 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4910 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 4911 | class ControllerDashboardViewList(generics.ListCreateAPIView): |
| 4912 | queryset = ControllerDashboardView.objects.select_related().all() |
| 4913 | serializer_class = ControllerDashboardViewSerializer |
| 4914 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 4915 | filter_backends = (filters.DjangoFilterBackend,) |
| 4916 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 4917 | |
| 4918 | def get_serializer_class(self): |
| 4919 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4920 | if (no_hyperlinks): |
| 4921 | return self.id_serializer_class |
| 4922 | else: |
| 4923 | return self.serializer_class |
| 4924 | |
| 4925 | def get_queryset(self): |
| 4926 | return ControllerDashboardView.select_by_user(self.request.user) |
| 4927 | |
| 4928 | def create(self, request, *args, **kwargs): |
| 4929 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4930 | if not (serializer.is_valid()): |
| 4931 | response = {"error": "validation", |
| 4932 | "specific_error": "not serializer.is_valid()",
|
| 4933 | "reasons": serializer.errors}
|
| 4934 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4935 | obj = serializer.object |
| 4936 | obj.caller = request.user |
| 4937 | if obj.can_update(request.user): |
| 4938 | return super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 4939 | else: |
| 4940 | raise Exception("failed obj.can_update") |
| 4941 | |
| 4942 | ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 4943 | if (ret.status_code%100 != 200): |
| 4944 | raise Exception(ret.data) |
| 4945 | |
| 4946 | return ret |
| 4947 | |
| 4948 | |
| 4949 | class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4950 | queryset = ControllerDashboardView.objects.select_related().all() |
| 4951 | serializer_class = ControllerDashboardViewSerializer |
| 4952 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 4953 | |
| 4954 | def get_serializer_class(self): |
| 4955 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4956 | if (no_hyperlinks): |
| 4957 | return self.id_serializer_class |
| 4958 | else: |
| 4959 | return self.serializer_class |
| 4960 | |
| 4961 | def get_queryset(self): |
| 4962 | return ControllerDashboardView.select_by_user(self.request.user) |
| 4963 | |
| 4964 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4965 | |
| 4966 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4967 | |
| 4968 | |
| 4969 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4970 | class AccountList(generics.ListCreateAPIView): |
| 4971 | queryset = Account.objects.select_related().all() |
| 4972 | serializer_class = AccountSerializer |
| 4973 | id_serializer_class = AccountIdSerializer |
| 4974 | filter_backends = (filters.DjangoFilterBackend,) |
| 4975 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 4976 | |
| 4977 | def get_serializer_class(self): |
| 4978 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4979 | if (no_hyperlinks): |
| 4980 | return self.id_serializer_class |
| 4981 | else: |
| 4982 | return self.serializer_class |
| 4983 | |
| 4984 | def get_queryset(self): |
| 4985 | return Account.select_by_user(self.request.user) |
| 4986 | |
| 4987 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4988 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4989 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4990 | response = {"error": "validation", |
| 4991 | "specific_error": "not serializer.is_valid()",
|
| 4992 | "reasons": serializer.errors}
|
| 4993 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4994 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4995 | obj.caller = request.user |
| 4996 | if obj.can_update(request.user): |
| 4997 | return super(AccountList, self).create(request, *args, **kwargs) |
| 4998 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4999 | raise Exception("failed obj.can_update") |
| 5000 | |
| 5001 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 5002 | if (ret.status_code%100 != 200): |
| 5003 | raise Exception(ret.data) |
| 5004 | |
| 5005 | return ret |
| 5006 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5007 | |
| 5008 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5009 | queryset = Account.objects.select_related().all() |
| 5010 | serializer_class = AccountSerializer |
| 5011 | id_serializer_class = AccountIdSerializer |
| 5012 | |
| 5013 | def get_serializer_class(self): |
| 5014 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5015 | if (no_hyperlinks): |
| 5016 | return self.id_serializer_class |
| 5017 | else: |
| 5018 | return self.serializer_class |
| 5019 | |
| 5020 | def get_queryset(self): |
| 5021 | return Account.select_by_user(self.request.user) |
| 5022 | |
| 5023 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5024 | |
| 5025 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5026 | |
| 5027 | |
| 5028 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5029 | class ControllerRoleList(generics.ListCreateAPIView): |
| 5030 | queryset = ControllerRole.objects.select_related().all() |
| 5031 | serializer_class = ControllerRoleSerializer |
| 5032 | id_serializer_class = ControllerRoleIdSerializer |
| 5033 | filter_backends = (filters.DjangoFilterBackend,) |
| 5034 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5035 | |
| 5036 | def get_serializer_class(self): |
| 5037 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5038 | if (no_hyperlinks): |
| 5039 | return self.id_serializer_class |
| 5040 | else: |
| 5041 | return self.serializer_class |
| 5042 | |
| 5043 | def get_queryset(self): |
| 5044 | return ControllerRole.select_by_user(self.request.user) |
| 5045 | |
| 5046 | def create(self, request, *args, **kwargs): |
| 5047 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5048 | if not (serializer.is_valid()): |
| 5049 | response = {"error": "validation", |
| 5050 | "specific_error": "not serializer.is_valid()",
|
| 5051 | "reasons": serializer.errors}
|
| 5052 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5053 | obj = serializer.object |
| 5054 | obj.caller = request.user |
| 5055 | if obj.can_update(request.user): |
| 5056 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5057 | else: |
| 5058 | raise Exception("failed obj.can_update") |
| 5059 | |
| 5060 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5061 | if (ret.status_code%100 != 200): |
| 5062 | raise Exception(ret.data) |
| 5063 | |
| 5064 | return ret |
| 5065 | |
| 5066 | |
| 5067 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5068 | queryset = ControllerRole.objects.select_related().all() |
| 5069 | serializer_class = ControllerRoleSerializer |
| 5070 | id_serializer_class = ControllerRoleIdSerializer |
| 5071 | |
| 5072 | def get_serializer_class(self): |
| 5073 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5074 | if (no_hyperlinks): |
| 5075 | return self.id_serializer_class |
| 5076 | else: |
| 5077 | return self.serializer_class |
| 5078 | |
| 5079 | def get_queryset(self): |
| 5080 | return ControllerRole.select_by_user(self.request.user) |
| 5081 | |
| 5082 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5083 | |
| 5084 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5085 | |
| 5086 | |
| 5087 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5088 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 5089 | queryset = NetworkParameterType.objects.select_related().all() |
| 5090 | serializer_class = NetworkParameterTypeSerializer |
| 5091 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5092 | filter_backends = (filters.DjangoFilterBackend,) |
| 5093 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 5094 | |
| 5095 | def get_serializer_class(self): |
| 5096 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5097 | if (no_hyperlinks): |
| 5098 | return self.id_serializer_class |
| 5099 | else: |
| 5100 | return self.serializer_class |
| 5101 | |
| 5102 | def get_queryset(self): |
| 5103 | return NetworkParameterType.select_by_user(self.request.user) |
| 5104 | |
| 5105 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5106 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5107 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5108 | response = {"error": "validation", |
| 5109 | "specific_error": "not serializer.is_valid()",
|
| 5110 | "reasons": serializer.errors}
|
| 5111 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5112 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5113 | obj.caller = request.user |
| 5114 | if obj.can_update(request.user): |
| 5115 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5116 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5117 | raise Exception("failed obj.can_update") |
| 5118 | |
| 5119 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5120 | if (ret.status_code%100 != 200): |
| 5121 | raise Exception(ret.data) |
| 5122 | |
| 5123 | return ret |
| 5124 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5125 | |
| 5126 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5127 | queryset = NetworkParameterType.objects.select_related().all() |
| 5128 | serializer_class = NetworkParameterTypeSerializer |
| 5129 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5130 | |
| 5131 | def get_serializer_class(self): |
| 5132 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5133 | if (no_hyperlinks): |
| 5134 | return self.id_serializer_class |
| 5135 | else: |
| 5136 | return self.serializer_class |
| 5137 | |
| 5138 | def get_queryset(self): |
| 5139 | return NetworkParameterType.select_by_user(self.request.user) |
| 5140 | |
| 5141 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5142 | |
| 5143 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5144 | |
| 5145 | |
| 5146 | |
| 5147 | class SiteCredentialList(generics.ListCreateAPIView): |
| 5148 | queryset = SiteCredential.objects.select_related().all() |
| 5149 | serializer_class = SiteCredentialSerializer |
| 5150 | id_serializer_class = SiteCredentialIdSerializer |
| 5151 | filter_backends = (filters.DjangoFilterBackend,) |
| 5152 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 5153 | |
| 5154 | def get_serializer_class(self): |
| 5155 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5156 | if (no_hyperlinks): |
| 5157 | return self.id_serializer_class |
| 5158 | else: |
| 5159 | return self.serializer_class |
| 5160 | |
| 5161 | def get_queryset(self): |
| 5162 | return SiteCredential.select_by_user(self.request.user) |
| 5163 | |
| 5164 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5165 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5166 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5167 | response = {"error": "validation", |
| 5168 | "specific_error": "not serializer.is_valid()",
|
| 5169 | "reasons": serializer.errors}
|
| 5170 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5171 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5172 | obj.caller = request.user |
| 5173 | if obj.can_update(request.user): |
| 5174 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5175 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5176 | raise Exception("failed obj.can_update") |
| 5177 | |
| 5178 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5179 | if (ret.status_code%100 != 200): |
| 5180 | raise Exception(ret.data) |
| 5181 | |
| 5182 | return ret |
| 5183 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5184 | |
| 5185 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5186 | queryset = SiteCredential.objects.select_related().all() |
| 5187 | serializer_class = SiteCredentialSerializer |
| 5188 | id_serializer_class = SiteCredentialIdSerializer |
| 5189 | |
| 5190 | def get_serializer_class(self): |
| 5191 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5192 | if (no_hyperlinks): |
| 5193 | return self.id_serializer_class |
| 5194 | else: |
| 5195 | return self.serializer_class |
| 5196 | |
| 5197 | def get_queryset(self): |
| 5198 | return SiteCredential.select_by_user(self.request.user) |
| 5199 | |
| 5200 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5201 | |
| 5202 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5203 | |
| 5204 | |
| 5205 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5206 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 5207 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5208 | serializer_class = DeploymentPrivilegeSerializer |
| 5209 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5210 | filter_backends = (filters.DjangoFilterBackend,) |
| 5211 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 5212 | |
| 5213 | def get_serializer_class(self): |
| 5214 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5215 | if (no_hyperlinks): |
| 5216 | return self.id_serializer_class |
| 5217 | else: |
| 5218 | return self.serializer_class |
| 5219 | |
| 5220 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5221 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5222 | |
| 5223 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5224 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5225 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5226 | response = {"error": "validation", |
| 5227 | "specific_error": "not serializer.is_valid()",
|
| 5228 | "reasons": serializer.errors}
|
| 5229 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5230 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5231 | obj.caller = request.user |
| 5232 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5233 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5234 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5235 | raise Exception("failed obj.can_update") |
| 5236 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5237 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5238 | if (ret.status_code%100 != 200): |
| 5239 | raise Exception(ret.data) |
| 5240 | |
| 5241 | return ret |
| 5242 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5243 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5244 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5245 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5246 | serializer_class = DeploymentPrivilegeSerializer |
| 5247 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5248 | |
| 5249 | def get_serializer_class(self): |
| 5250 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5251 | if (no_hyperlinks): |
| 5252 | return self.id_serializer_class |
| 5253 | else: |
| 5254 | return self.serializer_class |
| 5255 | |
| 5256 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5257 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5258 | |
| 5259 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5260 | |
| 5261 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5262 | |
| 5263 | |
| 5264 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5265 | class ControllerUsersList(generics.ListCreateAPIView): |
| 5266 | queryset = ControllerUsers.objects.select_related().all() |
| 5267 | serializer_class = ControllerUsersSerializer |
| 5268 | id_serializer_class = ControllerUsersIdSerializer |
| 5269 | filter_backends = (filters.DjangoFilterBackend,) |
| 5270 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 5271 | |
| 5272 | def get_serializer_class(self): |
| 5273 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5274 | if (no_hyperlinks): |
| 5275 | return self.id_serializer_class |
| 5276 | else: |
| 5277 | return self.serializer_class |
| 5278 | |
| 5279 | def get_queryset(self): |
| 5280 | return ControllerUsers.select_by_user(self.request.user) |
| 5281 | |
| 5282 | def create(self, request, *args, **kwargs): |
| 5283 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5284 | if not (serializer.is_valid()): |
| 5285 | response = {"error": "validation", |
| 5286 | "specific_error": "not serializer.is_valid()",
|
| 5287 | "reasons": serializer.errors}
|
| 5288 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5289 | obj = serializer.object |
| 5290 | obj.caller = request.user |
| 5291 | if obj.can_update(request.user): |
| 5292 | return super(ControllerUsersList, self).create(request, *args, **kwargs) |
| 5293 | else: |
| 5294 | raise Exception("failed obj.can_update") |
| 5295 | |
| 5296 | ret = super(ControllerUsersList, self).create(request, *args, **kwargs) |
| 5297 | if (ret.status_code%100 != 200): |
| 5298 | raise Exception(ret.data) |
| 5299 | |
| 5300 | return ret |
| 5301 | |
| 5302 | |
| 5303 | class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5304 | queryset = ControllerUsers.objects.select_related().all() |
| 5305 | serializer_class = ControllerUsersSerializer |
| 5306 | id_serializer_class = ControllerUsersIdSerializer |
| 5307 | |
| 5308 | def get_serializer_class(self): |
| 5309 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5310 | if (no_hyperlinks): |
| 5311 | return self.id_serializer_class |
| 5312 | else: |
| 5313 | return self.serializer_class |
| 5314 | |
| 5315 | def get_queryset(self): |
| 5316 | return ControllerUsers.select_by_user(self.request.user) |
| 5317 | |
| 5318 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5319 | |
| 5320 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5321 | |
| 5322 | |
| 5323 | |
| 5324 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 5325 | queryset = DeploymentRole.objects.select_related().all() |
| 5326 | serializer_class = DeploymentRoleSerializer |
| 5327 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5328 | filter_backends = (filters.DjangoFilterBackend,) |
| 5329 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5330 | |
| 5331 | def get_serializer_class(self): |
| 5332 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5333 | if (no_hyperlinks): |
| 5334 | return self.id_serializer_class |
| 5335 | else: |
| 5336 | return self.serializer_class |
| 5337 | |
| 5338 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5339 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5340 | |
| 5341 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5342 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5343 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5344 | response = {"error": "validation", |
| 5345 | "specific_error": "not serializer.is_valid()",
|
| 5346 | "reasons": serializer.errors}
|
| 5347 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5348 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5349 | obj.caller = request.user |
| 5350 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5351 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5352 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5353 | raise Exception("failed obj.can_update") |
| 5354 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5355 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5356 | if (ret.status_code%100 != 200): |
| 5357 | raise Exception(ret.data) |
| 5358 | |
| 5359 | return ret |
| 5360 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5361 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5362 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5363 | queryset = DeploymentRole.objects.select_related().all() |
| 5364 | serializer_class = DeploymentRoleSerializer |
| 5365 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5366 | |
| 5367 | def get_serializer_class(self): |
| 5368 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5369 | if (no_hyperlinks): |
| 5370 | return self.id_serializer_class |
| 5371 | else: |
| 5372 | return self.serializer_class |
| 5373 | |
| 5374 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5375 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5376 | |
| 5377 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5378 | |
| 5379 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5380 | |
| 5381 | |
| 5382 | |
| 5383 | class UserCredentialList(generics.ListCreateAPIView): |
| 5384 | queryset = UserCredential.objects.select_related().all() |
| 5385 | serializer_class = UserCredentialSerializer |
| 5386 | id_serializer_class = UserCredentialIdSerializer |
| 5387 | filter_backends = (filters.DjangoFilterBackend,) |
| 5388 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 5389 | |
| 5390 | def get_serializer_class(self): |
| 5391 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5392 | if (no_hyperlinks): |
| 5393 | return self.id_serializer_class |
| 5394 | else: |
| 5395 | return self.serializer_class |
| 5396 | |
| 5397 | def get_queryset(self): |
| 5398 | return UserCredential.select_by_user(self.request.user) |
| 5399 | |
| 5400 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5401 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5402 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5403 | response = {"error": "validation", |
| 5404 | "specific_error": "not serializer.is_valid()",
|
| 5405 | "reasons": serializer.errors}
|
| 5406 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5407 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5408 | obj.caller = request.user |
| 5409 | if obj.can_update(request.user): |
| 5410 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5411 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5412 | raise Exception("failed obj.can_update") |
| 5413 | |
| 5414 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5415 | if (ret.status_code%100 != 200): |
| 5416 | raise Exception(ret.data) |
| 5417 | |
| 5418 | return ret |
| 5419 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5420 | |
| 5421 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5422 | queryset = UserCredential.objects.select_related().all() |
| 5423 | serializer_class = UserCredentialSerializer |
| 5424 | id_serializer_class = UserCredentialIdSerializer |
| 5425 | |
| 5426 | def get_serializer_class(self): |
| 5427 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5428 | if (no_hyperlinks): |
| 5429 | return self.id_serializer_class |
| 5430 | else: |
| 5431 | return self.serializer_class |
| 5432 | |
| 5433 | def get_queryset(self): |
| 5434 | return UserCredential.select_by_user(self.request.user) |
| 5435 | |
| 5436 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5437 | |
| 5438 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5439 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5440 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5441 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5442 | class SiteDeploymentsList(generics.ListCreateAPIView): |
| 5443 | queryset = SiteDeployments.objects.select_related().all() |
| 5444 | serializer_class = SiteDeploymentsSerializer |
| 5445 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5446 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5447 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5448 | |
| 5449 | def get_serializer_class(self): |
| 5450 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5451 | if (no_hyperlinks): |
| 5452 | return self.id_serializer_class |
| 5453 | else: |
| 5454 | return self.serializer_class |
| 5455 | |
| 5456 | def get_queryset(self): |
| 5457 | return SiteDeployments.select_by_user(self.request.user) |
| 5458 | |
| 5459 | def create(self, request, *args, **kwargs): |
| 5460 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5461 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5462 | response = {"error": "validation", |
| 5463 | "specific_error": "not serializer.is_valid()",
|
| 5464 | "reasons": serializer.errors}
|
| 5465 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5466 | obj = serializer.object |
| 5467 | obj.caller = request.user |
| 5468 | if obj.can_update(request.user): |
| 5469 | return super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 5470 | else: |
| 5471 | raise Exception("failed obj.can_update") |
| 5472 | |
| 5473 | ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 5474 | if (ret.status_code%100 != 200): |
| 5475 | raise Exception(ret.data) |
| 5476 | |
| 5477 | return ret |
| 5478 | |
| 5479 | |
| 5480 | class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5481 | queryset = SiteDeployments.objects.select_related().all() |
| 5482 | serializer_class = SiteDeploymentsSerializer |
| 5483 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5484 | |
| 5485 | def get_serializer_class(self): |
| 5486 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5487 | if (no_hyperlinks): |
| 5488 | return self.id_serializer_class |
| 5489 | else: |
| 5490 | return self.serializer_class |
| 5491 | |
| 5492 | def get_queryset(self): |
| 5493 | return SiteDeployments.select_by_user(self.request.user) |
| 5494 | |
| 5495 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5496 | |
| 5497 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5498 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5499 | |
| 5500 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5501 | class SliceTagList(generics.ListCreateAPIView): |
| 5502 | queryset = SliceTag.objects.select_related().all() |
| 5503 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5504 | id_serializer_class = SliceTagIdSerializer |
| 5505 | filter_backends = (filters.DjangoFilterBackend,) |
| 5506 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 5507 | |
| 5508 | def get_serializer_class(self): |
| 5509 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5510 | if (no_hyperlinks): |
| 5511 | return self.id_serializer_class |
| 5512 | else: |
| 5513 | return self.serializer_class |
| 5514 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5515 | def get_queryset(self): |
| 5516 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5517 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5518 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5519 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5520 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5521 | response = {"error": "validation", |
| 5522 | "specific_error": "not serializer.is_valid()",
|
| 5523 | "reasons": serializer.errors}
|
| 5524 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5525 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5526 | obj.caller = request.user |
| 5527 | if obj.can_update(request.user): |
| 5528 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 5529 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5530 | raise Exception("failed obj.can_update") |
| 5531 | |
| 5532 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 5533 | if (ret.status_code%100 != 200): |
| 5534 | raise Exception(ret.data) |
| 5535 | |
| 5536 | return ret |
| 5537 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5538 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5539 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5540 | queryset = SliceTag.objects.select_related().all() |
| 5541 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5542 | id_serializer_class = SliceTagIdSerializer |
| 5543 | |
| 5544 | def get_serializer_class(self): |
| 5545 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5546 | if (no_hyperlinks): |
| 5547 | return self.id_serializer_class |
| 5548 | else: |
| 5549 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5550 | |
| 5551 | def get_queryset(self): |
| 5552 | return SliceTag.select_by_user(self.request.user) |
| 5553 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5554 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5555 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5556 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5557 | |
| 5558 | |
| 5559 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5560 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 5561 | queryset = NetworkTemplate.objects.select_related().all() |
| 5562 | serializer_class = NetworkTemplateSerializer |
| 5563 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5564 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5565 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5566 | |
| 5567 | def get_serializer_class(self): |
| 5568 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5569 | if (no_hyperlinks): |
| 5570 | return self.id_serializer_class |
| 5571 | else: |
| 5572 | return self.serializer_class |
| 5573 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5574 | def get_queryset(self): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5575 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5576 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5577 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5578 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5579 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5580 | response = {"error": "validation", |
| 5581 | "specific_error": "not serializer.is_valid()",
|
| 5582 | "reasons": serializer.errors}
|
| 5583 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5584 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5585 | obj.caller = request.user |
| 5586 | if obj.can_update(request.user): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5587 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5588 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5589 | raise Exception("failed obj.can_update") |
| 5590 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5591 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5592 | if (ret.status_code%100 != 200): |
| 5593 | raise Exception(ret.data) |
| 5594 | |
| 5595 | return ret |
| 5596 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5597 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5598 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5599 | queryset = NetworkTemplate.objects.select_related().all() |
| 5600 | serializer_class = NetworkTemplateSerializer |
| 5601 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5602 | |
| 5603 | def get_serializer_class(self): |
| 5604 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5605 | if (no_hyperlinks): |
| 5606 | return self.id_serializer_class |
| 5607 | else: |
| 5608 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5609 | |
| 5610 | def get_queryset(self): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5611 | return NetworkTemplate.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5612 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5613 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5614 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5615 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5616 | |
| 5617 | |
| 5618 | |
| 5619 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5620 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5621 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5622 | id_serializer_class = RouterIdSerializer |
| 5623 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5624 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5625 | |
| 5626 | def get_serializer_class(self): |
| 5627 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5628 | if (no_hyperlinks): |
| 5629 | return self.id_serializer_class |
| 5630 | else: |
| 5631 | return self.serializer_class |
| 5632 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5633 | def get_queryset(self): |
| 5634 | return Router.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 | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5644 | obj.caller = request.user |
| 5645 | if obj.can_update(request.user): |
| 5646 | return super(RouterList, 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(RouterList, self).create(request, *args, **kwargs) |
| 5651 | if (ret.status_code%100 != 200): |
| 5652 | raise Exception(ret.data) |
| 5653 | |
| 5654 | return ret |
| 5655 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5656 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5657 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5658 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5659 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5660 | id_serializer_class = RouterIdSerializer |
| 5661 | |
| 5662 | def get_serializer_class(self): |
| 5663 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5664 | if (no_hyperlinks): |
| 5665 | return self.id_serializer_class |
| 5666 | else: |
| 5667 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5668 | |
| 5669 | def get_queryset(self): |
| 5670 | return Router.select_by_user(self.request.user) |
| 5671 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5672 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5673 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5674 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5675 | |
| 5676 | |
| 5677 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5678 | class ServiceResourceList(generics.ListCreateAPIView): |
| 5679 | queryset = ServiceResource.objects.select_related().all() |
| 5680 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5681 | id_serializer_class = ServiceResourceIdSerializer |
| 5682 | filter_backends = (filters.DjangoFilterBackend,) |
| 5683 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 5684 | |
| 5685 | def get_serializer_class(self): |
| 5686 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5687 | if (no_hyperlinks): |
| 5688 | return self.id_serializer_class |
| 5689 | else: |
| 5690 | return self.serializer_class |
| 5691 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5692 | def get_queryset(self): |
| 5693 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5694 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5695 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5696 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5697 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5698 | response = {"error": "validation", |
| 5699 | "specific_error": "not serializer.is_valid()",
|
| 5700 | "reasons": serializer.errors}
|
| 5701 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5702 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5703 | obj.caller = request.user |
| 5704 | if obj.can_update(request.user): |
| 5705 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5706 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5707 | raise Exception("failed obj.can_update") |
| 5708 | |
| 5709 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5710 | if (ret.status_code%100 != 200): |
| 5711 | raise Exception(ret.data) |
| 5712 | |
| 5713 | return ret |
| 5714 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5715 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5716 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5717 | queryset = ServiceResource.objects.select_related().all() |
| 5718 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5719 | id_serializer_class = ServiceResourceIdSerializer |
| 5720 | |
| 5721 | def get_serializer_class(self): |
| 5722 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5723 | if (no_hyperlinks): |
| 5724 | return self.id_serializer_class |
| 5725 | else: |
| 5726 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5727 | |
| 5728 | def get_queryset(self): |
| 5729 | return ServiceResource.select_by_user(self.request.user) |
| 5730 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5731 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5732 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5733 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5734 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5735 | |
| 5736 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5737 | class ControllerSlicesList(generics.ListCreateAPIView): |
| 5738 | queryset = ControllerSlices.objects.select_related().all() |
| 5739 | serializer_class = ControllerSlicesSerializer |
| 5740 | id_serializer_class = ControllerSlicesIdSerializer |
| 5741 | filter_backends = (filters.DjangoFilterBackend,) |
| 5742 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 5743 | |
| 5744 | def get_serializer_class(self): |
| 5745 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5746 | if (no_hyperlinks): |
| 5747 | return self.id_serializer_class |
| 5748 | else: |
| 5749 | return self.serializer_class |
| 5750 | |
| 5751 | def get_queryset(self): |
| 5752 | return ControllerSlices.select_by_user(self.request.user) |
| 5753 | |
| 5754 | def create(self, request, *args, **kwargs): |
| 5755 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5756 | if not (serializer.is_valid()): |
| 5757 | response = {"error": "validation", |
| 5758 | "specific_error": "not serializer.is_valid()",
|
| 5759 | "reasons": serializer.errors}
|
| 5760 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5761 | obj = serializer.object |
| 5762 | obj.caller = request.user |
| 5763 | if obj.can_update(request.user): |
| 5764 | return super(ControllerSlicesList, self).create(request, *args, **kwargs) |
| 5765 | else: |
| 5766 | raise Exception("failed obj.can_update") |
| 5767 | |
| 5768 | ret = super(ControllerSlicesList, self).create(request, *args, **kwargs) |
| 5769 | if (ret.status_code%100 != 200): |
| 5770 | raise Exception(ret.data) |
| 5771 | |
| 5772 | return ret |
| 5773 | |
| 5774 | |
| 5775 | class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5776 | queryset = ControllerSlices.objects.select_related().all() |
| 5777 | serializer_class = ControllerSlicesSerializer |
| 5778 | id_serializer_class = ControllerSlicesIdSerializer |
| 5779 | |
| 5780 | def get_serializer_class(self): |
| 5781 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5782 | if (no_hyperlinks): |
| 5783 | return self.id_serializer_class |
| 5784 | else: |
| 5785 | return self.serializer_class |
| 5786 | |
| 5787 | def get_queryset(self): |
| 5788 | return ControllerSlices.select_by_user(self.request.user) |
| 5789 | |
| 5790 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5791 | |
| 5792 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5793 | |
| 5794 | |
| 5795 | |