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 | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Scott Baker | f3816ac | 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 | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 11 | from django.conf.urls import patterns, url |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 12 | |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 13 | if hasattr(serializers, "ReadOnlyField"): |
| 14 | # rest_framework 3.x |
| 15 | IdField = serializers.ReadOnlyField |
| 16 | else: |
| 17 | # rest_framework 2.x |
| 18 | IdField = serializers.Field |
| 19 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 20 | """ |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 21 | Schema of the generator object: |
| 22 | all: Set of all Model objects |
| 23 | all_if(regex): Set of Model objects that match regex |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 24 | |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 25 | Model object: |
| 26 | plural: English plural of object name |
| 27 | camel: CamelCase version of object name |
| 28 | refs: list of references to other Model objects |
| 29 | props: list of properties minus refs |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 30 | |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 31 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 32 | """ |
| 33 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 34 | def get_REST_patterns(): |
| 35 | return patterns('', |
| 36 | url(r'^plstackapi/$', api_root), |
| 37 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 38 | url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 39 | url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
| 40 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 41 | url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 42 | url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
| 43 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 44 | url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'), |
| 45 | url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'), |
| 46 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 47 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 48 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
| 49 | |
| 50 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 51 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
| 52 | |
| 53 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 54 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
| 55 | |
| 56 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 57 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
| 58 | |
| 59 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 60 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
| 61 | |
| 62 | url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 63 | url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
| 64 | |
| 65 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 66 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
| 67 | |
| 68 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 69 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
| 70 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 71 | url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'), |
| 72 | url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'), |
| 73 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 74 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 75 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
| 76 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 77 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 78 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 79 | |
| 80 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 81 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 82 | |
| 83 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 84 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 85 | |
| 86 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 87 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 88 | |
| 89 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 90 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 91 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 92 | url(r'plstackapi/controllernetworks/$', ControllerNetworksList.as_view(), name='controllernetworks-list'), |
| 93 | url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworksDetail.as_view(), name ='controllernetworks-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 94 | |
| 95 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 96 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 97 | |
| 98 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 99 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 100 | |
| 101 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 102 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 103 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 104 | url(r'plstackapi/controllersitedeploymentses/$', ControllerSiteDeploymentsList.as_view(), name='controllersitedeployments-list'), |
| 105 | url(r'plstackapi/controllersitedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDeploymentsDetail.as_view(), name ='controllersitedeployments-detail'), |
| 106 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 107 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 108 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 109 | |
| 110 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 111 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 112 | |
| 113 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 114 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 115 | |
| 116 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 117 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 118 | |
| 119 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 120 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 121 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 122 | url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 123 | url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 124 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 125 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 126 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 127 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 128 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 129 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 130 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 131 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 132 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 133 | |
| 134 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 135 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 136 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 137 | url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'), |
| 138 | url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
| 139 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 140 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 141 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 142 | |
| 143 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 144 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 145 | |
| 146 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 147 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
| 148 | |
| 149 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 150 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 151 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 152 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 153 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 154 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 155 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 156 | url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 157 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 158 | url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'), |
| 159 | url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'), |
| 160 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 161 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 162 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 163 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 164 | url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 165 | url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
| 166 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 167 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 168 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 169 | |
| 170 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 171 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 172 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 173 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 174 | url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 175 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 176 | url(r'plstackapi/controllerusers/$', ControllerUsersList.as_view(), name='controllerusers-list'), |
| 177 | url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUsersDetail.as_view(), name ='controllerusers-detail'), |
| 178 | |
| 179 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 180 | url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 181 | |
| 182 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 183 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 184 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 185 | url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'), |
| 186 | url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 187 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 188 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 189 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 190 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 191 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 192 | url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 193 | |
| 194 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 195 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 196 | |
| 197 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 198 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 199 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 200 | url(r'plstackapi/controllerslices/$', ControllerSlicesList.as_view(), name='controllerslices-list'), |
| 201 | url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicesDetail.as_view(), name ='controllerslices-detail'), |
| 202 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 203 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 204 | |
| 205 | @api_view(['GET']) |
| 206 | def api_root(request, format=None): |
| 207 | return Response({ |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 208 | 'flavors': reverse('flavor-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 209 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 210 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 211 | 'images': reverse('image-list', request=request, format=format), |
| 212 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 213 | 'sites': reverse('site-list', request=request, format=format), |
| 214 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 215 | 'tags': reverse('tag-list', request=request, format=format), |
| 216 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 217 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 218 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 219 | 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 220 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 221 | 'projects': reverse('project-list', request=request, format=format), |
| 222 | 'slices': reverse('slice-list', request=request, format=format), |
| 223 | 'networks': reverse('network-list', request=request, format=format), |
| 224 | 'services': reverse('service-list', request=request, format=format), |
| 225 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 226 | 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 227 | 'charges': reverse('charge-list', request=request, format=format), |
| 228 | 'roles': reverse('role-list', request=request, format=format), |
| 229 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 230 | 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 231 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 232 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 233 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 234 | 'nodes': reverse('node-list', request=request, format=format), |
| 235 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 236 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 237 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 238 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 239 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 240 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 241 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 242 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 243 | 'users': reverse('user-list', request=request, format=format), |
| 244 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 245 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 246 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 247 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 248 | 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 249 | 'accounts': reverse('account-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 250 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 251 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 252 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 253 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 254 | 'controlleruserses': reverse('controllerusers-list', request=request, format=format), |
| 255 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 256 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 257 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 258 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 259 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 260 | 'routers': reverse('router-list', request=request, format=format), |
| 261 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 262 | 'controllersliceses': reverse('controllerslices-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 263 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 264 | }) |
| 265 | |
| 266 | # Based on serializers.py |
| 267 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 268 | class XOSModelSerializer(serializers.ModelSerializer): |
| 269 | def save_object(self, obj, **kwargs): |
| 270 | |
| 271 | """ rest_framework can't deal with ManyToMany relations that have a |
| 272 | through table. In plstackapi, most of the through tables we have |
| 273 | use defaults or blank fields, so there's no reason why we shouldn't |
| 274 | be able to save these objects. |
| 275 | |
| 276 | So, let's strip out these m2m relations, and deal with them ourself. |
| 277 | """ |
| 278 | obj._complex_m2m_data={};
|
| 279 | if getattr(obj, '_m2m_data', None):
|
| 280 | for relatedObject in obj._meta.get_all_related_many_to_many_objects():
|
| 281 | if (relatedObject.field.rel.through._meta.auto_created):
|
| 282 | # These are non-trough ManyToMany relations and
|
| 283 | # can be updated just fine
|
| 284 | continue
|
| 285 | fieldName = relatedObject.get_accessor_name()
|
| 286 | if fieldName in obj._m2m_data.keys():
|
| 287 | obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
|
| 288 | del obj._m2m_data[fieldName]
|
| 289 |
|
| 290 | serializers.ModelSerializer.save_object(self, obj, **kwargs); |
| 291 | |
| 292 | for (accessor, stuff) in obj._complex_m2m_data.items(): |
| 293 | (relatedObject, data) = stuff |
| 294 | through = relatedObject.field.rel.through |
| 295 | local_fieldName = relatedObject.field.m2m_reverse_field_name() |
| 296 | remote_fieldName = relatedObject.field.m2m_field_name() |
| 297 | |
| 298 | # get the current set of existing relations |
| 299 | existing = through.objects.filter(**{local_fieldName: obj}); |
| 300 | |
| 301 | data_ids = [item.id for item in data] |
| 302 | existing_ids = [getattr(item,remote_fieldName).id for item in existing] |
| 303 | |
| 304 | #print "data_ids", data_ids |
| 305 | #print "existing_ids", existing_ids |
| 306 | |
| 307 | # remove relations that are in 'existing' but not in 'data' |
| 308 | for item in list(existing): |
| 309 | if (getattr(item,remote_fieldName).id not in data_ids): |
| 310 | print "delete", getattr(item,remote_fieldName) |
| 311 | item.delete() #(purge=True) |
| 312 | |
| 313 | # add relations that are in 'data' but not in 'existing' |
| 314 | for item in data: |
| 315 | if (item.id not in existing_ids): |
| 316 | #print "add", item |
| 317 | newModel = through(**{local_fieldName: obj, remote_fieldName: item}) |
| 318 | newModel.save() |
| 319 | |
| 320 | |
| 321 | |
| 322 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 323 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 324 | |
| 325 | |
| 326 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 327 | |
| 328 | |
| 329 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 330 | validators = serializers.SerializerMethodField("getValidators") |
| 331 | def getHumanReadableName(self, obj):
|
| 332 | return str(obj) |
| 333 | def getValidators(self, obj): |
| 334 | try: |
| 335 | return obj.getValidators() |
| 336 | except: |
| 337 | return None |
| 338 | class Meta: |
| 339 | model = Flavor |
| 340 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 341 | |
| 342 | class FlavorIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 343 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 344 | |
| 345 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 346 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 347 | |
| 348 | |
| 349 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 350 | validators = serializers.SerializerMethodField("getValidators") |
| 351 | def getHumanReadableName(self, obj):
|
| 352 | return str(obj)
|
| 353 | def getValidators(self, obj):
|
| 354 | try: |
| 355 | return obj.getValidators() |
| 356 | except: |
| 357 | return None
|
| 358 | class Meta:
|
| 359 | model = Flavor |
| 360 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 361 | |
| 362 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 363 | |
| 364 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 365 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 366 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 367 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 368 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 369 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 370 | def getHumanReadableName(self, obj):
|
| 371 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 372 | def getValidators(self, obj): |
| 373 | try: |
| 374 | return obj.getValidators() |
| 375 | except: |
| 376 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 377 | class Meta: |
| 378 | model = ServiceAttribute |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 379 | 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] | 380 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 381 | class ServiceAttributeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 382 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 383 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 384 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 385 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 386 | def getHumanReadableName(self, obj):
|
| 387 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 388 | def getValidators(self, obj):
|
| 389 | try: |
| 390 | return obj.getValidators() |
| 391 | except: |
| 392 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 393 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 394 | model = ServiceAttribute |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 395 | 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] | 396 | |
| 397 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 398 | |
| 399 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 400 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 401 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 402 | |
| 403 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 404 | validators = serializers.SerializerMethodField("getValidators") |
| 405 | def getHumanReadableName(self, obj):
|
| 406 | return str(obj) |
| 407 | def getValidators(self, obj): |
| 408 | try: |
| 409 | return obj.getValidators() |
| 410 | except: |
| 411 | return None |
| 412 | class Meta: |
| 413 | model = ControllerImages |
| 414 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 415 | |
| 416 | class ControllerImagesIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 417 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 418 | |
| 419 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 420 | validators = serializers.SerializerMethodField("getValidators") |
| 421 | def getHumanReadableName(self, obj):
|
| 422 | return str(obj)
|
| 423 | def getValidators(self, obj):
|
| 424 | try: |
| 425 | return obj.getValidators() |
| 426 | except: |
| 427 | return None
|
| 428 | class Meta:
|
| 429 | model = ControllerImages |
| 430 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 435 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 436 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 437 | |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 438 | |
| 439 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 440 | |
| 441 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 442 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 443 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 444 | def getHumanReadableName(self, obj):
|
| 445 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 446 | def getValidators(self, obj): |
| 447 | try: |
| 448 | return obj.getValidators() |
| 449 | except: |
| 450 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 451 | class Meta: |
| 452 | model = Image |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 453 | 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] | 454 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 455 | class ImageIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 456 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 457 | |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 458 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 459 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 460 | |
| 461 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 462 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 463 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 464 | def getHumanReadableName(self, obj):
|
| 465 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 466 | def getValidators(self, obj):
|
| 467 | try: |
| 468 | return obj.getValidators() |
| 469 | except: |
| 470 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 471 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 472 | model = Image |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 473 | 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] | 474 | |
| 475 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 476 | |
| 477 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 478 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 479 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 480 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 481 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 482 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 483 | def getHumanReadableName(self, obj):
|
| 484 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 485 | def getValidators(self, obj): |
| 486 | try: |
| 487 | return obj.getValidators() |
| 488 | except: |
| 489 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 490 | class Meta: |
| 491 | model = NetworkParameter |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 492 | 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] | 493 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 494 | class NetworkParameterIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 495 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 496 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 497 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 498 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 499 | def getHumanReadableName(self, obj):
|
| 500 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 501 | def getValidators(self, obj):
|
| 502 | try: |
| 503 | return obj.getValidators() |
| 504 | except: |
| 505 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 506 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 507 | model = NetworkParameter |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 508 | 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] | 509 | |
| 510 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 511 | |
| 512 | |
| 513 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 514 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 515 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 516 | |
| 517 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 518 | |
| 519 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 520 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 521 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 522 | def getHumanReadableName(self, obj):
|
| 523 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 524 | def getValidators(self, obj): |
| 525 | try: |
| 526 | return obj.getValidators() |
| 527 | except: |
| 528 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 529 | class Meta: |
| 530 | model = Site |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 531 | 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] | 532 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 533 | class SiteIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 534 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 535 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 536 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 537 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 538 | |
| 539 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 540 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 541 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 542 | def getHumanReadableName(self, obj):
|
| 543 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 544 | def getValidators(self, obj):
|
| 545 | try: |
| 546 | return obj.getValidators() |
| 547 | except: |
| 548 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 549 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 550 | model = Site |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 551 | 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] | 552 | |
| 553 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 554 | |
| 555 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 556 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 557 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 558 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 559 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 560 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 561 | def getHumanReadableName(self, obj):
|
| 562 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 563 | def getValidators(self, obj): |
| 564 | try: |
| 565 | return obj.getValidators() |
| 566 | except: |
| 567 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 568 | class Meta: |
| 569 | model = SliceRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 570 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 571 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 572 | class SliceRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 573 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 574 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 575 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 576 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 577 | def getHumanReadableName(self, obj):
|
| 578 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 579 | def getValidators(self, obj):
|
| 580 | try: |
| 581 | return obj.getValidators() |
| 582 | except: |
| 583 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 584 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 585 | model = SliceRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 586 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 587 | |
| 588 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 589 | |
| 590 | |
| 591 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 592 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 593 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 594 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 595 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 596 | def getHumanReadableName(self, obj):
|
| 597 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 598 | def getValidators(self, obj): |
| 599 | try: |
| 600 | return obj.getValidators() |
| 601 | except: |
| 602 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 603 | class Meta: |
| 604 | model = Tag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 605 | 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] | 606 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 607 | class TagIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 608 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 609 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 610 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 611 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 612 | def getHumanReadableName(self, obj):
|
| 613 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 614 | def getValidators(self, obj):
|
| 615 | try: |
| 616 | return obj.getValidators() |
| 617 | except: |
| 618 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 619 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 620 | model = Tag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 621 | 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] | 622 | |
| 623 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 624 | |
| 625 | |
| 626 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 627 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 628 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 629 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 630 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 631 | def getHumanReadableName(self, obj):
|
| 632 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 633 | def getValidators(self, obj): |
| 634 | try: |
| 635 | return obj.getValidators() |
| 636 | except: |
| 637 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 638 | class Meta: |
| 639 | model = Invoice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 640 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 641 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 642 | class InvoiceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 643 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 644 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 645 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 646 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 647 | def getHumanReadableName(self, obj):
|
| 648 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 649 | def getValidators(self, obj):
|
| 650 | try: |
| 651 | return obj.getValidators() |
| 652 | except: |
| 653 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 654 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 655 | model = Invoice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 656 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 657 | |
| 658 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 659 | |
| 660 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 661 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 662 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 663 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 664 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 665 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 666 | def getHumanReadableName(self, obj):
|
| 667 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 668 | def getValidators(self, obj): |
| 669 | try: |
| 670 | return obj.getValidators() |
| 671 | except: |
| 672 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 673 | class Meta: |
| 674 | model = SlicePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 675 | 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] | 676 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 677 | class SlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 678 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 679 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 680 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 681 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 682 | def getHumanReadableName(self, obj):
|
| 683 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 684 | def getValidators(self, obj):
|
| 685 | try: |
| 686 | return obj.getValidators() |
| 687 | except: |
| 688 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 689 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 690 | model = SlicePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 691 | 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] | 692 | |
| 693 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 694 | |
| 695 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 696 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 697 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 698 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 699 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 700 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 701 | def getHumanReadableName(self, obj):
|
| 702 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 703 | def getValidators(self, obj): |
| 704 | try: |
| 705 | return obj.getValidators() |
| 706 | except: |
| 707 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 708 | class Meta: |
| 709 | model = PlanetStackRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 710 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 711 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 712 | class PlanetStackRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 713 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 714 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 715 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 716 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 717 | def getHumanReadableName(self, obj):
|
| 718 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 719 | def getValidators(self, obj):
|
| 720 | try: |
| 721 | return obj.getValidators() |
| 722 | except: |
| 723 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 724 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 725 | model = PlanetStackRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 726 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 727 | |
| 728 | |
| 729 | |
| 730 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 731 | class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 732 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 733 | |
| 734 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 735 | validators = serializers.SerializerMethodField("getValidators") |
| 736 | def getHumanReadableName(self, obj):
|
| 737 | return str(obj) |
| 738 | def getValidators(self, obj): |
| 739 | try: |
| 740 | return obj.getValidators() |
| 741 | except: |
| 742 | return None |
| 743 | class Meta: |
| 744 | model = ControllerPrivilege |
| 745 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 746 | |
| 747 | class ControllerPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 748 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 749 | |
| 750 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 751 | validators = serializers.SerializerMethodField("getValidators") |
| 752 | def getHumanReadableName(self, obj):
|
| 753 | return str(obj)
|
| 754 | def getValidators(self, obj):
|
| 755 | try: |
| 756 | return obj.getValidators() |
| 757 | except: |
| 758 | return None
|
| 759 | class Meta:
|
| 760 | model = ControllerPrivilege |
| 761 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 766 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 767 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 768 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 769 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 770 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 771 | def getHumanReadableName(self, obj):
|
| 772 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 773 | def getValidators(self, obj): |
| 774 | try: |
| 775 | return obj.getValidators() |
| 776 | except: |
| 777 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 778 | class Meta: |
| 779 | model = NetworkSliver |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 780 | 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] | 781 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 782 | class NetworkSliverIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 783 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 784 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 785 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 786 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 787 | def getHumanReadableName(self, obj):
|
| 788 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 789 | def getValidators(self, obj):
|
| 790 | try: |
| 791 | return obj.getValidators() |
| 792 | except: |
| 793 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 794 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 795 | model = NetworkSliver |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 796 | 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] | 797 | |
| 798 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 799 | |
| 800 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 801 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 802 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 803 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 804 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 805 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 806 | def getHumanReadableName(self, obj):
|
| 807 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 808 | def getValidators(self, obj): |
| 809 | try: |
| 810 | return obj.getValidators() |
| 811 | except: |
| 812 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 813 | class Meta: |
| 814 | model = Project |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 815 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 816 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 817 | class ProjectIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 818 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 819 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 820 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 821 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 822 | def getHumanReadableName(self, obj):
|
| 823 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 824 | def getValidators(self, obj):
|
| 825 | try: |
| 826 | return obj.getValidators() |
| 827 | except: |
| 828 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 829 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 830 | model = Project |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 831 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 832 | |
| 833 | |
| 834 | |
| 835 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 836 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 837 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 838 | |
| 839 | |
| 840 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 841 | |
| 842 | |
| 843 | |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 844 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 845 | |
| 846 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 847 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 848 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 849 | def getHumanReadableName(self, obj):
|
| 850 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 851 | def getValidators(self, obj): |
| 852 | try: |
| 853 | return obj.getValidators() |
| 854 | except: |
| 855 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 856 | class Meta: |
| 857 | model = Slice |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 858 | 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] | 859 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 860 | class SliceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 861 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 862 | |
| 863 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 864 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 865 | |
| 866 | |
| 867 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 868 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 869 | |
| 870 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 871 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 872 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 873 | def getHumanReadableName(self, obj):
|
| 874 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 875 | def getValidators(self, obj):
|
| 876 | try: |
| 877 | return obj.getValidators() |
| 878 | except: |
| 879 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 880 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 881 | model = Slice |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 882 | 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] | 883 | |
| 884 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 885 | |
| 886 | |
| 887 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 888 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 889 | |
| 890 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 891 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 892 | |
| 893 | |
| 894 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 895 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 896 | |
| 897 | |
| 898 | |
| 899 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 900 | |
| 901 | |
| 902 | |
| 903 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 904 | |
| 905 | |
| 906 | |
| 907 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 908 | |
| 909 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 910 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 911 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 912 | def getHumanReadableName(self, obj):
|
| 913 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 914 | def getValidators(self, obj): |
| 915 | try: |
| 916 | return obj.getValidators() |
| 917 | except: |
| 918 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 919 | class Meta: |
| 920 | model = Network |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 921 | 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] | 922 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 923 | class NetworkIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 924 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 925 | |
| 926 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 927 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 928 | |
| 929 | |
| 930 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 931 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 932 | |
| 933 | |
| 934 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 935 | slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 936 | |
| 937 | |
| 938 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 939 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 940 | |
| 941 | |
| 942 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 943 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 944 | |
| 945 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 946 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 947 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 948 | def getHumanReadableName(self, obj):
|
| 949 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 950 | def getValidators(self, obj):
|
| 951 | try: |
| 952 | return obj.getValidators() |
| 953 | except: |
| 954 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 955 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 956 | model = Network |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 957 | 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] | 958 | |
| 959 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 960 | |
| 961 | |
| 962 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 963 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 964 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 965 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 966 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 967 | def getHumanReadableName(self, obj):
|
| 968 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 969 | def getValidators(self, obj): |
| 970 | try: |
| 971 | return obj.getValidators() |
| 972 | except: |
| 973 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 974 | class Meta: |
| 975 | model = Service |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 976 | 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] | 977 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 978 | class ServiceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 979 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 980 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 981 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 982 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 983 | def getHumanReadableName(self, obj):
|
| 984 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 985 | def getValidators(self, obj):
|
| 986 | try: |
| 987 | return obj.getValidators() |
| 988 | except: |
| 989 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 990 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 991 | model = Service |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 992 | 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] | 993 | |
| 994 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 995 | |
| 996 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 997 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 998 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 999 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1000 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1001 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1002 | def getHumanReadableName(self, obj):
|
| 1003 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1004 | def getValidators(self, obj): |
| 1005 | try: |
| 1006 | return obj.getValidators() |
| 1007 | except: |
| 1008 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1009 | class Meta: |
| 1010 | model = ServiceClass |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1011 | 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] | 1012 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1013 | class ServiceClassIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1014 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1015 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1016 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1017 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1018 | def getHumanReadableName(self, obj):
|
| 1019 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1020 | def getValidators(self, obj):
|
| 1021 | try: |
| 1022 | return obj.getValidators() |
| 1023 | except: |
| 1024 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1025 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1026 | model = ServiceClass |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1027 | 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] | 1028 | |
| 1029 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1030 | |
| 1031 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1032 | class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1033 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1034 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1035 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1036 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1037 | def getHumanReadableName(self, obj):
|
| 1038 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1039 | def getValidators(self, obj): |
| 1040 | try: |
| 1041 | return obj.getValidators() |
| 1042 | except: |
| 1043 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1044 | class Meta: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1045 | model = ControllerNetworks |
| 1046 | 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] | 1047 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1048 | class ControllerNetworksIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1049 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1050 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1051 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1052 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1053 | def getHumanReadableName(self, obj):
|
| 1054 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1055 | def getValidators(self, obj):
|
| 1056 | try: |
| 1057 | return obj.getValidators() |
| 1058 | except: |
| 1059 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1060 | class Meta:
|
| 1061 | model = ControllerNetworks |
| 1062 | 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] | 1063 | |
| 1064 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1065 | |
| 1066 | |
| 1067 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1068 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1069 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1070 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1071 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1072 | def getHumanReadableName(self, obj):
|
| 1073 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1074 | def getValidators(self, obj): |
| 1075 | try: |
| 1076 | return obj.getValidators() |
| 1077 | except: |
| 1078 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1079 | class Meta: |
| 1080 | model = Charge |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1081 | 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] | 1082 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1083 | class ChargeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1084 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1085 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1086 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1087 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1088 | def getHumanReadableName(self, obj):
|
| 1089 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1090 | def getValidators(self, obj):
|
| 1091 | try: |
| 1092 | return obj.getValidators() |
| 1093 | except: |
| 1094 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1095 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1096 | model = Charge |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1097 | 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] | 1098 | |
| 1099 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1100 | |
| 1101 | |
| 1102 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1103 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1104 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1105 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1106 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1107 | def getHumanReadableName(self, obj):
|
| 1108 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1109 | def getValidators(self, obj): |
| 1110 | try: |
| 1111 | return obj.getValidators() |
| 1112 | except: |
| 1113 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1114 | class Meta: |
| 1115 | model = Role |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1116 | 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] | 1117 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1118 | class RoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1119 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1120 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1121 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1122 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1123 | def getHumanReadableName(self, obj):
|
| 1124 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1125 | def getValidators(self, obj):
|
| 1126 | try: |
| 1127 | return obj.getValidators() |
| 1128 | except: |
| 1129 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1130 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1131 | model = Role |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1132 | 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] | 1133 | |
| 1134 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1135 | |
| 1136 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1137 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1138 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1139 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1140 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1141 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1142 | def getHumanReadableName(self, obj):
|
| 1143 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1144 | def getValidators(self, obj): |
| 1145 | try: |
| 1146 | return obj.getValidators() |
| 1147 | except: |
| 1148 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1149 | class Meta: |
| 1150 | model = UsableObject |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1151 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1152 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1153 | class UsableObjectIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1154 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1155 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1156 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1157 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1158 | def getHumanReadableName(self, obj):
|
| 1159 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1160 | def getValidators(self, obj):
|
| 1161 | try: |
| 1162 | return obj.getValidators() |
| 1163 | except: |
| 1164 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1165 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1166 | model = UsableObject |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1167 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1168 | |
| 1169 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1170 | |
| 1171 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1172 | class ControllerSiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1173 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1174 | |
| 1175 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1176 | validators = serializers.SerializerMethodField("getValidators") |
| 1177 | def getHumanReadableName(self, obj):
|
| 1178 | return str(obj) |
| 1179 | def getValidators(self, obj): |
| 1180 | try: |
| 1181 | return obj.getValidators() |
| 1182 | except: |
| 1183 | return None |
| 1184 | class Meta: |
| 1185 | model = ControllerSiteDeployments |
| 1186 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 1187 | |
| 1188 | class ControllerSiteDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1189 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1190 | |
| 1191 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1192 | validators = serializers.SerializerMethodField("getValidators") |
| 1193 | def getHumanReadableName(self, obj):
|
| 1194 | return str(obj)
|
| 1195 | def getValidators(self, obj):
|
| 1196 | try: |
| 1197 | return obj.getValidators() |
| 1198 | except: |
| 1199 | return None
|
| 1200 | class Meta:
|
| 1201 | model = ControllerSiteDeployments |
| 1202 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1207 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1208 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1209 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1210 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1211 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1212 | def getHumanReadableName(self, obj):
|
| 1213 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1214 | def getValidators(self, obj): |
| 1215 | try: |
| 1216 | return obj.getValidators() |
| 1217 | except: |
| 1218 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1219 | class Meta: |
| 1220 | model = SiteRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1221 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1222 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1223 | class SiteRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1224 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1225 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1226 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1227 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1228 | def getHumanReadableName(self, obj):
|
| 1229 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1230 | def getValidators(self, obj):
|
| 1231 | try: |
| 1232 | return obj.getValidators() |
| 1233 | except: |
| 1234 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1235 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1236 | model = SiteRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1237 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1238 | |
| 1239 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1240 | |
| 1241 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1242 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1243 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1244 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1245 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1246 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1247 | def getHumanReadableName(self, obj):
|
| 1248 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1249 | def getValidators(self, obj): |
| 1250 | try: |
| 1251 | return obj.getValidators() |
| 1252 | except: |
| 1253 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1254 | class Meta: |
| 1255 | model = SliceCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1256 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1257 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1258 | class SliceCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1259 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1260 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1261 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1262 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1263 | def getHumanReadableName(self, obj):
|
| 1264 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1265 | def getValidators(self, obj):
|
| 1266 | try: |
| 1267 | return obj.getValidators() |
| 1268 | except: |
| 1269 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1270 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1271 | model = SliceCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1272 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1273 | |
| 1274 | |
| 1275 | |
| 1276 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1277 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1278 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1279 | |
| 1280 | |
| 1281 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1282 | |
| 1283 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1284 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1285 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1286 | def getHumanReadableName(self, obj):
|
| 1287 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1288 | def getValidators(self, obj): |
| 1289 | try: |
| 1290 | return obj.getValidators() |
| 1291 | except: |
| 1292 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1293 | class Meta: |
| 1294 | model = Sliver |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 1295 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1296 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1297 | class SliverIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1298 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1299 | |
| 1300 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1301 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1302 | |
| 1303 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1304 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1305 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1306 | def getHumanReadableName(self, obj):
|
| 1307 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1308 | def getValidators(self, obj):
|
| 1309 | try: |
| 1310 | return obj.getValidators() |
| 1311 | except: |
| 1312 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1313 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1314 | model = Sliver |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 1315 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1316 | |
| 1317 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1318 | |
| 1319 | |
| 1320 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1321 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1322 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1323 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1324 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1325 | def getHumanReadableName(self, obj):
|
| 1326 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1327 | def getValidators(self, obj): |
| 1328 | try: |
| 1329 | return obj.getValidators() |
| 1330 | except: |
| 1331 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1332 | class Meta: |
| 1333 | model = Node |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1334 | 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] | 1335 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1336 | class NodeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1337 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1338 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1339 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1340 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1341 | def getHumanReadableName(self, obj):
|
| 1342 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1343 | def getValidators(self, obj):
|
| 1344 | try: |
| 1345 | return obj.getValidators() |
| 1346 | except: |
| 1347 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1348 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1349 | model = Node |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1350 | 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] | 1351 | |
| 1352 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1353 | |
| 1354 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1355 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1356 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1357 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1358 | |
| 1359 | controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail') |
| 1360 | |
| 1361 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1362 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1363 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1364 | def getHumanReadableName(self, obj):
|
| 1365 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1366 | def getValidators(self, obj): |
| 1367 | try: |
| 1368 | return obj.getValidators() |
| 1369 | except: |
| 1370 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1371 | class Meta: |
| 1372 | model = DashboardView |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1373 | 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] | 1374 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1375 | class DashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1376 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1377 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1378 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1379 | controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1380 | |
| 1381 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1382 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1383 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1384 | def getHumanReadableName(self, obj):
|
| 1385 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1386 | def getValidators(self, obj):
|
| 1387 | try: |
| 1388 | return obj.getValidators() |
| 1389 | except: |
| 1390 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1391 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1392 | model = DashboardView |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1393 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1394 | |
| 1395 | |
| 1396 | |
| 1397 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1398 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1399 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1400 | |
| 1401 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1402 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1403 | def getHumanReadableName(self, obj):
|
| 1404 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1405 | def getValidators(self, obj): |
| 1406 | try: |
| 1407 | return obj.getValidators() |
| 1408 | except: |
| 1409 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1410 | class Meta: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1411 | model = ImageDeployments |
| 1412 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1413 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1414 | class ImageDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1415 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1416 | |
| 1417 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1418 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1419 | def getHumanReadableName(self, obj):
|
| 1420 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1421 | def getValidators(self, obj):
|
| 1422 | try: |
| 1423 | return obj.getValidators() |
| 1424 | except: |
| 1425 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1426 | class Meta:
|
| 1427 | model = ImageDeployments |
| 1428 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1429 | |
| 1430 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1431 | |
| 1432 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1433 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1434 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1435 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1436 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1437 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1438 | def getHumanReadableName(self, obj):
|
| 1439 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1440 | def getValidators(self, obj): |
| 1441 | try: |
| 1442 | return obj.getValidators() |
| 1443 | except: |
| 1444 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1445 | class Meta: |
| 1446 | model = ReservedResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1447 | 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] | 1448 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1449 | class ReservedResourceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1450 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1451 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1452 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1453 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1454 | def getHumanReadableName(self, obj):
|
| 1455 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1456 | def getValidators(self, obj):
|
| 1457 | try: |
| 1458 | return obj.getValidators() |
| 1459 | except: |
| 1460 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1461 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1462 | model = ReservedResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1463 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1464 | |
| 1465 | |
| 1466 | |
| 1467 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1468 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1469 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1470 | |
| 1471 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1472 | validators = serializers.SerializerMethodField("getValidators") |
| 1473 | def getHumanReadableName(self, obj):
|
| 1474 | return str(obj) |
| 1475 | def getValidators(self, obj): |
| 1476 | try: |
| 1477 | return obj.getValidators() |
| 1478 | except: |
| 1479 | return None |
| 1480 | class Meta: |
| 1481 | model = Payment |
| 1482 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1483 | |
| 1484 | class PaymentIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1485 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1486 | |
| 1487 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1488 | validators = serializers.SerializerMethodField("getValidators") |
| 1489 | def getHumanReadableName(self, obj):
|
| 1490 | return str(obj)
|
| 1491 | def getValidators(self, obj):
|
| 1492 | try: |
| 1493 | return obj.getValidators() |
| 1494 | except: |
| 1495 | return None
|
| 1496 | class Meta:
|
| 1497 | model = Payment |
| 1498 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1499 | |
| 1500 | |
| 1501 | |
| 1502 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1503 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1504 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1505 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1506 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1507 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1508 | def getHumanReadableName(self, obj):
|
| 1509 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1510 | def getValidators(self, obj): |
| 1511 | try: |
| 1512 | return obj.getValidators() |
| 1513 | except: |
| 1514 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1515 | class Meta: |
| 1516 | model = NetworkSlice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1517 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1518 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1519 | class NetworkSliceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1520 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1521 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1522 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1523 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1524 | def getHumanReadableName(self, obj):
|
| 1525 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1526 | def getValidators(self, obj):
|
| 1527 | try: |
| 1528 | return obj.getValidators() |
| 1529 | except: |
| 1530 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1531 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1532 | model = NetworkSlice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1533 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1534 | |
| 1535 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1536 | |
| 1537 | |
| 1538 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1539 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1540 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1541 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1542 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1543 | def getHumanReadableName(self, obj):
|
| 1544 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1545 | def getValidators(self, obj): |
| 1546 | try: |
| 1547 | return obj.getValidators() |
| 1548 | except: |
| 1549 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1550 | class Meta: |
| 1551 | model = UserDashboardView |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1552 | 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] | 1553 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1554 | class UserDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1555 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1556 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1557 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1558 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1559 | def getHumanReadableName(self, obj):
|
| 1560 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1561 | def getValidators(self, obj):
|
| 1562 | try: |
| 1563 | return obj.getValidators() |
| 1564 | except: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1565 | return None
|
| 1566 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1567 | model = UserDashboardView |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1568 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1569 | |
| 1570 | |
| 1571 | |
| 1572 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1573 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1574 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1575 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1576 | |
| 1577 | dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail') |
| 1578 | |
| 1579 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1580 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1581 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1582 | def getHumanReadableName(self, obj):
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1583 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1584 | def getValidators(self, obj): |
| 1585 | try: |
| 1586 | return obj.getValidators() |
| 1587 | except: |
| 1588 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1589 | class Meta: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1590 | model = Controller |
| 1591 | 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] | 1592 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1593 | class ControllerIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1594 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1595 | |
| 1596 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1597 | dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1598 | |
| 1599 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1600 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1601 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1602 | def getHumanReadableName(self, obj):
|
| 1603 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1604 | def getValidators(self, obj):
|
| 1605 | try: |
| 1606 | return obj.getValidators() |
| 1607 | except: |
| 1608 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1609 | class Meta:
|
| 1610 | model = Controller |
| 1611 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 1612 | |
| 1613 | |
| 1614 | |
| 1615 | |
| 1616 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1617 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1618 | |
| 1619 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1620 | validators = serializers.SerializerMethodField("getValidators") |
| 1621 | def getHumanReadableName(self, obj):
|
| 1622 | return str(obj) |
| 1623 | def getValidators(self, obj): |
| 1624 | try: |
| 1625 | return obj.getValidators() |
| 1626 | except: |
| 1627 | return None |
| 1628 | class Meta: |
| 1629 | model = PlanetStackPrivilege |
| 1630 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1631 | |
| 1632 | class PlanetStackPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1633 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1634 | |
| 1635 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1636 | validators = serializers.SerializerMethodField("getValidators") |
| 1637 | def getHumanReadableName(self, obj):
|
| 1638 | return str(obj)
|
| 1639 | def getValidators(self, obj):
|
| 1640 | try: |
| 1641 | return obj.getValidators() |
| 1642 | except: |
| 1643 | return None
|
| 1644 | class Meta:
|
| 1645 | model = PlanetStackPrivilege |
| 1646 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1647 | |
| 1648 | |
| 1649 | |
| 1650 | |
| 1651 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1652 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1653 | |
| 1654 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1655 | validators = serializers.SerializerMethodField("getValidators") |
| 1656 | def getHumanReadableName(self, obj):
|
| 1657 | return str(obj) |
| 1658 | def getValidators(self, obj): |
| 1659 | try: |
| 1660 | return obj.getValidators() |
| 1661 | except: |
| 1662 | return None |
| 1663 | class Meta: |
| 1664 | model = User |
| 1665 | 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',) |
| 1666 | |
| 1667 | class UserIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1668 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1669 | |
| 1670 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1671 | validators = serializers.SerializerMethodField("getValidators") |
| 1672 | def getHumanReadableName(self, obj):
|
| 1673 | return str(obj)
|
| 1674 | def getValidators(self, obj):
|
| 1675 | try: |
| 1676 | return obj.getValidators() |
| 1677 | except: |
| 1678 | return None
|
| 1679 | class Meta:
|
| 1680 | model = User |
| 1681 | 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',) |
| 1682 | |
| 1683 | |
| 1684 | |
| 1685 | |
| 1686 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1687 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1688 | |
| 1689 | |
| 1690 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1691 | |
| 1692 | |
| 1693 | |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1694 | images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail') |
| 1695 | |
| 1696 | |
| 1697 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1698 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1699 | |
| 1700 | |
| 1701 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1702 | validators = serializers.SerializerMethodField("getValidators") |
| 1703 | def getHumanReadableName(self, obj):
|
| 1704 | return str(obj) |
| 1705 | def getValidators(self, obj): |
| 1706 | try: |
| 1707 | return obj.getValidators() |
| 1708 | except: |
| 1709 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1710 | class Meta: |
| 1711 | model = Deployment |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1712 | 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] | 1713 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1714 | class DeploymentIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1715 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1716 | |
| 1717 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1718 | flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1719 | |
| 1720 | |
| 1721 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1722 | images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all()) |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1723 | |
| 1724 | |
| 1725 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1726 | sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1727 | |
| 1728 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1729 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1730 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1731 | def getHumanReadableName(self, obj):
|
| 1732 | return str(obj)
|
| 1733 | def getValidators(self, obj):
|
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1734 | try: |
| 1735 | return obj.getValidators() |
| 1736 | except: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1737 | return None
|
| 1738 | class Meta:
|
| 1739 | model = Deployment |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1740 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',) |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1741 | |
| 1742 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1743 | |
| 1744 | |
| 1745 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1746 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1747 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1748 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1749 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1750 | def getHumanReadableName(self, obj):
|
| 1751 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1752 | def getValidators(self, obj): |
| 1753 | try: |
| 1754 | return obj.getValidators() |
| 1755 | except: |
| 1756 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1757 | class Meta: |
| 1758 | model = Reservation |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1759 | 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] | 1760 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1761 | class ReservationIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1762 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1763 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1764 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1765 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1766 | def getHumanReadableName(self, obj):
|
| 1767 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1768 | def getValidators(self, obj):
|
| 1769 | try: |
| 1770 | return obj.getValidators() |
| 1771 | except: |
| 1772 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1773 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1774 | model = Reservation |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1775 | 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] | 1776 | |
| 1777 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1778 | |
| 1779 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1780 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1781 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1782 | |
| 1783 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1784 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1785 | def getHumanReadableName(self, obj):
|
| 1786 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1787 | def getValidators(self, obj): |
| 1788 | try: |
| 1789 | return obj.getValidators() |
| 1790 | except: |
| 1791 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1792 | class Meta: |
| 1793 | model = SitePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1794 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1795 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1796 | class SitePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1797 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1798 | |
| 1799 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1800 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1801 | def getHumanReadableName(self, obj):
|
| 1802 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1803 | def getValidators(self, obj):
|
| 1804 | try: |
| 1805 | return obj.getValidators() |
| 1806 | except: |
| 1807 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1808 | class Meta:
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1809 | model = SitePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1810 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1811 | |
| 1812 | |
| 1813 | |
| 1814 | |
| 1815 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1816 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1817 | |
| 1818 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1819 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1820 | def getHumanReadableName(self, obj):
|
| 1821 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1822 | def getValidators(self, obj): |
| 1823 | try: |
| 1824 | return obj.getValidators() |
| 1825 | except: |
| 1826 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1827 | class Meta: |
| 1828 | model = PlanetStack |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1829 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1830 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1831 | class PlanetStackIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1832 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1833 | |
| 1834 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1835 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1836 | def getHumanReadableName(self, obj):
|
| 1837 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1838 | def getValidators(self, obj):
|
| 1839 | try: |
| 1840 | return obj.getValidators() |
| 1841 | except: |
| 1842 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1843 | class Meta:
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1844 | model = PlanetStack |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1845 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1846 | |
| 1847 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1848 | |
| 1849 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1850 | class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1851 | id = IdField() |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1852 | |
| 1853 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1854 | validators = serializers.SerializerMethodField("getValidators") |
| 1855 | def getHumanReadableName(self, obj):
|
| 1856 | return str(obj) |
| 1857 | def getValidators(self, obj): |
| 1858 | try: |
| 1859 | return obj.getValidators() |
| 1860 | except: |
| 1861 | return None |
| 1862 | class Meta: |
| 1863 | model = ControllerDashboardView |
| 1864 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1865 | |
| 1866 | class ControllerDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1867 | id = IdField() |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1868 | |
| 1869 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1870 | validators = serializers.SerializerMethodField("getValidators") |
| 1871 | def getHumanReadableName(self, obj):
|
| 1872 | return str(obj)
|
| 1873 | def getValidators(self, obj):
|
| 1874 | try: |
| 1875 | return obj.getValidators() |
| 1876 | except: |
| 1877 | return None
|
| 1878 | class Meta:
|
| 1879 | model = ControllerDashboardView |
| 1880 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1881 | |
| 1882 | |
| 1883 | |
| 1884 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1885 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1886 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1887 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1888 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1889 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1890 | def getHumanReadableName(self, obj):
|
| 1891 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1892 | def getValidators(self, obj): |
| 1893 | try: |
| 1894 | return obj.getValidators() |
| 1895 | except: |
| 1896 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1897 | class Meta: |
| 1898 | model = Account |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1899 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1900 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1901 | class AccountIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1902 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1903 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1904 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1905 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1906 | def getHumanReadableName(self, obj):
|
| 1907 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1908 | def getValidators(self, obj):
|
| 1909 | try: |
| 1910 | return obj.getValidators() |
| 1911 | except: |
| 1912 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1913 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1914 | model = Account |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1915 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1916 | |
| 1917 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1918 | |
| 1919 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1920 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1921 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1922 | |
| 1923 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1924 | validators = serializers.SerializerMethodField("getValidators") |
| 1925 | def getHumanReadableName(self, obj):
|
| 1926 | return str(obj) |
| 1927 | def getValidators(self, obj): |
| 1928 | try: |
| 1929 | return obj.getValidators() |
| 1930 | except: |
| 1931 | return None |
| 1932 | class Meta: |
| 1933 | model = ControllerRole |
| 1934 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1935 | |
| 1936 | class ControllerRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1937 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1938 | |
| 1939 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1940 | validators = serializers.SerializerMethodField("getValidators") |
| 1941 | def getHumanReadableName(self, obj):
|
| 1942 | return str(obj)
|
| 1943 | def getValidators(self, obj):
|
| 1944 | try: |
| 1945 | return obj.getValidators() |
| 1946 | except: |
| 1947 | return None
|
| 1948 | class Meta:
|
| 1949 | model = ControllerRole |
| 1950 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1951 | |
| 1952 | |
| 1953 | |
| 1954 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1955 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1956 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1957 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1958 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1959 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1960 | def getHumanReadableName(self, obj):
|
| 1961 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1962 | def getValidators(self, obj): |
| 1963 | try: |
| 1964 | return obj.getValidators() |
| 1965 | except: |
| 1966 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1967 | class Meta: |
| 1968 | model = NetworkParameterType |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1969 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1970 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1971 | class NetworkParameterTypeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1972 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1973 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1974 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1975 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1976 | def getHumanReadableName(self, obj):
|
| 1977 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1978 | def getValidators(self, obj):
|
| 1979 | try: |
| 1980 | return obj.getValidators() |
| 1981 | except: |
| 1982 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1983 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1984 | model = NetworkParameterType |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1985 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1986 | |
| 1987 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1988 | |
| 1989 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1990 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1991 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1992 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1993 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1994 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1995 | def getHumanReadableName(self, obj):
|
| 1996 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1997 | def getValidators(self, obj): |
| 1998 | try: |
| 1999 | return obj.getValidators() |
| 2000 | except: |
| 2001 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2002 | class Meta: |
| 2003 | model = SiteCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2004 | 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] | 2005 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2006 | class SiteCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2007 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2008 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2009 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2010 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2011 | def getHumanReadableName(self, obj):
|
| 2012 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2013 | def getValidators(self, obj):
|
| 2014 | try: |
| 2015 | return obj.getValidators() |
| 2016 | except: |
| 2017 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2018 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2019 | model = SiteCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2020 | 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] | 2021 | |
| 2022 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2023 | |
| 2024 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2025 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2026 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2027 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2028 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2029 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2030 | def getHumanReadableName(self, obj):
|
| 2031 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2032 | def getValidators(self, obj): |
| 2033 | try: |
| 2034 | return obj.getValidators() |
| 2035 | except: |
| 2036 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2037 | class Meta: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2038 | model = DeploymentPrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2039 | 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] | 2040 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2041 | class DeploymentPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2042 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2043 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2044 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2045 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2046 | def getHumanReadableName(self, obj):
|
| 2047 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2048 | def getValidators(self, obj):
|
| 2049 | try: |
| 2050 | return obj.getValidators() |
| 2051 | except: |
| 2052 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2053 | class Meta:
|
| 2054 | model = DeploymentPrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2055 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2056 | |
| 2057 | |
| 2058 | |
| 2059 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2060 | class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2061 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2062 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2063 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2064 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2065 | def getHumanReadableName(self, obj):
|
| 2066 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2067 | def getValidators(self, obj): |
| 2068 | try: |
| 2069 | return obj.getValidators() |
| 2070 | except: |
| 2071 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2072 | class Meta: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2073 | model = ControllerUsers |
| 2074 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2075 | |
| 2076 | class ControllerUsersIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2077 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2078 | |
| 2079 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2080 | validators = serializers.SerializerMethodField("getValidators") |
| 2081 | def getHumanReadableName(self, obj):
|
| 2082 | return str(obj)
|
| 2083 | def getValidators(self, obj):
|
| 2084 | try: |
| 2085 | return obj.getValidators() |
| 2086 | except: |
| 2087 | return None
|
| 2088 | class Meta:
|
| 2089 | model = ControllerUsers |
| 2090 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2091 | |
| 2092 | |
| 2093 | |
| 2094 | |
| 2095 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2096 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2097 | |
| 2098 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2099 | validators = serializers.SerializerMethodField("getValidators") |
| 2100 | def getHumanReadableName(self, obj):
|
| 2101 | return str(obj) |
| 2102 | def getValidators(self, obj): |
| 2103 | try: |
| 2104 | return obj.getValidators() |
| 2105 | except: |
| 2106 | return None |
| 2107 | class Meta: |
| 2108 | model = DeploymentRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2109 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2110 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2111 | class DeploymentRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2112 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2113 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2114 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2115 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2116 | def getHumanReadableName(self, obj):
|
| 2117 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2118 | def getValidators(self, obj):
|
| 2119 | try: |
| 2120 | return obj.getValidators() |
| 2121 | except: |
| 2122 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2123 | class Meta:
|
| 2124 | model = DeploymentRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2125 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2126 | |
| 2127 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2128 | |
| 2129 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2130 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2131 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2132 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2133 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2134 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2135 | def getHumanReadableName(self, obj):
|
| 2136 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2137 | def getValidators(self, obj): |
| 2138 | try: |
| 2139 | return obj.getValidators() |
| 2140 | except: |
| 2141 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2142 | class Meta: |
| 2143 | model = UserCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2144 | 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] | 2145 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2146 | class UserCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2147 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2148 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2149 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2150 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2151 | def getHumanReadableName(self, obj):
|
| 2152 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2153 | def getValidators(self, obj):
|
| 2154 | try: |
| 2155 | return obj.getValidators() |
| 2156 | except: |
| 2157 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2158 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2159 | model = UserCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2160 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2161 | |
| 2162 | |
| 2163 | |
| 2164 | |
| 2165 | class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2166 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2167 | |
| 2168 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2169 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2170 | def getHumanReadableName(self, obj):
|
| 2171 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2172 | def getValidators(self, obj): |
| 2173 | try: |
| 2174 | return obj.getValidators() |
| 2175 | except: |
| 2176 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2177 | class Meta: |
| 2178 | model = SiteDeployments |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2179 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2180 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2181 | class SiteDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2182 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2183 | |
| 2184 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2185 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2186 | def getHumanReadableName(self, obj):
|
| 2187 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2188 | def getValidators(self, obj):
|
| 2189 | try: |
| 2190 | return obj.getValidators() |
| 2191 | except: |
| 2192 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2193 | class Meta:
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2194 | model = SiteDeployments |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2195 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
| 2196 | |
| 2197 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2198 | |
| 2199 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2200 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2201 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2202 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2203 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2204 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2205 | def getHumanReadableName(self, obj):
|
| 2206 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2207 | def getValidators(self, obj): |
| 2208 | try: |
| 2209 | return obj.getValidators() |
| 2210 | except: |
| 2211 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2212 | class Meta: |
| 2213 | model = SliceTag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2214 | 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] | 2215 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2216 | class SliceTagIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2217 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2218 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2219 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2220 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2221 | def getHumanReadableName(self, obj):
|
| 2222 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2223 | def getValidators(self, obj):
|
| 2224 | try: |
| 2225 | return obj.getValidators() |
| 2226 | except: |
| 2227 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2228 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2229 | model = SliceTag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2230 | 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] | 2231 | |
| 2232 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2233 | |
| 2234 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2235 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2236 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2237 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2238 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2239 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2240 | def getHumanReadableName(self, obj):
|
| 2241 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2242 | def getValidators(self, obj): |
| 2243 | try: |
| 2244 | return obj.getValidators() |
| 2245 | except: |
| 2246 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2247 | class Meta: |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2248 | model = NetworkTemplate |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 2249 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2250 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2251 | class NetworkTemplateIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2252 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2253 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2254 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2255 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2256 | def getHumanReadableName(self, obj):
|
| 2257 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2258 | def getValidators(self, obj):
|
| 2259 | try: |
| 2260 | return obj.getValidators() |
| 2261 | except: |
| 2262 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2263 | class Meta:
|
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2264 | model = NetworkTemplate |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 2265 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2266 | |
| 2267 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2268 | |
| 2269 | |
| 2270 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2271 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2272 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2273 | |
| 2274 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2275 | |
| 2276 | |
| 2277 | |
| 2278 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2279 | |
| 2280 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2281 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2282 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2283 | def getHumanReadableName(self, obj):
|
| 2284 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2285 | def getValidators(self, obj): |
| 2286 | try: |
| 2287 | return obj.getValidators() |
| 2288 | except: |
| 2289 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2290 | class Meta: |
| 2291 | model = Router |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2292 | 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] | 2293 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2294 | class RouterIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2295 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2296 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2297 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2298 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2299 | |
| 2300 | |
| 2301 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2302 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2303 | |
| 2304 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2305 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2306 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2307 | def getHumanReadableName(self, obj):
|
| 2308 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2309 | def getValidators(self, obj):
|
| 2310 | try: |
| 2311 | return obj.getValidators() |
| 2312 | except: |
| 2313 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2314 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2315 | model = Router |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2316 | 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] | 2317 | |
| 2318 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2319 | |
| 2320 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2321 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2322 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2323 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2324 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2325 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2326 | def getHumanReadableName(self, obj):
|
| 2327 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2328 | def getValidators(self, obj): |
| 2329 | try: |
| 2330 | return obj.getValidators() |
| 2331 | except: |
| 2332 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2333 | class Meta: |
| 2334 | model = ServiceResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2335 | 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] | 2336 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2337 | class ServiceResourceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2338 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2339 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2340 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2341 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2342 | def getHumanReadableName(self, obj):
|
| 2343 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2344 | def getValidators(self, obj):
|
| 2345 | try: |
| 2346 | return obj.getValidators() |
| 2347 | except: |
| 2348 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2349 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2350 | model = ServiceResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2351 | 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] | 2352 | |
| 2353 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2354 | |
| 2355 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2356 | class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2357 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2358 | |
| 2359 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2360 | validators = serializers.SerializerMethodField("getValidators") |
| 2361 | def getHumanReadableName(self, obj):
|
| 2362 | return str(obj) |
| 2363 | def getValidators(self, obj): |
| 2364 | try: |
| 2365 | return obj.getValidators() |
| 2366 | except: |
| 2367 | return None |
| 2368 | class Meta: |
| 2369 | model = ControllerSlices |
| 2370 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2371 | |
| 2372 | class ControllerSlicesIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2373 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2374 | |
| 2375 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2376 | validators = serializers.SerializerMethodField("getValidators") |
| 2377 | def getHumanReadableName(self, obj):
|
| 2378 | return str(obj)
|
| 2379 | def getValidators(self, obj):
|
| 2380 | try: |
| 2381 | return obj.getValidators() |
| 2382 | except: |
| 2383 | return None
|
| 2384 | class Meta:
|
| 2385 | model = ControllerSlices |
| 2386 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2387 | |
| 2388 | |
| 2389 | |
| 2390 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2391 | serializerLookUp = { |
| 2392 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2393 | Flavor: FlavorSerializer, |
| 2394 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2395 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2396 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2397 | ControllerImages: ControllerImagesSerializer, |
| 2398 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2399 | Image: ImageSerializer, |
| 2400 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2401 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2402 | |
| 2403 | Site: SiteSerializer, |
| 2404 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2405 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2406 | |
| 2407 | Tag: TagSerializer, |
| 2408 | |
| 2409 | Invoice: InvoiceSerializer, |
| 2410 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2411 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2412 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2413 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2414 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2415 | ControllerPrivilege: ControllerPrivilegeSerializer, |
| 2416 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2417 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2418 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2419 | Project: ProjectSerializer, |
| 2420 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2421 | Slice: SliceSerializer, |
| 2422 | |
| 2423 | Network: NetworkSerializer, |
| 2424 | |
| 2425 | Service: ServiceSerializer, |
| 2426 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2427 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2428 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2429 | ControllerNetworks: ControllerNetworksSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2430 | |
| 2431 | Charge: ChargeSerializer, |
| 2432 | |
| 2433 | Role: RoleSerializer, |
| 2434 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2435 | UsableObject: UsableObjectSerializer, |
| 2436 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2437 | ControllerSiteDeployments: ControllerSiteDeploymentsSerializer, |
| 2438 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2439 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2440 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2441 | SliceCredential: SliceCredentialSerializer, |
| 2442 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2443 | Sliver: SliverSerializer, |
| 2444 | |
| 2445 | Node: NodeSerializer, |
| 2446 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2447 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2448 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2449 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2450 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2451 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2452 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2453 | Payment: PaymentSerializer, |
| 2454 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2455 | NetworkSlice: NetworkSliceSerializer, |
| 2456 | |
| 2457 | UserDashboardView: UserDashboardViewSerializer, |
| 2458 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2459 | Controller: ControllerSerializer, |
| 2460 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2461 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2462 | |
| 2463 | User: UserSerializer, |
| 2464 | |
| 2465 | Deployment: DeploymentSerializer, |
| 2466 | |
| 2467 | Reservation: ReservationSerializer, |
| 2468 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2469 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2470 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2471 | PlanetStack: PlanetStackSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2472 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2473 | ControllerDashboardView: ControllerDashboardViewSerializer, |
| 2474 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2475 | Account: AccountSerializer, |
| 2476 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2477 | ControllerRole: ControllerRoleSerializer, |
| 2478 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2479 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2480 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2481 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2482 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2483 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2484 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2485 | ControllerUsers: ControllerUsersSerializer, |
| 2486 | |
| 2487 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2488 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2489 | UserCredential: UserCredentialSerializer, |
| 2490 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2491 | SiteDeployments: SiteDeploymentsSerializer, |
| 2492 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2493 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2494 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2495 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2496 | |
| 2497 | Router: RouterSerializer, |
| 2498 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2499 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2500 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2501 | ControllerSlices: ControllerSlicesSerializer, |
| 2502 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2503 | None: None, |
| 2504 | } |
| 2505 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2506 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2507 | |
| 2508 | # To handle fine-grained field permissions, we have to check can_update |
| 2509 | # the object has been updated but before it has been saved. |
| 2510 | |
| 2511 | def update(self, request, *args, **kwargs):
|
| 2512 | partial = kwargs.pop('partial', False)
|
| 2513 | self.object = self.get_object_or_none()
|
| 2514 |
|
| 2515 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2516 | files=request.FILES, partial=partial)
|
| 2517 |
|
| 2518 | if not serializer.is_valid():
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2519 | response = {"error": "validation",
|
| 2520 | "specific_error": "not serializer.is_valid()",
|
| 2521 | "reasons": serializer.errors}
|
| 2522 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2523 |
|
| 2524 | try:
|
| 2525 | self.pre_save(serializer.object)
|
| 2526 | except ValidationError as err:
|
| 2527 | # full_clean on model instance may be called in pre_save,
|
| 2528 | # so we have to handle eventual errors.
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2529 | response = {"error": "validation",
|
| 2530 | "specific_error": "ValidationError in pre_save",
|
| 2531 | "reasons": err.message_dict}
|
| 2532 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2533 |
|
| 2534 | if serializer.object is not None:
|
| 2535 | if not serializer.object.can_update(request.user):
|
| 2536 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2537 |
|
| 2538 | if self.object is None:
|
| 2539 | self.object = serializer.save(force_insert=True)
|
| 2540 | self.post_save(self.object, created=True)
|
| 2541 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2542 |
|
| 2543 | self.object = serializer.save(force_update=True)
|
| 2544 | self.post_save(self.object, created=False)
|
| 2545 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2546 | |
| 2547 | def destroy(self, request, *args, **kwargs): |
| 2548 | obj = self.get_object() |
| 2549 | if obj.can_update(request.user): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2550 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2551 | else: |
| 2552 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2553 | |
| 2554 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2555 | # Based on core/views/*.py |
| 2556 | |
| 2557 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2558 | class FlavorList(generics.ListCreateAPIView): |
| 2559 | queryset = Flavor.objects.select_related().all() |
| 2560 | serializer_class = FlavorSerializer |
| 2561 | id_serializer_class = FlavorIdSerializer |
| 2562 | filter_backends = (filters.DjangoFilterBackend,) |
| 2563 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 2564 | |
| 2565 | def get_serializer_class(self): |
| 2566 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2567 | if (no_hyperlinks): |
| 2568 | return self.id_serializer_class |
| 2569 | else: |
| 2570 | return self.serializer_class |
| 2571 | |
| 2572 | def get_queryset(self): |
| 2573 | return Flavor.select_by_user(self.request.user) |
| 2574 | |
| 2575 | def create(self, request, *args, **kwargs): |
| 2576 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2577 | if not (serializer.is_valid()): |
| 2578 | response = {"error": "validation", |
| 2579 | "specific_error": "not serializer.is_valid()",
|
| 2580 | "reasons": serializer.errors}
|
| 2581 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2582 | obj = serializer.object |
| 2583 | obj.caller = request.user |
| 2584 | if obj.can_update(request.user): |
| 2585 | return super(FlavorList, self).create(request, *args, **kwargs) |
| 2586 | else: |
| 2587 | raise Exception("failed obj.can_update") |
| 2588 | |
| 2589 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 2590 | if (ret.status_code%100 != 200): |
| 2591 | raise Exception(ret.data) |
| 2592 | |
| 2593 | return ret |
| 2594 | |
| 2595 | |
| 2596 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2597 | queryset = Flavor.objects.select_related().all() |
| 2598 | serializer_class = FlavorSerializer |
| 2599 | id_serializer_class = FlavorIdSerializer |
| 2600 | |
| 2601 | def get_serializer_class(self): |
| 2602 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2603 | if (no_hyperlinks): |
| 2604 | return self.id_serializer_class |
| 2605 | else: |
| 2606 | return self.serializer_class |
| 2607 | |
| 2608 | def get_queryset(self): |
| 2609 | return Flavor.select_by_user(self.request.user) |
| 2610 | |
| 2611 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2612 | |
| 2613 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2614 | |
| 2615 | |
| 2616 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2617 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 2618 | queryset = ServiceAttribute.objects.select_related().all() |
| 2619 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2620 | id_serializer_class = ServiceAttributeIdSerializer |
| 2621 | filter_backends = (filters.DjangoFilterBackend,) |
| 2622 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 2623 | |
| 2624 | def get_serializer_class(self): |
| 2625 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2626 | if (no_hyperlinks): |
| 2627 | return self.id_serializer_class |
| 2628 | else: |
| 2629 | return self.serializer_class |
| 2630 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2631 | def get_queryset(self): |
| 2632 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2633 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2634 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2635 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2636 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2637 | response = {"error": "validation", |
| 2638 | "specific_error": "not serializer.is_valid()",
|
| 2639 | "reasons": serializer.errors}
|
| 2640 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2641 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2642 | obj.caller = request.user |
| 2643 | if obj.can_update(request.user): |
| 2644 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2645 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2646 | raise Exception("failed obj.can_update") |
| 2647 | |
| 2648 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2649 | if (ret.status_code%100 != 200): |
| 2650 | raise Exception(ret.data) |
| 2651 | |
| 2652 | return ret |
| 2653 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2654 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2655 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2656 | queryset = ServiceAttribute.objects.select_related().all() |
| 2657 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2658 | id_serializer_class = ServiceAttributeIdSerializer |
| 2659 | |
| 2660 | def get_serializer_class(self): |
| 2661 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2662 | if (no_hyperlinks): |
| 2663 | return self.id_serializer_class |
| 2664 | else: |
| 2665 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2666 | |
| 2667 | def get_queryset(self): |
| 2668 | return ServiceAttribute.select_by_user(self.request.user) |
| 2669 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2670 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2671 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2672 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2673 | |
| 2674 | |
| 2675 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2676 | class ControllerImagesList(generics.ListCreateAPIView): |
| 2677 | queryset = ControllerImages.objects.select_related().all() |
| 2678 | serializer_class = ControllerImagesSerializer |
| 2679 | id_serializer_class = ControllerImagesIdSerializer |
| 2680 | filter_backends = (filters.DjangoFilterBackend,) |
| 2681 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 2682 | |
| 2683 | def get_serializer_class(self): |
| 2684 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2685 | if (no_hyperlinks): |
| 2686 | return self.id_serializer_class |
| 2687 | else: |
| 2688 | return self.serializer_class |
| 2689 | |
| 2690 | def get_queryset(self): |
| 2691 | return ControllerImages.select_by_user(self.request.user) |
| 2692 | |
| 2693 | def create(self, request, *args, **kwargs): |
| 2694 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2695 | if not (serializer.is_valid()): |
| 2696 | response = {"error": "validation", |
| 2697 | "specific_error": "not serializer.is_valid()",
|
| 2698 | "reasons": serializer.errors}
|
| 2699 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2700 | obj = serializer.object |
| 2701 | obj.caller = request.user |
| 2702 | if obj.can_update(request.user): |
| 2703 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2704 | else: |
| 2705 | raise Exception("failed obj.can_update") |
| 2706 | |
| 2707 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2708 | if (ret.status_code%100 != 200): |
| 2709 | raise Exception(ret.data) |
| 2710 | |
| 2711 | return ret |
| 2712 | |
| 2713 | |
| 2714 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2715 | queryset = ControllerImages.objects.select_related().all() |
| 2716 | serializer_class = ControllerImagesSerializer |
| 2717 | id_serializer_class = ControllerImagesIdSerializer |
| 2718 | |
| 2719 | def get_serializer_class(self): |
| 2720 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2721 | if (no_hyperlinks): |
| 2722 | return self.id_serializer_class |
| 2723 | else: |
| 2724 | return self.serializer_class |
| 2725 | |
| 2726 | def get_queryset(self): |
| 2727 | return ControllerImages.select_by_user(self.request.user) |
| 2728 | |
| 2729 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2730 | |
| 2731 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2732 | |
| 2733 | |
| 2734 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2735 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2736 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2737 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2738 | id_serializer_class = ImageIdSerializer |
| 2739 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 2740 | 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] | 2741 | |
| 2742 | def get_serializer_class(self): |
| 2743 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2744 | if (no_hyperlinks): |
| 2745 | return self.id_serializer_class |
| 2746 | else: |
| 2747 | return self.serializer_class |
| 2748 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2749 | def get_queryset(self): |
| 2750 | return Image.select_by_user(self.request.user) |
| 2751 | |
| 2752 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2753 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2754 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2755 | response = {"error": "validation", |
| 2756 | "specific_error": "not serializer.is_valid()",
|
| 2757 | "reasons": serializer.errors}
|
| 2758 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2759 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2760 | obj.caller = request.user |
| 2761 | if obj.can_update(request.user): |
| 2762 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2763 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2764 | raise Exception("failed obj.can_update") |
| 2765 | |
| 2766 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2767 | if (ret.status_code%100 != 200): |
| 2768 | raise Exception(ret.data) |
| 2769 | |
| 2770 | return ret |
| 2771 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2772 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2773 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2774 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2775 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2776 | id_serializer_class = ImageIdSerializer |
| 2777 | |
| 2778 | def get_serializer_class(self): |
| 2779 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2780 | if (no_hyperlinks): |
| 2781 | return self.id_serializer_class |
| 2782 | else: |
| 2783 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2784 | |
| 2785 | def get_queryset(self): |
| 2786 | return Image.select_by_user(self.request.user) |
| 2787 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2788 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2789 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2790 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2791 | |
| 2792 | |
| 2793 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2794 | class NetworkParameterList(generics.ListCreateAPIView): |
| 2795 | queryset = NetworkParameter.objects.select_related().all() |
| 2796 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2797 | id_serializer_class = NetworkParameterIdSerializer |
| 2798 | filter_backends = (filters.DjangoFilterBackend,) |
| 2799 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 2800 | |
| 2801 | def get_serializer_class(self): |
| 2802 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2803 | if (no_hyperlinks): |
| 2804 | return self.id_serializer_class |
| 2805 | else: |
| 2806 | return self.serializer_class |
| 2807 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2808 | def get_queryset(self): |
| 2809 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2810 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2811 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2812 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2813 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2814 | response = {"error": "validation", |
| 2815 | "specific_error": "not serializer.is_valid()",
|
| 2816 | "reasons": serializer.errors}
|
| 2817 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2818 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2819 | obj.caller = request.user |
| 2820 | if obj.can_update(request.user): |
| 2821 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2822 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2823 | raise Exception("failed obj.can_update") |
| 2824 | |
| 2825 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2826 | if (ret.status_code%100 != 200): |
| 2827 | raise Exception(ret.data) |
| 2828 | |
| 2829 | return ret |
| 2830 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2831 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2832 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2833 | queryset = NetworkParameter.objects.select_related().all() |
| 2834 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2835 | id_serializer_class = NetworkParameterIdSerializer |
| 2836 | |
| 2837 | def get_serializer_class(self): |
| 2838 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2839 | if (no_hyperlinks): |
| 2840 | return self.id_serializer_class |
| 2841 | else: |
| 2842 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2843 | |
| 2844 | def get_queryset(self): |
| 2845 | return NetworkParameter.select_by_user(self.request.user) |
| 2846 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2847 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2848 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2849 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2850 | |
| 2851 | |
| 2852 | |
| 2853 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2854 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2855 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2856 | id_serializer_class = SiteIdSerializer |
| 2857 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2858 | 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] | 2859 | |
| 2860 | def get_serializer_class(self): |
| 2861 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2862 | if (no_hyperlinks): |
| 2863 | return self.id_serializer_class |
| 2864 | else: |
| 2865 | return self.serializer_class |
| 2866 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2867 | def get_queryset(self): |
| 2868 | return Site.select_by_user(self.request.user) |
| 2869 | |
| 2870 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2871 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2872 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2873 | response = {"error": "validation", |
| 2874 | "specific_error": "not serializer.is_valid()",
|
| 2875 | "reasons": serializer.errors}
|
| 2876 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2877 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2878 | obj.caller = request.user |
| 2879 | if obj.can_update(request.user): |
| 2880 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2881 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2882 | raise Exception("failed obj.can_update") |
| 2883 | |
| 2884 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2885 | if (ret.status_code%100 != 200): |
| 2886 | raise Exception(ret.data) |
| 2887 | |
| 2888 | return ret |
| 2889 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2890 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2891 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2892 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2893 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2894 | id_serializer_class = SiteIdSerializer |
| 2895 | |
| 2896 | def get_serializer_class(self): |
| 2897 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2898 | if (no_hyperlinks): |
| 2899 | return self.id_serializer_class |
| 2900 | else: |
| 2901 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2902 | |
| 2903 | def get_queryset(self): |
| 2904 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2905 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2906 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2907 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2908 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2909 | |
| 2910 | |
| 2911 | |
| 2912 | class SliceRoleList(generics.ListCreateAPIView): |
| 2913 | queryset = SliceRole.objects.select_related().all() |
| 2914 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2915 | id_serializer_class = SliceRoleIdSerializer |
| 2916 | filter_backends = (filters.DjangoFilterBackend,) |
| 2917 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2918 | |
| 2919 | def get_serializer_class(self): |
| 2920 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2921 | if (no_hyperlinks): |
| 2922 | return self.id_serializer_class |
| 2923 | else: |
| 2924 | return self.serializer_class |
| 2925 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2926 | def get_queryset(self): |
| 2927 | return SliceRole.select_by_user(self.request.user) |
| 2928 | |
| 2929 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2930 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2931 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2932 | response = {"error": "validation", |
| 2933 | "specific_error": "not serializer.is_valid()",
|
| 2934 | "reasons": serializer.errors}
|
| 2935 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2936 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2937 | obj.caller = request.user |
| 2938 | if obj.can_update(request.user): |
| 2939 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2940 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2941 | raise Exception("failed obj.can_update") |
| 2942 | |
| 2943 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2944 | if (ret.status_code%100 != 200): |
| 2945 | raise Exception(ret.data) |
| 2946 | |
| 2947 | return ret |
| 2948 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2949 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2950 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2951 | queryset = SliceRole.objects.select_related().all() |
| 2952 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2953 | id_serializer_class = SliceRoleIdSerializer |
| 2954 | |
| 2955 | def get_serializer_class(self): |
| 2956 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2957 | if (no_hyperlinks): |
| 2958 | return self.id_serializer_class |
| 2959 | else: |
| 2960 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2961 | |
| 2962 | def get_queryset(self): |
| 2963 | return SliceRole.select_by_user(self.request.user) |
| 2964 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2965 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2966 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2967 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2968 | |
| 2969 | |
| 2970 | |
| 2971 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2972 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2973 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2974 | id_serializer_class = TagIdSerializer |
| 2975 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2976 | 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] | 2977 | |
| 2978 | def get_serializer_class(self): |
| 2979 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2980 | if (no_hyperlinks): |
| 2981 | return self.id_serializer_class |
| 2982 | else: |
| 2983 | return self.serializer_class |
| 2984 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2985 | def get_queryset(self): |
| 2986 | return Tag.select_by_user(self.request.user) |
| 2987 | |
| 2988 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2989 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2990 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2991 | response = {"error": "validation", |
| 2992 | "specific_error": "not serializer.is_valid()",
|
| 2993 | "reasons": serializer.errors}
|
| 2994 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2995 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2996 | obj.caller = request.user |
| 2997 | if obj.can_update(request.user): |
| 2998 | return super(TagList, self).create(request, *args, **kwargs) |
| 2999 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3000 | raise Exception("failed obj.can_update") |
| 3001 | |
| 3002 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 3003 | if (ret.status_code%100 != 200): |
| 3004 | raise Exception(ret.data) |
| 3005 | |
| 3006 | return ret |
| 3007 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3008 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3009 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3010 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3011 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3012 | id_serializer_class = TagIdSerializer |
| 3013 | |
| 3014 | def get_serializer_class(self): |
| 3015 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3016 | if (no_hyperlinks): |
| 3017 | return self.id_serializer_class |
| 3018 | else: |
| 3019 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3020 | |
| 3021 | def get_queryset(self): |
| 3022 | return Tag.select_by_user(self.request.user) |
| 3023 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3024 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3025 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3026 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3027 | |
| 3028 | |
| 3029 | |
| 3030 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3031 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3032 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3033 | id_serializer_class = InvoiceIdSerializer |
| 3034 | filter_backends = (filters.DjangoFilterBackend,) |
| 3035 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 3036 | |
| 3037 | def get_serializer_class(self): |
| 3038 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3039 | if (no_hyperlinks): |
| 3040 | return self.id_serializer_class |
| 3041 | else: |
| 3042 | return self.serializer_class |
| 3043 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3044 | def get_queryset(self): |
| 3045 | return Invoice.select_by_user(self.request.user) |
| 3046 | |
| 3047 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3048 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3049 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3050 | response = {"error": "validation", |
| 3051 | "specific_error": "not serializer.is_valid()",
|
| 3052 | "reasons": serializer.errors}
|
| 3053 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3054 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3055 | obj.caller = request.user |
| 3056 | if obj.can_update(request.user): |
| 3057 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 3058 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3059 | raise Exception("failed obj.can_update") |
| 3060 | |
| 3061 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 3062 | if (ret.status_code%100 != 200): |
| 3063 | raise Exception(ret.data) |
| 3064 | |
| 3065 | return ret |
| 3066 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3067 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3068 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3069 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3070 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3071 | id_serializer_class = InvoiceIdSerializer |
| 3072 | |
| 3073 | def get_serializer_class(self): |
| 3074 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3075 | if (no_hyperlinks): |
| 3076 | return self.id_serializer_class |
| 3077 | else: |
| 3078 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3079 | |
| 3080 | def get_queryset(self): |
| 3081 | return Invoice.select_by_user(self.request.user) |
| 3082 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3083 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3084 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3085 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3086 | |
| 3087 | |
| 3088 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3089 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 3090 | queryset = SlicePrivilege.objects.select_related().all() |
| 3091 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3092 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3093 | filter_backends = (filters.DjangoFilterBackend,) |
| 3094 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 3095 | |
| 3096 | def get_serializer_class(self): |
| 3097 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3098 | if (no_hyperlinks): |
| 3099 | return self.id_serializer_class |
| 3100 | else: |
| 3101 | return self.serializer_class |
| 3102 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3103 | def get_queryset(self): |
| 3104 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3105 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3106 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3107 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3108 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3109 | response = {"error": "validation", |
| 3110 | "specific_error": "not serializer.is_valid()",
|
| 3111 | "reasons": serializer.errors}
|
| 3112 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3113 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3114 | obj.caller = request.user |
| 3115 | if obj.can_update(request.user): |
| 3116 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3117 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3118 | raise Exception("failed obj.can_update") |
| 3119 | |
| 3120 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3121 | if (ret.status_code%100 != 200): |
| 3122 | raise Exception(ret.data) |
| 3123 | |
| 3124 | return ret |
| 3125 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3126 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3127 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3128 | queryset = SlicePrivilege.objects.select_related().all() |
| 3129 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3130 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3131 | |
| 3132 | def get_serializer_class(self): |
| 3133 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3134 | if (no_hyperlinks): |
| 3135 | return self.id_serializer_class |
| 3136 | else: |
| 3137 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3138 | |
| 3139 | def get_queryset(self): |
| 3140 | return SlicePrivilege.select_by_user(self.request.user) |
| 3141 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3142 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3143 | |
| 3144 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3145 | |
| 3146 | |
| 3147 | |
| 3148 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 3149 | queryset = PlanetStackRole.objects.select_related().all() |
| 3150 | serializer_class = PlanetStackRoleSerializer |
| 3151 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3152 | filter_backends = (filters.DjangoFilterBackend,) |
| 3153 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3154 | |
| 3155 | def get_serializer_class(self): |
| 3156 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3157 | if (no_hyperlinks): |
| 3158 | return self.id_serializer_class |
| 3159 | else: |
| 3160 | return self.serializer_class |
| 3161 | |
| 3162 | def get_queryset(self): |
| 3163 | return PlanetStackRole.select_by_user(self.request.user) |
| 3164 | |
| 3165 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3166 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3167 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3168 | response = {"error": "validation", |
| 3169 | "specific_error": "not serializer.is_valid()",
|
| 3170 | "reasons": serializer.errors}
|
| 3171 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3172 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3173 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3174 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3175 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3176 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3177 | raise Exception("failed obj.can_update") |
| 3178 | |
| 3179 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 3180 | if (ret.status_code%100 != 200): |
| 3181 | raise Exception(ret.data) |
| 3182 | |
| 3183 | return ret |
| 3184 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3185 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3186 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3187 | queryset = PlanetStackRole.objects.select_related().all() |
| 3188 | serializer_class = PlanetStackRoleSerializer |
| 3189 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3190 | |
| 3191 | def get_serializer_class(self): |
| 3192 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3193 | if (no_hyperlinks): |
| 3194 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3195 | else: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3196 | return self.serializer_class |
| 3197 | |
| 3198 | def get_queryset(self): |
| 3199 | return PlanetStackRole.select_by_user(self.request.user) |
| 3200 | |
| 3201 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3202 | |
| 3203 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3204 | |
| 3205 | |
| 3206 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3207 | class ControllerPrivilegeList(generics.ListCreateAPIView): |
| 3208 | queryset = ControllerPrivilege.objects.select_related().all() |
| 3209 | serializer_class = ControllerPrivilegeSerializer |
| 3210 | id_serializer_class = ControllerPrivilegeIdSerializer |
| 3211 | filter_backends = (filters.DjangoFilterBackend,) |
| 3212 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 3213 | |
| 3214 | def get_serializer_class(self): |
| 3215 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3216 | if (no_hyperlinks): |
| 3217 | return self.id_serializer_class |
| 3218 | else: |
| 3219 | return self.serializer_class |
| 3220 | |
| 3221 | def get_queryset(self): |
| 3222 | return ControllerPrivilege.select_by_user(self.request.user) |
| 3223 | |
| 3224 | def create(self, request, *args, **kwargs): |
| 3225 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3226 | if not (serializer.is_valid()): |
| 3227 | response = {"error": "validation", |
| 3228 | "specific_error": "not serializer.is_valid()",
|
| 3229 | "reasons": serializer.errors}
|
| 3230 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3231 | obj = serializer.object |
| 3232 | obj.caller = request.user |
| 3233 | if obj.can_update(request.user): |
| 3234 | return super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
| 3235 | else: |
| 3236 | raise Exception("failed obj.can_update") |
| 3237 | |
| 3238 | ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
| 3239 | if (ret.status_code%100 != 200): |
| 3240 | raise Exception(ret.data) |
| 3241 | |
| 3242 | return ret |
| 3243 | |
| 3244 | |
| 3245 | class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3246 | queryset = ControllerPrivilege.objects.select_related().all() |
| 3247 | serializer_class = ControllerPrivilegeSerializer |
| 3248 | id_serializer_class = ControllerPrivilegeIdSerializer |
| 3249 | |
| 3250 | def get_serializer_class(self): |
| 3251 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3252 | if (no_hyperlinks): |
| 3253 | return self.id_serializer_class |
| 3254 | else: |
| 3255 | return self.serializer_class |
| 3256 | |
| 3257 | def get_queryset(self): |
| 3258 | return ControllerPrivilege.select_by_user(self.request.user) |
| 3259 | |
| 3260 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3261 | |
| 3262 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3263 | |
| 3264 | |
| 3265 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3266 | class NetworkSliverList(generics.ListCreateAPIView): |
| 3267 | queryset = NetworkSliver.objects.select_related().all() |
| 3268 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3269 | id_serializer_class = NetworkSliverIdSerializer |
| 3270 | filter_backends = (filters.DjangoFilterBackend,) |
| 3271 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 3272 | |
| 3273 | def get_serializer_class(self): |
| 3274 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3275 | if (no_hyperlinks): |
| 3276 | return self.id_serializer_class |
| 3277 | else: |
| 3278 | return self.serializer_class |
| 3279 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3280 | def get_queryset(self): |
| 3281 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3282 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3283 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3284 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3285 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3286 | response = {"error": "validation", |
| 3287 | "specific_error": "not serializer.is_valid()",
|
| 3288 | "reasons": serializer.errors}
|
| 3289 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3290 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3291 | obj.caller = request.user |
| 3292 | if obj.can_update(request.user): |
| 3293 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3294 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3295 | raise Exception("failed obj.can_update") |
| 3296 | |
| 3297 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3298 | if (ret.status_code%100 != 200): |
| 3299 | raise Exception(ret.data) |
| 3300 | |
| 3301 | return ret |
| 3302 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3303 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3304 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3305 | queryset = NetworkSliver.objects.select_related().all() |
| 3306 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3307 | id_serializer_class = NetworkSliverIdSerializer |
| 3308 | |
| 3309 | def get_serializer_class(self): |
| 3310 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3311 | if (no_hyperlinks): |
| 3312 | return self.id_serializer_class |
| 3313 | else: |
| 3314 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3315 | |
| 3316 | def get_queryset(self): |
| 3317 | return NetworkSliver.select_by_user(self.request.user) |
| 3318 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3319 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3320 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3321 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3322 | |
| 3323 | |
| 3324 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3325 | class ProjectList(generics.ListCreateAPIView): |
| 3326 | queryset = Project.objects.select_related().all() |
| 3327 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3328 | id_serializer_class = ProjectIdSerializer |
| 3329 | filter_backends = (filters.DjangoFilterBackend,) |
| 3330 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3331 | |
| 3332 | def get_serializer_class(self): |
| 3333 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3334 | if (no_hyperlinks): |
| 3335 | return self.id_serializer_class |
| 3336 | else: |
| 3337 | return self.serializer_class |
| 3338 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3339 | def get_queryset(self): |
| 3340 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3341 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3342 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3343 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3344 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3345 | response = {"error": "validation", |
| 3346 | "specific_error": "not serializer.is_valid()",
|
| 3347 | "reasons": serializer.errors}
|
| 3348 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3349 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3350 | obj.caller = request.user |
| 3351 | if obj.can_update(request.user): |
| 3352 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 3353 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3354 | raise Exception("failed obj.can_update") |
| 3355 | |
| 3356 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 3357 | if (ret.status_code%100 != 200): |
| 3358 | raise Exception(ret.data) |
| 3359 | |
| 3360 | return ret |
| 3361 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3362 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3363 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3364 | queryset = Project.objects.select_related().all() |
| 3365 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3366 | id_serializer_class = ProjectIdSerializer |
| 3367 | |
| 3368 | def get_serializer_class(self): |
| 3369 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3370 | if (no_hyperlinks): |
| 3371 | return self.id_serializer_class |
| 3372 | else: |
| 3373 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3374 | |
| 3375 | def get_queryset(self): |
| 3376 | return Project.select_by_user(self.request.user) |
| 3377 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3378 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3379 | |
| 3380 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3381 | |
| 3382 | |
| 3383 | |
| 3384 | class SliceList(generics.ListCreateAPIView): |
| 3385 | queryset = Slice.objects.select_related().all() |
| 3386 | serializer_class = SliceSerializer |
| 3387 | id_serializer_class = SliceIdSerializer |
| 3388 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3389 | 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 | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3390 | |
| 3391 | def get_serializer_class(self): |
| 3392 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3393 | if (no_hyperlinks): |
| 3394 | return self.id_serializer_class |
| 3395 | else: |
| 3396 | return self.serializer_class |
| 3397 | |
| 3398 | def get_queryset(self): |
| 3399 | return Slice.select_by_user(self.request.user) |
| 3400 | |
| 3401 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3402 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3403 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3404 | response = {"error": "validation", |
| 3405 | "specific_error": "not serializer.is_valid()",
|
| 3406 | "reasons": serializer.errors}
|
| 3407 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3408 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3409 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3410 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3411 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3412 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3413 | raise Exception("failed obj.can_update") |
| 3414 | |
| 3415 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3416 | if (ret.status_code%100 != 200): |
| 3417 | raise Exception(ret.data) |
| 3418 | |
| 3419 | return ret |
| 3420 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3421 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3422 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3423 | queryset = Slice.objects.select_related().all() |
| 3424 | serializer_class = SliceSerializer |
| 3425 | id_serializer_class = SliceIdSerializer |
| 3426 | |
| 3427 | def get_serializer_class(self): |
| 3428 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3429 | if (no_hyperlinks): |
| 3430 | return self.id_serializer_class |
| 3431 | else: |
| 3432 | return self.serializer_class |
| 3433 | |
| 3434 | def get_queryset(self): |
| 3435 | return Slice.select_by_user(self.request.user) |
| 3436 | |
| 3437 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3438 | |
| 3439 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3440 | |
| 3441 | |
| 3442 | |
| 3443 | class NetworkList(generics.ListCreateAPIView): |
| 3444 | queryset = Network.objects.select_related().all() |
| 3445 | serializer_class = NetworkSerializer |
| 3446 | id_serializer_class = NetworkIdSerializer |
| 3447 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3448 | 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 | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3449 | |
| 3450 | def get_serializer_class(self): |
| 3451 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3452 | if (no_hyperlinks): |
| 3453 | return self.id_serializer_class |
| 3454 | else: |
| 3455 | return self.serializer_class |
| 3456 | |
| 3457 | def get_queryset(self): |
| 3458 | return Network.select_by_user(self.request.user) |
| 3459 | |
| 3460 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3461 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3462 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3463 | response = {"error": "validation", |
| 3464 | "specific_error": "not serializer.is_valid()",
|
| 3465 | "reasons": serializer.errors}
|
| 3466 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3467 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3468 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3469 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3470 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3471 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3472 | raise Exception("failed obj.can_update") |
| 3473 | |
| 3474 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3475 | if (ret.status_code%100 != 200): |
| 3476 | raise Exception(ret.data) |
| 3477 | |
| 3478 | return ret |
| 3479 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3480 | |
| 3481 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3482 | queryset = Network.objects.select_related().all() |
| 3483 | serializer_class = NetworkSerializer |
| 3484 | id_serializer_class = NetworkIdSerializer |
| 3485 | |
| 3486 | def get_serializer_class(self): |
| 3487 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3488 | if (no_hyperlinks): |
| 3489 | return self.id_serializer_class |
| 3490 | else: |
| 3491 | return self.serializer_class |
| 3492 | |
| 3493 | def get_queryset(self): |
| 3494 | return Network.select_by_user(self.request.user) |
| 3495 | |
| 3496 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3497 | |
| 3498 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3499 | |
| 3500 | |
| 3501 | |
| 3502 | class ServiceList(generics.ListCreateAPIView): |
| 3503 | queryset = Service.objects.select_related().all() |
| 3504 | serializer_class = ServiceSerializer |
| 3505 | id_serializer_class = ServiceIdSerializer |
| 3506 | filter_backends = (filters.DjangoFilterBackend,) |
| 3507 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 3508 | |
| 3509 | def get_serializer_class(self): |
| 3510 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3511 | if (no_hyperlinks): |
| 3512 | return self.id_serializer_class |
| 3513 | else: |
| 3514 | return self.serializer_class |
| 3515 | |
| 3516 | def get_queryset(self): |
| 3517 | return Service.select_by_user(self.request.user) |
| 3518 | |
| 3519 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3520 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3521 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3522 | response = {"error": "validation", |
| 3523 | "specific_error": "not serializer.is_valid()",
|
| 3524 | "reasons": serializer.errors}
|
| 3525 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3526 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3527 | obj.caller = request.user |
| 3528 | if obj.can_update(request.user): |
| 3529 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3530 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3531 | raise Exception("failed obj.can_update") |
| 3532 | |
| 3533 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3534 | if (ret.status_code%100 != 200): |
| 3535 | raise Exception(ret.data) |
| 3536 | |
| 3537 | return ret |
| 3538 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3539 | |
| 3540 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3541 | queryset = Service.objects.select_related().all() |
| 3542 | serializer_class = ServiceSerializer |
| 3543 | id_serializer_class = ServiceIdSerializer |
| 3544 | |
| 3545 | def get_serializer_class(self): |
| 3546 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3547 | if (no_hyperlinks): |
| 3548 | return self.id_serializer_class |
| 3549 | else: |
| 3550 | return self.serializer_class |
| 3551 | |
| 3552 | def get_queryset(self): |
| 3553 | return Service.select_by_user(self.request.user) |
| 3554 | |
| 3555 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3556 | |
| 3557 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3558 | |
| 3559 | |
| 3560 | |
| 3561 | class ServiceClassList(generics.ListCreateAPIView): |
| 3562 | queryset = ServiceClass.objects.select_related().all() |
| 3563 | serializer_class = ServiceClassSerializer |
| 3564 | id_serializer_class = ServiceClassIdSerializer |
| 3565 | filter_backends = (filters.DjangoFilterBackend,) |
| 3566 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 3567 | |
| 3568 | def get_serializer_class(self): |
| 3569 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3570 | if (no_hyperlinks): |
| 3571 | return self.id_serializer_class |
| 3572 | else: |
| 3573 | return self.serializer_class |
| 3574 | |
| 3575 | def get_queryset(self): |
| 3576 | return ServiceClass.select_by_user(self.request.user) |
| 3577 | |
| 3578 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3579 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3580 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3581 | response = {"error": "validation", |
| 3582 | "specific_error": "not serializer.is_valid()",
|
| 3583 | "reasons": serializer.errors}
|
| 3584 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3585 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3586 | obj.caller = request.user |
| 3587 | if obj.can_update(request.user): |
| 3588 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3589 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3590 | raise Exception("failed obj.can_update") |
| 3591 | |
| 3592 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3593 | if (ret.status_code%100 != 200): |
| 3594 | raise Exception(ret.data) |
| 3595 | |
| 3596 | return ret |
| 3597 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3598 | |
| 3599 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3600 | queryset = ServiceClass.objects.select_related().all() |
| 3601 | serializer_class = ServiceClassSerializer |
| 3602 | id_serializer_class = ServiceClassIdSerializer |
| 3603 | |
| 3604 | def get_serializer_class(self): |
| 3605 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3606 | if (no_hyperlinks): |
| 3607 | return self.id_serializer_class |
| 3608 | else: |
| 3609 | return self.serializer_class |
| 3610 | |
| 3611 | def get_queryset(self): |
| 3612 | return ServiceClass.select_by_user(self.request.user) |
| 3613 | |
| 3614 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3615 | |
| 3616 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3617 | |
| 3618 | |
| 3619 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3620 | class ControllerNetworksList(generics.ListCreateAPIView): |
| 3621 | queryset = ControllerNetworks.objects.select_related().all() |
| 3622 | serializer_class = ControllerNetworksSerializer |
| 3623 | id_serializer_class = ControllerNetworksIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3624 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3625 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3626 | |
| 3627 | def get_serializer_class(self): |
| 3628 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3629 | if (no_hyperlinks): |
| 3630 | return self.id_serializer_class |
| 3631 | else: |
| 3632 | return self.serializer_class |
| 3633 | |
| 3634 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3635 | return ControllerNetworks.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3636 | |
| 3637 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3638 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3639 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3640 | response = {"error": "validation", |
| 3641 | "specific_error": "not serializer.is_valid()",
|
| 3642 | "reasons": serializer.errors}
|
| 3643 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3644 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3645 | obj.caller = request.user |
| 3646 | if obj.can_update(request.user): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3647 | return super(ControllerNetworksList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3648 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3649 | raise Exception("failed obj.can_update") |
| 3650 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3651 | ret = super(ControllerNetworksList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3652 | if (ret.status_code%100 != 200): |
| 3653 | raise Exception(ret.data) |
| 3654 | |
| 3655 | return ret |
| 3656 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3657 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3658 | class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3659 | queryset = ControllerNetworks.objects.select_related().all() |
| 3660 | serializer_class = ControllerNetworksSerializer |
| 3661 | id_serializer_class = ControllerNetworksIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3662 | |
| 3663 | def get_serializer_class(self): |
| 3664 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3665 | if (no_hyperlinks): |
| 3666 | return self.id_serializer_class |
| 3667 | else: |
| 3668 | return self.serializer_class |
| 3669 | |
| 3670 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3671 | return ControllerNetworks.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3672 | |
| 3673 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3674 | |
| 3675 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3676 | |
| 3677 | |
| 3678 | |
| 3679 | class ChargeList(generics.ListCreateAPIView): |
| 3680 | queryset = Charge.objects.select_related().all() |
| 3681 | serializer_class = ChargeSerializer |
| 3682 | id_serializer_class = ChargeIdSerializer |
| 3683 | filter_backends = (filters.DjangoFilterBackend,) |
| 3684 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 3685 | |
| 3686 | def get_serializer_class(self): |
| 3687 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3688 | if (no_hyperlinks): |
| 3689 | return self.id_serializer_class |
| 3690 | else: |
| 3691 | return self.serializer_class |
| 3692 | |
| 3693 | def get_queryset(self): |
| 3694 | return Charge.select_by_user(self.request.user) |
| 3695 | |
| 3696 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3697 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3698 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3699 | response = {"error": "validation", |
| 3700 | "specific_error": "not serializer.is_valid()",
|
| 3701 | "reasons": serializer.errors}
|
| 3702 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3703 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3704 | obj.caller = request.user |
| 3705 | if obj.can_update(request.user): |
| 3706 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3707 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3708 | raise Exception("failed obj.can_update") |
| 3709 | |
| 3710 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3711 | if (ret.status_code%100 != 200): |
| 3712 | raise Exception(ret.data) |
| 3713 | |
| 3714 | return ret |
| 3715 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3716 | |
| 3717 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3718 | queryset = Charge.objects.select_related().all() |
| 3719 | serializer_class = ChargeSerializer |
| 3720 | id_serializer_class = ChargeIdSerializer |
| 3721 | |
| 3722 | def get_serializer_class(self): |
| 3723 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3724 | if (no_hyperlinks): |
| 3725 | return self.id_serializer_class |
| 3726 | else: |
| 3727 | return self.serializer_class |
| 3728 | |
| 3729 | def get_queryset(self): |
| 3730 | return Charge.select_by_user(self.request.user) |
| 3731 | |
| 3732 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3733 | |
| 3734 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3735 | |
| 3736 | |
| 3737 | |
| 3738 | class RoleList(generics.ListCreateAPIView): |
| 3739 | queryset = Role.objects.select_related().all() |
| 3740 | serializer_class = RoleSerializer |
| 3741 | id_serializer_class = RoleIdSerializer |
| 3742 | filter_backends = (filters.DjangoFilterBackend,) |
| 3743 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 3744 | |
| 3745 | def get_serializer_class(self): |
| 3746 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3747 | if (no_hyperlinks): |
| 3748 | return self.id_serializer_class |
| 3749 | else: |
| 3750 | return self.serializer_class |
| 3751 | |
| 3752 | def get_queryset(self): |
| 3753 | return Role.select_by_user(self.request.user) |
| 3754 | |
| 3755 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3756 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3757 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3758 | response = {"error": "validation", |
| 3759 | "specific_error": "not serializer.is_valid()",
|
| 3760 | "reasons": serializer.errors}
|
| 3761 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3762 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3763 | obj.caller = request.user |
| 3764 | if obj.can_update(request.user): |
| 3765 | return super(RoleList, self).create(request, *args, **kwargs) |
| 3766 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3767 | raise Exception("failed obj.can_update") |
| 3768 | |
| 3769 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 3770 | if (ret.status_code%100 != 200): |
| 3771 | raise Exception(ret.data) |
| 3772 | |
| 3773 | return ret |
| 3774 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3775 | |
| 3776 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3777 | queryset = Role.objects.select_related().all() |
| 3778 | serializer_class = RoleSerializer |
| 3779 | id_serializer_class = RoleIdSerializer |
| 3780 | |
| 3781 | def get_serializer_class(self): |
| 3782 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3783 | if (no_hyperlinks): |
| 3784 | return self.id_serializer_class |
| 3785 | else: |
| 3786 | return self.serializer_class |
| 3787 | |
| 3788 | def get_queryset(self): |
| 3789 | return Role.select_by_user(self.request.user) |
| 3790 | |
| 3791 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3792 | |
| 3793 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3794 | |
| 3795 | |
| 3796 | |
| 3797 | class UsableObjectList(generics.ListCreateAPIView): |
| 3798 | queryset = UsableObject.objects.select_related().all() |
| 3799 | serializer_class = UsableObjectSerializer |
| 3800 | id_serializer_class = UsableObjectIdSerializer |
| 3801 | filter_backends = (filters.DjangoFilterBackend,) |
| 3802 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3803 | |
| 3804 | def get_serializer_class(self): |
| 3805 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3806 | if (no_hyperlinks): |
| 3807 | return self.id_serializer_class |
| 3808 | else: |
| 3809 | return self.serializer_class |
| 3810 | |
| 3811 | def get_queryset(self): |
| 3812 | return UsableObject.select_by_user(self.request.user) |
| 3813 | |
| 3814 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3815 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3816 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3817 | response = {"error": "validation", |
| 3818 | "specific_error": "not serializer.is_valid()",
|
| 3819 | "reasons": serializer.errors}
|
| 3820 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3821 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3822 | obj.caller = request.user |
| 3823 | if obj.can_update(request.user): |
| 3824 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3825 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3826 | raise Exception("failed obj.can_update") |
| 3827 | |
| 3828 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3829 | if (ret.status_code%100 != 200): |
| 3830 | raise Exception(ret.data) |
| 3831 | |
| 3832 | return ret |
| 3833 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3834 | |
| 3835 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3836 | queryset = UsableObject.objects.select_related().all() |
| 3837 | serializer_class = UsableObjectSerializer |
| 3838 | id_serializer_class = UsableObjectIdSerializer |
| 3839 | |
| 3840 | def get_serializer_class(self): |
| 3841 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3842 | if (no_hyperlinks): |
| 3843 | return self.id_serializer_class |
| 3844 | else: |
| 3845 | return self.serializer_class |
| 3846 | |
| 3847 | def get_queryset(self): |
| 3848 | return UsableObject.select_by_user(self.request.user) |
| 3849 | |
| 3850 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3851 | |
| 3852 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3853 | |
| 3854 | |
| 3855 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3856 | class ControllerSiteDeploymentsList(generics.ListCreateAPIView): |
| 3857 | queryset = ControllerSiteDeployments.objects.select_related().all() |
| 3858 | serializer_class = ControllerSiteDeploymentsSerializer |
| 3859 | id_serializer_class = ControllerSiteDeploymentsIdSerializer |
| 3860 | filter_backends = (filters.DjangoFilterBackend,) |
| 3861 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 3862 | |
| 3863 | def get_serializer_class(self): |
| 3864 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3865 | if (no_hyperlinks): |
| 3866 | return self.id_serializer_class |
| 3867 | else: |
| 3868 | return self.serializer_class |
| 3869 | |
| 3870 | def get_queryset(self): |
| 3871 | return ControllerSiteDeployments.select_by_user(self.request.user) |
| 3872 | |
| 3873 | def create(self, request, *args, **kwargs): |
| 3874 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3875 | if not (serializer.is_valid()): |
| 3876 | response = {"error": "validation", |
| 3877 | "specific_error": "not serializer.is_valid()",
|
| 3878 | "reasons": serializer.errors}
|
| 3879 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3880 | obj = serializer.object |
| 3881 | obj.caller = request.user |
| 3882 | if obj.can_update(request.user): |
| 3883 | return super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs) |
| 3884 | else: |
| 3885 | raise Exception("failed obj.can_update") |
| 3886 | |
| 3887 | ret = super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs) |
| 3888 | if (ret.status_code%100 != 200): |
| 3889 | raise Exception(ret.data) |
| 3890 | |
| 3891 | return ret |
| 3892 | |
| 3893 | |
| 3894 | class ControllerSiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3895 | queryset = ControllerSiteDeployments.objects.select_related().all() |
| 3896 | serializer_class = ControllerSiteDeploymentsSerializer |
| 3897 | id_serializer_class = ControllerSiteDeploymentsIdSerializer |
| 3898 | |
| 3899 | def get_serializer_class(self): |
| 3900 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3901 | if (no_hyperlinks): |
| 3902 | return self.id_serializer_class |
| 3903 | else: |
| 3904 | return self.serializer_class |
| 3905 | |
| 3906 | def get_queryset(self): |
| 3907 | return ControllerSiteDeployments.select_by_user(self.request.user) |
| 3908 | |
| 3909 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3910 | |
| 3911 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3912 | |
| 3913 | |
| 3914 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3915 | class SiteRoleList(generics.ListCreateAPIView): |
| 3916 | queryset = SiteRole.objects.select_related().all() |
| 3917 | serializer_class = SiteRoleSerializer |
| 3918 | id_serializer_class = SiteRoleIdSerializer |
| 3919 | filter_backends = (filters.DjangoFilterBackend,) |
| 3920 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3921 | |
| 3922 | def get_serializer_class(self): |
| 3923 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3924 | if (no_hyperlinks): |
| 3925 | return self.id_serializer_class |
| 3926 | else: |
| 3927 | return self.serializer_class |
| 3928 | |
| 3929 | def get_queryset(self): |
| 3930 | return SiteRole.select_by_user(self.request.user) |
| 3931 | |
| 3932 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3933 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3934 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3935 | response = {"error": "validation", |
| 3936 | "specific_error": "not serializer.is_valid()",
|
| 3937 | "reasons": serializer.errors}
|
| 3938 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3939 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3940 | obj.caller = request.user |
| 3941 | if obj.can_update(request.user): |
| 3942 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3943 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3944 | raise Exception("failed obj.can_update") |
| 3945 | |
| 3946 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3947 | if (ret.status_code%100 != 200): |
| 3948 | raise Exception(ret.data) |
| 3949 | |
| 3950 | return ret |
| 3951 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3952 | |
| 3953 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3954 | queryset = SiteRole.objects.select_related().all() |
| 3955 | serializer_class = SiteRoleSerializer |
| 3956 | id_serializer_class = SiteRoleIdSerializer |
| 3957 | |
| 3958 | def get_serializer_class(self): |
| 3959 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3960 | if (no_hyperlinks): |
| 3961 | return self.id_serializer_class |
| 3962 | else: |
| 3963 | return self.serializer_class |
| 3964 | |
| 3965 | def get_queryset(self): |
| 3966 | return SiteRole.select_by_user(self.request.user) |
| 3967 | |
| 3968 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3969 | |
| 3970 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3971 | |
| 3972 | |
| 3973 | |
| 3974 | class SliceCredentialList(generics.ListCreateAPIView): |
| 3975 | queryset = SliceCredential.objects.select_related().all() |
| 3976 | serializer_class = SliceCredentialSerializer |
| 3977 | id_serializer_class = SliceCredentialIdSerializer |
| 3978 | filter_backends = (filters.DjangoFilterBackend,) |
| 3979 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 3980 | |
| 3981 | def get_serializer_class(self): |
| 3982 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3983 | if (no_hyperlinks): |
| 3984 | return self.id_serializer_class |
| 3985 | else: |
| 3986 | return self.serializer_class |
| 3987 | |
| 3988 | def get_queryset(self): |
| 3989 | return SliceCredential.select_by_user(self.request.user) |
| 3990 | |
| 3991 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3992 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3993 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3994 | response = {"error": "validation", |
| 3995 | "specific_error": "not serializer.is_valid()",
|
| 3996 | "reasons": serializer.errors}
|
| 3997 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3998 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3999 | obj.caller = request.user |
| 4000 | if obj.can_update(request.user): |
| 4001 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 4002 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4003 | raise Exception("failed obj.can_update") |
| 4004 | |
| 4005 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 4006 | if (ret.status_code%100 != 200): |
| 4007 | raise Exception(ret.data) |
| 4008 | |
| 4009 | return ret |
| 4010 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4011 | |
| 4012 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4013 | queryset = SliceCredential.objects.select_related().all() |
| 4014 | serializer_class = SliceCredentialSerializer |
| 4015 | id_serializer_class = SliceCredentialIdSerializer |
| 4016 | |
| 4017 | def get_serializer_class(self): |
| 4018 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4019 | if (no_hyperlinks): |
| 4020 | return self.id_serializer_class |
| 4021 | else: |
| 4022 | return self.serializer_class |
| 4023 | |
| 4024 | def get_queryset(self): |
| 4025 | return SliceCredential.select_by_user(self.request.user) |
| 4026 | |
| 4027 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4028 | |
| 4029 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4030 | |
| 4031 | |
| 4032 | |
| 4033 | class SliverList(generics.ListCreateAPIView): |
| 4034 | queryset = Sliver.objects.select_related().all() |
| 4035 | serializer_class = SliverSerializer |
| 4036 | id_serializer_class = SliverIdSerializer |
| 4037 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 4038 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4039 | |
| 4040 | def get_serializer_class(self): |
| 4041 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4042 | if (no_hyperlinks): |
| 4043 | return self.id_serializer_class |
| 4044 | else: |
| 4045 | return self.serializer_class |
| 4046 | |
| 4047 | def get_queryset(self): |
| 4048 | return Sliver.select_by_user(self.request.user) |
| 4049 | |
| 4050 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4051 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4052 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4053 | response = {"error": "validation", |
| 4054 | "specific_error": "not serializer.is_valid()",
|
| 4055 | "reasons": serializer.errors}
|
| 4056 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4057 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4058 | obj.caller = request.user |
| 4059 | if obj.can_update(request.user): |
| 4060 | return super(SliverList, self).create(request, *args, **kwargs) |
| 4061 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4062 | raise Exception("failed obj.can_update") |
| 4063 | |
| 4064 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 4065 | if (ret.status_code%100 != 200): |
| 4066 | raise Exception(ret.data) |
| 4067 | |
| 4068 | return ret |
| 4069 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4070 | |
| 4071 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4072 | queryset = Sliver.objects.select_related().all() |
| 4073 | serializer_class = SliverSerializer |
| 4074 | id_serializer_class = SliverIdSerializer |
| 4075 | |
| 4076 | def get_serializer_class(self): |
| 4077 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4078 | if (no_hyperlinks): |
| 4079 | return self.id_serializer_class |
| 4080 | else: |
| 4081 | return self.serializer_class |
| 4082 | |
| 4083 | def get_queryset(self): |
| 4084 | return Sliver.select_by_user(self.request.user) |
| 4085 | |
| 4086 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4087 | |
| 4088 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4089 | |
| 4090 | |
| 4091 | |
| 4092 | class NodeList(generics.ListCreateAPIView): |
| 4093 | queryset = Node.objects.select_related().all() |
| 4094 | serializer_class = NodeSerializer |
| 4095 | id_serializer_class = NodeIdSerializer |
| 4096 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4097 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4098 | |
| 4099 | def get_serializer_class(self): |
| 4100 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4101 | if (no_hyperlinks): |
| 4102 | return self.id_serializer_class |
| 4103 | else: |
| 4104 | return self.serializer_class |
| 4105 | |
| 4106 | def get_queryset(self): |
| 4107 | return Node.select_by_user(self.request.user) |
| 4108 | |
| 4109 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4110 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4111 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4112 | response = {"error": "validation", |
| 4113 | "specific_error": "not serializer.is_valid()",
|
| 4114 | "reasons": serializer.errors}
|
| 4115 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4116 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4117 | obj.caller = request.user |
| 4118 | if obj.can_update(request.user): |
| 4119 | return super(NodeList, self).create(request, *args, **kwargs) |
| 4120 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4121 | raise Exception("failed obj.can_update") |
| 4122 | |
| 4123 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 4124 | if (ret.status_code%100 != 200): |
| 4125 | raise Exception(ret.data) |
| 4126 | |
| 4127 | return ret |
| 4128 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4129 | |
| 4130 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4131 | queryset = Node.objects.select_related().all() |
| 4132 | serializer_class = NodeSerializer |
| 4133 | id_serializer_class = NodeIdSerializer |
| 4134 | |
| 4135 | def get_serializer_class(self): |
| 4136 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4137 | if (no_hyperlinks): |
| 4138 | return self.id_serializer_class |
| 4139 | else: |
| 4140 | return self.serializer_class |
| 4141 | |
| 4142 | def get_queryset(self): |
| 4143 | return Node.select_by_user(self.request.user) |
| 4144 | |
| 4145 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4146 | |
| 4147 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4148 | |
| 4149 | |
| 4150 | |
| 4151 | class DashboardViewList(generics.ListCreateAPIView): |
| 4152 | queryset = DashboardView.objects.select_related().all() |
| 4153 | serializer_class = DashboardViewSerializer |
| 4154 | id_serializer_class = DashboardViewIdSerializer |
| 4155 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4156 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4157 | |
| 4158 | def get_serializer_class(self): |
| 4159 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4160 | if (no_hyperlinks): |
| 4161 | return self.id_serializer_class |
| 4162 | else: |
| 4163 | return self.serializer_class |
| 4164 | |
| 4165 | def get_queryset(self): |
| 4166 | return DashboardView.select_by_user(self.request.user) |
| 4167 | |
| 4168 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4169 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4170 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4171 | response = {"error": "validation", |
| 4172 | "specific_error": "not serializer.is_valid()",
|
| 4173 | "reasons": serializer.errors}
|
| 4174 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4175 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4176 | obj.caller = request.user |
| 4177 | if obj.can_update(request.user): |
| 4178 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4179 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4180 | raise Exception("failed obj.can_update") |
| 4181 | |
| 4182 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4183 | if (ret.status_code%100 != 200): |
| 4184 | raise Exception(ret.data) |
| 4185 | |
| 4186 | return ret |
| 4187 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4188 | |
| 4189 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4190 | queryset = DashboardView.objects.select_related().all() |
| 4191 | serializer_class = DashboardViewSerializer |
| 4192 | id_serializer_class = DashboardViewIdSerializer |
| 4193 | |
| 4194 | def get_serializer_class(self): |
| 4195 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4196 | if (no_hyperlinks): |
| 4197 | return self.id_serializer_class |
| 4198 | else: |
| 4199 | return self.serializer_class |
| 4200 | |
| 4201 | def get_queryset(self): |
| 4202 | return DashboardView.select_by_user(self.request.user) |
| 4203 | |
| 4204 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4205 | |
| 4206 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4207 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4208 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4209 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4210 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 4211 | queryset = ImageDeployments.objects.select_related().all() |
| 4212 | serializer_class = ImageDeploymentsSerializer |
| 4213 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4214 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4215 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4216 | |
| 4217 | def get_serializer_class(self): |
| 4218 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4219 | if (no_hyperlinks): |
| 4220 | return self.id_serializer_class |
| 4221 | else: |
| 4222 | return self.serializer_class |
| 4223 | |
| 4224 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4225 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4226 | |
| 4227 | def create(self, request, *args, **kwargs): |
| 4228 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4229 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4230 | response = {"error": "validation", |
| 4231 | "specific_error": "not serializer.is_valid()",
|
| 4232 | "reasons": serializer.errors}
|
| 4233 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4234 | obj = serializer.object |
| 4235 | obj.caller = request.user |
| 4236 | if obj.can_update(request.user): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4237 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4238 | else: |
| 4239 | raise Exception("failed obj.can_update") |
| 4240 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4241 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4242 | if (ret.status_code%100 != 200): |
| 4243 | raise Exception(ret.data) |
| 4244 | |
| 4245 | return ret |
| 4246 | |
| 4247 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4248 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4249 | queryset = ImageDeployments.objects.select_related().all() |
| 4250 | serializer_class = ImageDeploymentsSerializer |
| 4251 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4252 | |
| 4253 | def get_serializer_class(self): |
| 4254 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4255 | if (no_hyperlinks): |
| 4256 | return self.id_serializer_class |
| 4257 | else: |
| 4258 | return self.serializer_class |
| 4259 | |
| 4260 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4261 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4262 | |
| 4263 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4264 | |
| 4265 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4266 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4267 | |
| 4268 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4269 | class ReservedResourceList(generics.ListCreateAPIView): |
| 4270 | queryset = ReservedResource.objects.select_related().all() |
| 4271 | serializer_class = ReservedResourceSerializer |
| 4272 | id_serializer_class = ReservedResourceIdSerializer |
| 4273 | filter_backends = (filters.DjangoFilterBackend,) |
| 4274 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 4275 | |
| 4276 | def get_serializer_class(self): |
| 4277 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4278 | if (no_hyperlinks): |
| 4279 | return self.id_serializer_class |
| 4280 | else: |
| 4281 | return self.serializer_class |
| 4282 | |
| 4283 | def get_queryset(self): |
| 4284 | return ReservedResource.select_by_user(self.request.user) |
| 4285 | |
| 4286 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4287 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4288 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4289 | response = {"error": "validation", |
| 4290 | "specific_error": "not serializer.is_valid()",
|
| 4291 | "reasons": serializer.errors}
|
| 4292 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4293 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4294 | obj.caller = request.user |
| 4295 | if obj.can_update(request.user): |
| 4296 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4297 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4298 | raise Exception("failed obj.can_update") |
| 4299 | |
| 4300 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4301 | if (ret.status_code%100 != 200): |
| 4302 | raise Exception(ret.data) |
| 4303 | |
| 4304 | return ret |
| 4305 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4306 | |
| 4307 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4308 | queryset = ReservedResource.objects.select_related().all() |
| 4309 | serializer_class = ReservedResourceSerializer |
| 4310 | id_serializer_class = ReservedResourceIdSerializer |
| 4311 | |
| 4312 | def get_serializer_class(self): |
| 4313 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4314 | if (no_hyperlinks): |
| 4315 | return self.id_serializer_class |
| 4316 | else: |
| 4317 | return self.serializer_class |
| 4318 | |
| 4319 | def get_queryset(self): |
| 4320 | return ReservedResource.select_by_user(self.request.user) |
| 4321 | |
| 4322 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4323 | |
| 4324 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4325 | |
| 4326 | |
| 4327 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4328 | class PaymentList(generics.ListCreateAPIView): |
| 4329 | queryset = Payment.objects.select_related().all() |
| 4330 | serializer_class = PaymentSerializer |
| 4331 | id_serializer_class = PaymentIdSerializer |
| 4332 | filter_backends = (filters.DjangoFilterBackend,) |
| 4333 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 4334 | |
| 4335 | def get_serializer_class(self): |
| 4336 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4337 | if (no_hyperlinks): |
| 4338 | return self.id_serializer_class |
| 4339 | else: |
| 4340 | return self.serializer_class |
| 4341 | |
| 4342 | def get_queryset(self): |
| 4343 | return Payment.select_by_user(self.request.user) |
| 4344 | |
| 4345 | def create(self, request, *args, **kwargs): |
| 4346 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4347 | if not (serializer.is_valid()): |
| 4348 | response = {"error": "validation", |
| 4349 | "specific_error": "not serializer.is_valid()",
|
| 4350 | "reasons": serializer.errors}
|
| 4351 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4352 | obj = serializer.object |
| 4353 | obj.caller = request.user |
| 4354 | if obj.can_update(request.user): |
| 4355 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 4356 | else: |
| 4357 | raise Exception("failed obj.can_update") |
| 4358 | |
| 4359 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 4360 | if (ret.status_code%100 != 200): |
| 4361 | raise Exception(ret.data) |
| 4362 | |
| 4363 | return ret |
| 4364 | |
| 4365 | |
| 4366 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4367 | queryset = Payment.objects.select_related().all() |
| 4368 | serializer_class = PaymentSerializer |
| 4369 | id_serializer_class = PaymentIdSerializer |
| 4370 | |
| 4371 | def get_serializer_class(self): |
| 4372 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4373 | if (no_hyperlinks): |
| 4374 | return self.id_serializer_class |
| 4375 | else: |
| 4376 | return self.serializer_class |
| 4377 | |
| 4378 | def get_queryset(self): |
| 4379 | return Payment.select_by_user(self.request.user) |
| 4380 | |
| 4381 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4382 | |
| 4383 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4384 | |
| 4385 | |
| 4386 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4387 | class NetworkSliceList(generics.ListCreateAPIView): |
| 4388 | queryset = NetworkSlice.objects.select_related().all() |
| 4389 | serializer_class = NetworkSliceSerializer |
| 4390 | id_serializer_class = NetworkSliceIdSerializer |
| 4391 | filter_backends = (filters.DjangoFilterBackend,) |
| 4392 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 4393 | |
| 4394 | def get_serializer_class(self): |
| 4395 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4396 | if (no_hyperlinks): |
| 4397 | return self.id_serializer_class |
| 4398 | else: |
| 4399 | return self.serializer_class |
| 4400 | |
| 4401 | def get_queryset(self): |
| 4402 | return NetworkSlice.select_by_user(self.request.user) |
| 4403 | |
| 4404 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4405 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4406 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4407 | response = {"error": "validation", |
| 4408 | "specific_error": "not serializer.is_valid()",
|
| 4409 | "reasons": serializer.errors}
|
| 4410 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4411 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4412 | obj.caller = request.user |
| 4413 | if obj.can_update(request.user): |
| 4414 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4415 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4416 | raise Exception("failed obj.can_update") |
| 4417 | |
| 4418 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4419 | if (ret.status_code%100 != 200): |
| 4420 | raise Exception(ret.data) |
| 4421 | |
| 4422 | return ret |
| 4423 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4424 | |
| 4425 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4426 | queryset = NetworkSlice.objects.select_related().all() |
| 4427 | serializer_class = NetworkSliceSerializer |
| 4428 | id_serializer_class = NetworkSliceIdSerializer |
| 4429 | |
| 4430 | def get_serializer_class(self): |
| 4431 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4432 | if (no_hyperlinks): |
| 4433 | return self.id_serializer_class |
| 4434 | else: |
| 4435 | return self.serializer_class |
| 4436 | |
| 4437 | def get_queryset(self): |
| 4438 | return NetworkSlice.select_by_user(self.request.user) |
| 4439 | |
| 4440 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4441 | |
| 4442 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4443 | |
| 4444 | |
| 4445 | |
| 4446 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 4447 | queryset = UserDashboardView.objects.select_related().all() |
| 4448 | serializer_class = UserDashboardViewSerializer |
| 4449 | id_serializer_class = UserDashboardViewIdSerializer |
| 4450 | filter_backends = (filters.DjangoFilterBackend,) |
| 4451 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 4452 | |
| 4453 | def get_serializer_class(self): |
| 4454 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4455 | if (no_hyperlinks): |
| 4456 | return self.id_serializer_class |
| 4457 | else: |
| 4458 | return self.serializer_class |
| 4459 | |
| 4460 | def get_queryset(self): |
| 4461 | return UserDashboardView.select_by_user(self.request.user) |
| 4462 | |
| 4463 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4464 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4465 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4466 | response = {"error": "validation", |
| 4467 | "specific_error": "not serializer.is_valid()",
|
| 4468 | "reasons": serializer.errors}
|
| 4469 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4470 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4471 | obj.caller = request.user |
| 4472 | if obj.can_update(request.user): |
| 4473 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4474 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4475 | raise Exception("failed obj.can_update") |
| 4476 | |
| 4477 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4478 | if (ret.status_code%100 != 200): |
| 4479 | raise Exception(ret.data) |
| 4480 | |
| 4481 | return ret |
| 4482 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4483 | |
| 4484 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4485 | queryset = UserDashboardView.objects.select_related().all() |
| 4486 | serializer_class = UserDashboardViewSerializer |
| 4487 | id_serializer_class = UserDashboardViewIdSerializer |
| 4488 | |
| 4489 | def get_serializer_class(self): |
| 4490 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4491 | if (no_hyperlinks): |
| 4492 | return self.id_serializer_class |
| 4493 | else: |
| 4494 | return self.serializer_class |
| 4495 | |
| 4496 | def get_queryset(self): |
| 4497 | return UserDashboardView.select_by_user(self.request.user) |
| 4498 | |
| 4499 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4500 | |
| 4501 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4502 | |
| 4503 | |
| 4504 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4505 | class ControllerList(generics.ListCreateAPIView): |
| 4506 | queryset = Controller.objects.select_related().all() |
| 4507 | serializer_class = ControllerSerializer |
| 4508 | id_serializer_class = ControllerIdSerializer |
| 4509 | filter_backends = (filters.DjangoFilterBackend,) |
| 4510 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 4511 | |
| 4512 | def get_serializer_class(self): |
| 4513 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4514 | if (no_hyperlinks): |
| 4515 | return self.id_serializer_class |
| 4516 | else: |
| 4517 | return self.serializer_class |
| 4518 | |
| 4519 | def get_queryset(self): |
| 4520 | return Controller.select_by_user(self.request.user) |
| 4521 | |
| 4522 | def create(self, request, *args, **kwargs): |
| 4523 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4524 | if not (serializer.is_valid()): |
| 4525 | response = {"error": "validation", |
| 4526 | "specific_error": "not serializer.is_valid()",
|
| 4527 | "reasons": serializer.errors}
|
| 4528 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4529 | obj = serializer.object |
| 4530 | obj.caller = request.user |
| 4531 | if obj.can_update(request.user): |
| 4532 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4533 | else: |
| 4534 | raise Exception("failed obj.can_update") |
| 4535 | |
| 4536 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 4537 | if (ret.status_code%100 != 200): |
| 4538 | raise Exception(ret.data) |
| 4539 | |
| 4540 | return ret |
| 4541 | |
| 4542 | |
| 4543 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4544 | queryset = Controller.objects.select_related().all() |
| 4545 | serializer_class = ControllerSerializer |
| 4546 | id_serializer_class = ControllerIdSerializer |
| 4547 | |
| 4548 | def get_serializer_class(self): |
| 4549 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4550 | if (no_hyperlinks): |
| 4551 | return self.id_serializer_class |
| 4552 | else: |
| 4553 | return self.serializer_class |
| 4554 | |
| 4555 | def get_queryset(self): |
| 4556 | return Controller.select_by_user(self.request.user) |
| 4557 | |
| 4558 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4559 | |
| 4560 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4561 | |
| 4562 | |
| 4563 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4564 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 4565 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4566 | serializer_class = PlanetStackPrivilegeSerializer |
| 4567 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4568 | filter_backends = (filters.DjangoFilterBackend,) |
| 4569 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 4570 | |
| 4571 | def get_serializer_class(self): |
| 4572 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4573 | if (no_hyperlinks): |
| 4574 | return self.id_serializer_class |
| 4575 | else: |
| 4576 | return self.serializer_class |
| 4577 | |
| 4578 | def get_queryset(self): |
| 4579 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4580 | |
| 4581 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4582 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4583 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4584 | response = {"error": "validation", |
| 4585 | "specific_error": "not serializer.is_valid()",
|
| 4586 | "reasons": serializer.errors}
|
| 4587 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4588 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4589 | obj.caller = request.user |
| 4590 | if obj.can_update(request.user): |
| 4591 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4592 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4593 | raise Exception("failed obj.can_update") |
| 4594 | |
| 4595 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4596 | if (ret.status_code%100 != 200): |
| 4597 | raise Exception(ret.data) |
| 4598 | |
| 4599 | return ret |
| 4600 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4601 | |
| 4602 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4603 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4604 | serializer_class = PlanetStackPrivilegeSerializer |
| 4605 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4606 | |
| 4607 | def get_serializer_class(self): |
| 4608 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4609 | if (no_hyperlinks): |
| 4610 | return self.id_serializer_class |
| 4611 | else: |
| 4612 | return self.serializer_class |
| 4613 | |
| 4614 | def get_queryset(self): |
| 4615 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4616 | |
| 4617 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4618 | |
| 4619 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4620 | |
| 4621 | |
| 4622 | |
| 4623 | class UserList(generics.ListCreateAPIView): |
| 4624 | queryset = User.objects.select_related().all() |
| 4625 | serializer_class = UserSerializer |
| 4626 | id_serializer_class = UserIdSerializer |
| 4627 | filter_backends = (filters.DjangoFilterBackend,) |
| 4628 | 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',) |
| 4629 | |
| 4630 | def get_serializer_class(self): |
| 4631 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4632 | if (no_hyperlinks): |
| 4633 | return self.id_serializer_class |
| 4634 | else: |
| 4635 | return self.serializer_class |
| 4636 | |
| 4637 | def get_queryset(self): |
| 4638 | return User.select_by_user(self.request.user) |
| 4639 | |
| 4640 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4641 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4642 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4643 | response = {"error": "validation", |
| 4644 | "specific_error": "not serializer.is_valid()",
|
| 4645 | "reasons": serializer.errors}
|
| 4646 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4647 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4648 | obj.caller = request.user |
| 4649 | if obj.can_update(request.user): |
| 4650 | return super(UserList, self).create(request, *args, **kwargs) |
| 4651 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4652 | raise Exception("failed obj.can_update") |
| 4653 | |
| 4654 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 4655 | if (ret.status_code%100 != 200): |
| 4656 | raise Exception(ret.data) |
| 4657 | |
| 4658 | return ret |
| 4659 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4660 | |
| 4661 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4662 | queryset = User.objects.select_related().all() |
| 4663 | serializer_class = UserSerializer |
| 4664 | id_serializer_class = UserIdSerializer |
| 4665 | |
| 4666 | def get_serializer_class(self): |
| 4667 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4668 | if (no_hyperlinks): |
| 4669 | return self.id_serializer_class |
| 4670 | else: |
| 4671 | return self.serializer_class |
| 4672 | |
| 4673 | def get_queryset(self): |
| 4674 | return User.select_by_user(self.request.user) |
| 4675 | |
| 4676 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4677 | |
| 4678 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4679 | |
| 4680 | |
| 4681 | |
| 4682 | class DeploymentList(generics.ListCreateAPIView): |
| 4683 | queryset = Deployment.objects.select_related().all() |
| 4684 | serializer_class = DeploymentSerializer |
| 4685 | id_serializer_class = DeploymentIdSerializer |
| 4686 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 4687 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4688 | |
| 4689 | def get_serializer_class(self): |
| 4690 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4691 | if (no_hyperlinks): |
| 4692 | return self.id_serializer_class |
| 4693 | else: |
| 4694 | return self.serializer_class |
| 4695 | |
| 4696 | def get_queryset(self): |
| 4697 | return Deployment.select_by_user(self.request.user) |
| 4698 | |
| 4699 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4700 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4701 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4702 | response = {"error": "validation", |
| 4703 | "specific_error": "not serializer.is_valid()",
|
| 4704 | "reasons": serializer.errors}
|
| 4705 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4706 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4707 | obj.caller = request.user |
| 4708 | if obj.can_update(request.user): |
| 4709 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 4710 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4711 | raise Exception("failed obj.can_update") |
| 4712 | |
| 4713 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 4714 | if (ret.status_code%100 != 200): |
| 4715 | raise Exception(ret.data) |
| 4716 | |
| 4717 | return ret |
| 4718 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4719 | |
| 4720 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4721 | queryset = Deployment.objects.select_related().all() |
| 4722 | serializer_class = DeploymentSerializer |
| 4723 | id_serializer_class = DeploymentIdSerializer |
| 4724 | |
| 4725 | def get_serializer_class(self): |
| 4726 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4727 | if (no_hyperlinks): |
| 4728 | return self.id_serializer_class |
| 4729 | else: |
| 4730 | return self.serializer_class |
| 4731 | |
| 4732 | def get_queryset(self): |
| 4733 | return Deployment.select_by_user(self.request.user) |
| 4734 | |
| 4735 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4736 | |
| 4737 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4738 | |
| 4739 | |
| 4740 | |
| 4741 | class ReservationList(generics.ListCreateAPIView): |
| 4742 | queryset = Reservation.objects.select_related().all() |
| 4743 | serializer_class = ReservationSerializer |
| 4744 | id_serializer_class = ReservationIdSerializer |
| 4745 | filter_backends = (filters.DjangoFilterBackend,) |
| 4746 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 4747 | |
| 4748 | def get_serializer_class(self): |
| 4749 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4750 | if (no_hyperlinks): |
| 4751 | return self.id_serializer_class |
| 4752 | else: |
| 4753 | return self.serializer_class |
| 4754 | |
| 4755 | def get_queryset(self): |
| 4756 | return Reservation.select_by_user(self.request.user) |
| 4757 | |
| 4758 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4759 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4760 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4761 | response = {"error": "validation", |
| 4762 | "specific_error": "not serializer.is_valid()",
|
| 4763 | "reasons": serializer.errors}
|
| 4764 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4765 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4766 | obj.caller = request.user |
| 4767 | if obj.can_update(request.user): |
| 4768 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 4769 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4770 | raise Exception("failed obj.can_update") |
| 4771 | |
| 4772 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 4773 | if (ret.status_code%100 != 200): |
| 4774 | raise Exception(ret.data) |
| 4775 | |
| 4776 | return ret |
| 4777 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4778 | |
| 4779 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4780 | queryset = Reservation.objects.select_related().all() |
| 4781 | serializer_class = ReservationSerializer |
| 4782 | id_serializer_class = ReservationIdSerializer |
| 4783 | |
| 4784 | def get_serializer_class(self): |
| 4785 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4786 | if (no_hyperlinks): |
| 4787 | return self.id_serializer_class |
| 4788 | else: |
| 4789 | return self.serializer_class |
| 4790 | |
| 4791 | def get_queryset(self): |
| 4792 | return Reservation.select_by_user(self.request.user) |
| 4793 | |
| 4794 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4795 | |
| 4796 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4797 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4798 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4799 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4800 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 4801 | queryset = SitePrivilege.objects.select_related().all() |
| 4802 | serializer_class = SitePrivilegeSerializer |
| 4803 | id_serializer_class = SitePrivilegeIdSerializer |
| 4804 | filter_backends = (filters.DjangoFilterBackend,) |
| 4805 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 4806 | |
| 4807 | def get_serializer_class(self): |
| 4808 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4809 | if (no_hyperlinks): |
| 4810 | return self.id_serializer_class |
| 4811 | else: |
| 4812 | return self.serializer_class |
| 4813 | |
| 4814 | def get_queryset(self): |
| 4815 | return SitePrivilege.select_by_user(self.request.user) |
| 4816 | |
| 4817 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4818 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4819 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4820 | response = {"error": "validation", |
| 4821 | "specific_error": "not serializer.is_valid()",
|
| 4822 | "reasons": serializer.errors}
|
| 4823 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4824 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4825 | obj.caller = request.user |
| 4826 | if obj.can_update(request.user): |
| 4827 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4828 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4829 | raise Exception("failed obj.can_update") |
| 4830 | |
| 4831 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4832 | if (ret.status_code%100 != 200): |
| 4833 | raise Exception(ret.data) |
| 4834 | |
| 4835 | return ret |
| 4836 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4837 | |
| 4838 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4839 | queryset = SitePrivilege.objects.select_related().all() |
| 4840 | serializer_class = SitePrivilegeSerializer |
| 4841 | id_serializer_class = SitePrivilegeIdSerializer |
| 4842 | |
| 4843 | def get_serializer_class(self): |
| 4844 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4845 | if (no_hyperlinks): |
| 4846 | return self.id_serializer_class |
| 4847 | else: |
| 4848 | return self.serializer_class |
| 4849 | |
| 4850 | def get_queryset(self): |
| 4851 | return SitePrivilege.select_by_user(self.request.user) |
| 4852 | |
| 4853 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4854 | |
| 4855 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4856 | |
| 4857 | |
| 4858 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4859 | class PlanetStackList(generics.ListCreateAPIView): |
| 4860 | queryset = PlanetStack.objects.select_related().all() |
| 4861 | serializer_class = PlanetStackSerializer |
| 4862 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4863 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4864 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4865 | |
| 4866 | def get_serializer_class(self): |
| 4867 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4868 | if (no_hyperlinks): |
| 4869 | return self.id_serializer_class |
| 4870 | else: |
| 4871 | return self.serializer_class |
| 4872 | |
| 4873 | def get_queryset(self): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4874 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4875 | |
| 4876 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4877 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4878 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4879 | response = {"error": "validation", |
| 4880 | "specific_error": "not serializer.is_valid()",
|
| 4881 | "reasons": serializer.errors}
|
| 4882 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4883 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4884 | obj.caller = request.user |
| 4885 | if obj.can_update(request.user): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4886 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4887 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4888 | raise Exception("failed obj.can_update") |
| 4889 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4890 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4891 | if (ret.status_code%100 != 200): |
| 4892 | raise Exception(ret.data) |
| 4893 | |
| 4894 | return ret |
| 4895 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4896 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4897 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4898 | queryset = PlanetStack.objects.select_related().all() |
| 4899 | serializer_class = PlanetStackSerializer |
| 4900 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4901 | |
| 4902 | def get_serializer_class(self): |
| 4903 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4904 | if (no_hyperlinks): |
| 4905 | return self.id_serializer_class |
| 4906 | else: |
| 4907 | return self.serializer_class |
| 4908 | |
| 4909 | def get_queryset(self): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4910 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4911 | |
| 4912 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4913 | |
| 4914 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4915 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4916 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4917 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 4918 | class ControllerDashboardViewList(generics.ListCreateAPIView): |
| 4919 | queryset = ControllerDashboardView.objects.select_related().all() |
| 4920 | serializer_class = ControllerDashboardViewSerializer |
| 4921 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 4922 | filter_backends = (filters.DjangoFilterBackend,) |
| 4923 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 4924 | |
| 4925 | def get_serializer_class(self): |
| 4926 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4927 | if (no_hyperlinks): |
| 4928 | return self.id_serializer_class |
| 4929 | else: |
| 4930 | return self.serializer_class |
| 4931 | |
| 4932 | def get_queryset(self): |
| 4933 | return ControllerDashboardView.select_by_user(self.request.user) |
| 4934 | |
| 4935 | def create(self, request, *args, **kwargs): |
| 4936 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4937 | if not (serializer.is_valid()): |
| 4938 | response = {"error": "validation", |
| 4939 | "specific_error": "not serializer.is_valid()",
|
| 4940 | "reasons": serializer.errors}
|
| 4941 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4942 | obj = serializer.object |
| 4943 | obj.caller = request.user |
| 4944 | if obj.can_update(request.user): |
| 4945 | return super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 4946 | else: |
| 4947 | raise Exception("failed obj.can_update") |
| 4948 | |
| 4949 | ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 4950 | if (ret.status_code%100 != 200): |
| 4951 | raise Exception(ret.data) |
| 4952 | |
| 4953 | return ret |
| 4954 | |
| 4955 | |
| 4956 | class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4957 | queryset = ControllerDashboardView.objects.select_related().all() |
| 4958 | serializer_class = ControllerDashboardViewSerializer |
| 4959 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 4960 | |
| 4961 | def get_serializer_class(self): |
| 4962 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4963 | if (no_hyperlinks): |
| 4964 | return self.id_serializer_class |
| 4965 | else: |
| 4966 | return self.serializer_class |
| 4967 | |
| 4968 | def get_queryset(self): |
| 4969 | return ControllerDashboardView.select_by_user(self.request.user) |
| 4970 | |
| 4971 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4972 | |
| 4973 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4974 | |
| 4975 | |
| 4976 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4977 | class AccountList(generics.ListCreateAPIView): |
| 4978 | queryset = Account.objects.select_related().all() |
| 4979 | serializer_class = AccountSerializer |
| 4980 | id_serializer_class = AccountIdSerializer |
| 4981 | filter_backends = (filters.DjangoFilterBackend,) |
| 4982 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 4983 | |
| 4984 | def get_serializer_class(self): |
| 4985 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4986 | if (no_hyperlinks): |
| 4987 | return self.id_serializer_class |
| 4988 | else: |
| 4989 | return self.serializer_class |
| 4990 | |
| 4991 | def get_queryset(self): |
| 4992 | return Account.select_by_user(self.request.user) |
| 4993 | |
| 4994 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4995 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4996 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4997 | response = {"error": "validation", |
| 4998 | "specific_error": "not serializer.is_valid()",
|
| 4999 | "reasons": serializer.errors}
|
| 5000 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5001 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5002 | obj.caller = request.user |
| 5003 | if obj.can_update(request.user): |
| 5004 | return super(AccountList, self).create(request, *args, **kwargs) |
| 5005 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5006 | raise Exception("failed obj.can_update") |
| 5007 | |
| 5008 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 5009 | if (ret.status_code%100 != 200): |
| 5010 | raise Exception(ret.data) |
| 5011 | |
| 5012 | return ret |
| 5013 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5014 | |
| 5015 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5016 | queryset = Account.objects.select_related().all() |
| 5017 | serializer_class = AccountSerializer |
| 5018 | id_serializer_class = AccountIdSerializer |
| 5019 | |
| 5020 | def get_serializer_class(self): |
| 5021 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5022 | if (no_hyperlinks): |
| 5023 | return self.id_serializer_class |
| 5024 | else: |
| 5025 | return self.serializer_class |
| 5026 | |
| 5027 | def get_queryset(self): |
| 5028 | return Account.select_by_user(self.request.user) |
| 5029 | |
| 5030 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5031 | |
| 5032 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5033 | |
| 5034 | |
| 5035 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5036 | class ControllerRoleList(generics.ListCreateAPIView): |
| 5037 | queryset = ControllerRole.objects.select_related().all() |
| 5038 | serializer_class = ControllerRoleSerializer |
| 5039 | id_serializer_class = ControllerRoleIdSerializer |
| 5040 | filter_backends = (filters.DjangoFilterBackend,) |
| 5041 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5042 | |
| 5043 | def get_serializer_class(self): |
| 5044 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5045 | if (no_hyperlinks): |
| 5046 | return self.id_serializer_class |
| 5047 | else: |
| 5048 | return self.serializer_class |
| 5049 | |
| 5050 | def get_queryset(self): |
| 5051 | return ControllerRole.select_by_user(self.request.user) |
| 5052 | |
| 5053 | def create(self, request, *args, **kwargs): |
| 5054 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5055 | if not (serializer.is_valid()): |
| 5056 | response = {"error": "validation", |
| 5057 | "specific_error": "not serializer.is_valid()",
|
| 5058 | "reasons": serializer.errors}
|
| 5059 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5060 | obj = serializer.object |
| 5061 | obj.caller = request.user |
| 5062 | if obj.can_update(request.user): |
| 5063 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5064 | else: |
| 5065 | raise Exception("failed obj.can_update") |
| 5066 | |
| 5067 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5068 | if (ret.status_code%100 != 200): |
| 5069 | raise Exception(ret.data) |
| 5070 | |
| 5071 | return ret |
| 5072 | |
| 5073 | |
| 5074 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5075 | queryset = ControllerRole.objects.select_related().all() |
| 5076 | serializer_class = ControllerRoleSerializer |
| 5077 | id_serializer_class = ControllerRoleIdSerializer |
| 5078 | |
| 5079 | def get_serializer_class(self): |
| 5080 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5081 | if (no_hyperlinks): |
| 5082 | return self.id_serializer_class |
| 5083 | else: |
| 5084 | return self.serializer_class |
| 5085 | |
| 5086 | def get_queryset(self): |
| 5087 | return ControllerRole.select_by_user(self.request.user) |
| 5088 | |
| 5089 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5090 | |
| 5091 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5092 | |
| 5093 | |
| 5094 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5095 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 5096 | queryset = NetworkParameterType.objects.select_related().all() |
| 5097 | serializer_class = NetworkParameterTypeSerializer |
| 5098 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5099 | filter_backends = (filters.DjangoFilterBackend,) |
| 5100 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 5101 | |
| 5102 | def get_serializer_class(self): |
| 5103 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5104 | if (no_hyperlinks): |
| 5105 | return self.id_serializer_class |
| 5106 | else: |
| 5107 | return self.serializer_class |
| 5108 | |
| 5109 | def get_queryset(self): |
| 5110 | return NetworkParameterType.select_by_user(self.request.user) |
| 5111 | |
| 5112 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5113 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5114 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5115 | response = {"error": "validation", |
| 5116 | "specific_error": "not serializer.is_valid()",
|
| 5117 | "reasons": serializer.errors}
|
| 5118 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5119 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5120 | obj.caller = request.user |
| 5121 | if obj.can_update(request.user): |
| 5122 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5123 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5124 | raise Exception("failed obj.can_update") |
| 5125 | |
| 5126 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5127 | if (ret.status_code%100 != 200): |
| 5128 | raise Exception(ret.data) |
| 5129 | |
| 5130 | return ret |
| 5131 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5132 | |
| 5133 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5134 | queryset = NetworkParameterType.objects.select_related().all() |
| 5135 | serializer_class = NetworkParameterTypeSerializer |
| 5136 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5137 | |
| 5138 | def get_serializer_class(self): |
| 5139 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5140 | if (no_hyperlinks): |
| 5141 | return self.id_serializer_class |
| 5142 | else: |
| 5143 | return self.serializer_class |
| 5144 | |
| 5145 | def get_queryset(self): |
| 5146 | return NetworkParameterType.select_by_user(self.request.user) |
| 5147 | |
| 5148 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5149 | |
| 5150 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5151 | |
| 5152 | |
| 5153 | |
| 5154 | class SiteCredentialList(generics.ListCreateAPIView): |
| 5155 | queryset = SiteCredential.objects.select_related().all() |
| 5156 | serializer_class = SiteCredentialSerializer |
| 5157 | id_serializer_class = SiteCredentialIdSerializer |
| 5158 | filter_backends = (filters.DjangoFilterBackend,) |
| 5159 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 5160 | |
| 5161 | def get_serializer_class(self): |
| 5162 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5163 | if (no_hyperlinks): |
| 5164 | return self.id_serializer_class |
| 5165 | else: |
| 5166 | return self.serializer_class |
| 5167 | |
| 5168 | def get_queryset(self): |
| 5169 | return SiteCredential.select_by_user(self.request.user) |
| 5170 | |
| 5171 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5172 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5173 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5174 | response = {"error": "validation", |
| 5175 | "specific_error": "not serializer.is_valid()",
|
| 5176 | "reasons": serializer.errors}
|
| 5177 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5178 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5179 | obj.caller = request.user |
| 5180 | if obj.can_update(request.user): |
| 5181 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5182 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5183 | raise Exception("failed obj.can_update") |
| 5184 | |
| 5185 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5186 | if (ret.status_code%100 != 200): |
| 5187 | raise Exception(ret.data) |
| 5188 | |
| 5189 | return ret |
| 5190 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5191 | |
| 5192 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5193 | queryset = SiteCredential.objects.select_related().all() |
| 5194 | serializer_class = SiteCredentialSerializer |
| 5195 | id_serializer_class = SiteCredentialIdSerializer |
| 5196 | |
| 5197 | def get_serializer_class(self): |
| 5198 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5199 | if (no_hyperlinks): |
| 5200 | return self.id_serializer_class |
| 5201 | else: |
| 5202 | return self.serializer_class |
| 5203 | |
| 5204 | def get_queryset(self): |
| 5205 | return SiteCredential.select_by_user(self.request.user) |
| 5206 | |
| 5207 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5208 | |
| 5209 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5210 | |
| 5211 | |
| 5212 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5213 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 5214 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5215 | serializer_class = DeploymentPrivilegeSerializer |
| 5216 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5217 | filter_backends = (filters.DjangoFilterBackend,) |
| 5218 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 5219 | |
| 5220 | def get_serializer_class(self): |
| 5221 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5222 | if (no_hyperlinks): |
| 5223 | return self.id_serializer_class |
| 5224 | else: |
| 5225 | return self.serializer_class |
| 5226 | |
| 5227 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5228 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5229 | |
| 5230 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5231 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5232 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5233 | response = {"error": "validation", |
| 5234 | "specific_error": "not serializer.is_valid()",
|
| 5235 | "reasons": serializer.errors}
|
| 5236 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5237 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5238 | obj.caller = request.user |
| 5239 | if obj.can_update(request.user): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5240 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5241 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5242 | raise Exception("failed obj.can_update") |
| 5243 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5244 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5245 | if (ret.status_code%100 != 200): |
| 5246 | raise Exception(ret.data) |
| 5247 | |
| 5248 | return ret |
| 5249 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5250 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5251 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5252 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5253 | serializer_class = DeploymentPrivilegeSerializer |
| 5254 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5255 | |
| 5256 | def get_serializer_class(self): |
| 5257 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5258 | if (no_hyperlinks): |
| 5259 | return self.id_serializer_class |
| 5260 | else: |
| 5261 | return self.serializer_class |
| 5262 | |
| 5263 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5264 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5265 | |
| 5266 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5267 | |
| 5268 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5269 | |
| 5270 | |
| 5271 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5272 | class ControllerUsersList(generics.ListCreateAPIView): |
| 5273 | queryset = ControllerUsers.objects.select_related().all() |
| 5274 | serializer_class = ControllerUsersSerializer |
| 5275 | id_serializer_class = ControllerUsersIdSerializer |
| 5276 | filter_backends = (filters.DjangoFilterBackend,) |
| 5277 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 5278 | |
| 5279 | def get_serializer_class(self): |
| 5280 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5281 | if (no_hyperlinks): |
| 5282 | return self.id_serializer_class |
| 5283 | else: |
| 5284 | return self.serializer_class |
| 5285 | |
| 5286 | def get_queryset(self): |
| 5287 | return ControllerUsers.select_by_user(self.request.user) |
| 5288 | |
| 5289 | def create(self, request, *args, **kwargs): |
| 5290 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5291 | if not (serializer.is_valid()): |
| 5292 | response = {"error": "validation", |
| 5293 | "specific_error": "not serializer.is_valid()",
|
| 5294 | "reasons": serializer.errors}
|
| 5295 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5296 | obj = serializer.object |
| 5297 | obj.caller = request.user |
| 5298 | if obj.can_update(request.user): |
| 5299 | return super(ControllerUsersList, self).create(request, *args, **kwargs) |
| 5300 | else: |
| 5301 | raise Exception("failed obj.can_update") |
| 5302 | |
| 5303 | ret = super(ControllerUsersList, self).create(request, *args, **kwargs) |
| 5304 | if (ret.status_code%100 != 200): |
| 5305 | raise Exception(ret.data) |
| 5306 | |
| 5307 | return ret |
| 5308 | |
| 5309 | |
| 5310 | class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5311 | queryset = ControllerUsers.objects.select_related().all() |
| 5312 | serializer_class = ControllerUsersSerializer |
| 5313 | id_serializer_class = ControllerUsersIdSerializer |
| 5314 | |
| 5315 | def get_serializer_class(self): |
| 5316 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5317 | if (no_hyperlinks): |
| 5318 | return self.id_serializer_class |
| 5319 | else: |
| 5320 | return self.serializer_class |
| 5321 | |
| 5322 | def get_queryset(self): |
| 5323 | return ControllerUsers.select_by_user(self.request.user) |
| 5324 | |
| 5325 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5326 | |
| 5327 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5328 | |
| 5329 | |
| 5330 | |
| 5331 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 5332 | queryset = DeploymentRole.objects.select_related().all() |
| 5333 | serializer_class = DeploymentRoleSerializer |
| 5334 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5335 | filter_backends = (filters.DjangoFilterBackend,) |
| 5336 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5337 | |
| 5338 | def get_serializer_class(self): |
| 5339 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5340 | if (no_hyperlinks): |
| 5341 | return self.id_serializer_class |
| 5342 | else: |
| 5343 | return self.serializer_class |
| 5344 | |
| 5345 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5346 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5347 | |
| 5348 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5349 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5350 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5351 | response = {"error": "validation", |
| 5352 | "specific_error": "not serializer.is_valid()",
|
| 5353 | "reasons": serializer.errors}
|
| 5354 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5355 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5356 | obj.caller = request.user |
| 5357 | if obj.can_update(request.user): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5358 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5359 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5360 | raise Exception("failed obj.can_update") |
| 5361 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5362 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5363 | if (ret.status_code%100 != 200): |
| 5364 | raise Exception(ret.data) |
| 5365 | |
| 5366 | return ret |
| 5367 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5368 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5369 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5370 | queryset = DeploymentRole.objects.select_related().all() |
| 5371 | serializer_class = DeploymentRoleSerializer |
| 5372 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5373 | |
| 5374 | def get_serializer_class(self): |
| 5375 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5376 | if (no_hyperlinks): |
| 5377 | return self.id_serializer_class |
| 5378 | else: |
| 5379 | return self.serializer_class |
| 5380 | |
| 5381 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5382 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5383 | |
| 5384 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5385 | |
| 5386 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5387 | |
| 5388 | |
| 5389 | |
| 5390 | class UserCredentialList(generics.ListCreateAPIView): |
| 5391 | queryset = UserCredential.objects.select_related().all() |
| 5392 | serializer_class = UserCredentialSerializer |
| 5393 | id_serializer_class = UserCredentialIdSerializer |
| 5394 | filter_backends = (filters.DjangoFilterBackend,) |
| 5395 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 5396 | |
| 5397 | def get_serializer_class(self): |
| 5398 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5399 | if (no_hyperlinks): |
| 5400 | return self.id_serializer_class |
| 5401 | else: |
| 5402 | return self.serializer_class |
| 5403 | |
| 5404 | def get_queryset(self): |
| 5405 | return UserCredential.select_by_user(self.request.user) |
| 5406 | |
| 5407 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5408 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5409 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5410 | response = {"error": "validation", |
| 5411 | "specific_error": "not serializer.is_valid()",
|
| 5412 | "reasons": serializer.errors}
|
| 5413 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5414 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5415 | obj.caller = request.user |
| 5416 | if obj.can_update(request.user): |
| 5417 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5418 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5419 | raise Exception("failed obj.can_update") |
| 5420 | |
| 5421 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5422 | if (ret.status_code%100 != 200): |
| 5423 | raise Exception(ret.data) |
| 5424 | |
| 5425 | return ret |
| 5426 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5427 | |
| 5428 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5429 | queryset = UserCredential.objects.select_related().all() |
| 5430 | serializer_class = UserCredentialSerializer |
| 5431 | id_serializer_class = UserCredentialIdSerializer |
| 5432 | |
| 5433 | def get_serializer_class(self): |
| 5434 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5435 | if (no_hyperlinks): |
| 5436 | return self.id_serializer_class |
| 5437 | else: |
| 5438 | return self.serializer_class |
| 5439 | |
| 5440 | def get_queryset(self): |
| 5441 | return UserCredential.select_by_user(self.request.user) |
| 5442 | |
| 5443 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5444 | |
| 5445 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5446 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5447 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5448 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5449 | class SiteDeploymentsList(generics.ListCreateAPIView): |
| 5450 | queryset = SiteDeployments.objects.select_related().all() |
| 5451 | serializer_class = SiteDeploymentsSerializer |
| 5452 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5453 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5454 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5455 | |
| 5456 | def get_serializer_class(self): |
| 5457 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5458 | if (no_hyperlinks): |
| 5459 | return self.id_serializer_class |
| 5460 | else: |
| 5461 | return self.serializer_class |
| 5462 | |
| 5463 | def get_queryset(self): |
| 5464 | return SiteDeployments.select_by_user(self.request.user) |
| 5465 | |
| 5466 | def create(self, request, *args, **kwargs): |
| 5467 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5468 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5469 | response = {"error": "validation", |
| 5470 | "specific_error": "not serializer.is_valid()",
|
| 5471 | "reasons": serializer.errors}
|
| 5472 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5473 | obj = serializer.object |
| 5474 | obj.caller = request.user |
| 5475 | if obj.can_update(request.user): |
| 5476 | return super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 5477 | else: |
| 5478 | raise Exception("failed obj.can_update") |
| 5479 | |
| 5480 | ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 5481 | if (ret.status_code%100 != 200): |
| 5482 | raise Exception(ret.data) |
| 5483 | |
| 5484 | return ret |
| 5485 | |
| 5486 | |
| 5487 | class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5488 | queryset = SiteDeployments.objects.select_related().all() |
| 5489 | serializer_class = SiteDeploymentsSerializer |
| 5490 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5491 | |
| 5492 | def get_serializer_class(self): |
| 5493 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5494 | if (no_hyperlinks): |
| 5495 | return self.id_serializer_class |
| 5496 | else: |
| 5497 | return self.serializer_class |
| 5498 | |
| 5499 | def get_queryset(self): |
| 5500 | return SiteDeployments.select_by_user(self.request.user) |
| 5501 | |
| 5502 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5503 | |
| 5504 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5505 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5506 | |
| 5507 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5508 | class SliceTagList(generics.ListCreateAPIView): |
| 5509 | queryset = SliceTag.objects.select_related().all() |
| 5510 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5511 | id_serializer_class = SliceTagIdSerializer |
| 5512 | filter_backends = (filters.DjangoFilterBackend,) |
| 5513 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 5514 | |
| 5515 | def get_serializer_class(self): |
| 5516 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5517 | if (no_hyperlinks): |
| 5518 | return self.id_serializer_class |
| 5519 | else: |
| 5520 | return self.serializer_class |
| 5521 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5522 | def get_queryset(self): |
| 5523 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5524 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5525 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5526 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5527 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5528 | response = {"error": "validation", |
| 5529 | "specific_error": "not serializer.is_valid()",
|
| 5530 | "reasons": serializer.errors}
|
| 5531 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5532 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5533 | obj.caller = request.user |
| 5534 | if obj.can_update(request.user): |
| 5535 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 5536 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5537 | raise Exception("failed obj.can_update") |
| 5538 | |
| 5539 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 5540 | if (ret.status_code%100 != 200): |
| 5541 | raise Exception(ret.data) |
| 5542 | |
| 5543 | return ret |
| 5544 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5545 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5546 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5547 | queryset = SliceTag.objects.select_related().all() |
| 5548 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5549 | id_serializer_class = SliceTagIdSerializer |
| 5550 | |
| 5551 | def get_serializer_class(self): |
| 5552 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5553 | if (no_hyperlinks): |
| 5554 | return self.id_serializer_class |
| 5555 | else: |
| 5556 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5557 | |
| 5558 | def get_queryset(self): |
| 5559 | return SliceTag.select_by_user(self.request.user) |
| 5560 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5561 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5562 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5563 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5564 | |
| 5565 | |
| 5566 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5567 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 5568 | queryset = NetworkTemplate.objects.select_related().all() |
| 5569 | serializer_class = NetworkTemplateSerializer |
| 5570 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5571 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 5572 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5573 | |
| 5574 | def get_serializer_class(self): |
| 5575 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5576 | if (no_hyperlinks): |
| 5577 | return self.id_serializer_class |
| 5578 | else: |
| 5579 | return self.serializer_class |
| 5580 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5581 | def get_queryset(self): |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5582 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5583 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5584 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5585 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5586 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5587 | response = {"error": "validation", |
| 5588 | "specific_error": "not serializer.is_valid()",
|
| 5589 | "reasons": serializer.errors}
|
| 5590 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5591 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5592 | obj.caller = request.user |
| 5593 | if obj.can_update(request.user): |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5594 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5595 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5596 | raise Exception("failed obj.can_update") |
| 5597 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5598 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5599 | if (ret.status_code%100 != 200): |
| 5600 | raise Exception(ret.data) |
| 5601 | |
| 5602 | return ret |
| 5603 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5604 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5605 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5606 | queryset = NetworkTemplate.objects.select_related().all() |
| 5607 | serializer_class = NetworkTemplateSerializer |
| 5608 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5609 | |
| 5610 | def get_serializer_class(self): |
| 5611 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5612 | if (no_hyperlinks): |
| 5613 | return self.id_serializer_class |
| 5614 | else: |
| 5615 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5616 | |
| 5617 | def get_queryset(self): |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5618 | return NetworkTemplate.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5619 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5620 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5621 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5622 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5623 | |
| 5624 | |
| 5625 | |
| 5626 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5627 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5628 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5629 | id_serializer_class = RouterIdSerializer |
| 5630 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5631 | 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] | 5632 | |
| 5633 | def get_serializer_class(self): |
| 5634 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5635 | if (no_hyperlinks): |
| 5636 | return self.id_serializer_class |
| 5637 | else: |
| 5638 | return self.serializer_class |
| 5639 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5640 | def get_queryset(self): |
| 5641 | return Router.select_by_user(self.request.user) |
| 5642 | |
| 5643 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5644 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5645 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5646 | response = {"error": "validation", |
| 5647 | "specific_error": "not serializer.is_valid()",
|
| 5648 | "reasons": serializer.errors}
|
| 5649 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5650 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5651 | obj.caller = request.user |
| 5652 | if obj.can_update(request.user): |
| 5653 | return super(RouterList, self).create(request, *args, **kwargs) |
| 5654 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5655 | raise Exception("failed obj.can_update") |
| 5656 | |
| 5657 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 5658 | if (ret.status_code%100 != 200): |
| 5659 | raise Exception(ret.data) |
| 5660 | |
| 5661 | return ret |
| 5662 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5663 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5664 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5665 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5666 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5667 | id_serializer_class = RouterIdSerializer |
| 5668 | |
| 5669 | def get_serializer_class(self): |
| 5670 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5671 | if (no_hyperlinks): |
| 5672 | return self.id_serializer_class |
| 5673 | else: |
| 5674 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5675 | |
| 5676 | def get_queryset(self): |
| 5677 | return Router.select_by_user(self.request.user) |
| 5678 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5679 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5680 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5681 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5682 | |
| 5683 | |
| 5684 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5685 | class ServiceResourceList(generics.ListCreateAPIView): |
| 5686 | queryset = ServiceResource.objects.select_related().all() |
| 5687 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5688 | id_serializer_class = ServiceResourceIdSerializer |
| 5689 | filter_backends = (filters.DjangoFilterBackend,) |
| 5690 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 5691 | |
| 5692 | def get_serializer_class(self): |
| 5693 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5694 | if (no_hyperlinks): |
| 5695 | return self.id_serializer_class |
| 5696 | else: |
| 5697 | return self.serializer_class |
| 5698 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5699 | def get_queryset(self): |
| 5700 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5701 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5702 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5703 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5704 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5705 | response = {"error": "validation", |
| 5706 | "specific_error": "not serializer.is_valid()",
|
| 5707 | "reasons": serializer.errors}
|
| 5708 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5709 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5710 | obj.caller = request.user |
| 5711 | if obj.can_update(request.user): |
| 5712 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5713 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5714 | raise Exception("failed obj.can_update") |
| 5715 | |
| 5716 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5717 | if (ret.status_code%100 != 200): |
| 5718 | raise Exception(ret.data) |
| 5719 | |
| 5720 | return ret |
| 5721 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5722 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5723 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5724 | queryset = ServiceResource.objects.select_related().all() |
| 5725 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5726 | id_serializer_class = ServiceResourceIdSerializer |
| 5727 | |
| 5728 | def get_serializer_class(self): |
| 5729 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5730 | if (no_hyperlinks): |
| 5731 | return self.id_serializer_class |
| 5732 | else: |
| 5733 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5734 | |
| 5735 | def get_queryset(self): |
| 5736 | return ServiceResource.select_by_user(self.request.user) |
| 5737 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5738 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5739 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5740 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5741 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5742 | |
| 5743 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5744 | class ControllerSlicesList(generics.ListCreateAPIView): |
| 5745 | queryset = ControllerSlices.objects.select_related().all() |
| 5746 | serializer_class = ControllerSlicesSerializer |
| 5747 | id_serializer_class = ControllerSlicesIdSerializer |
| 5748 | filter_backends = (filters.DjangoFilterBackend,) |
| 5749 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 5750 | |
| 5751 | def get_serializer_class(self): |
| 5752 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5753 | if (no_hyperlinks): |
| 5754 | return self.id_serializer_class |
| 5755 | else: |
| 5756 | return self.serializer_class |
| 5757 | |
| 5758 | def get_queryset(self): |
| 5759 | return ControllerSlices.select_by_user(self.request.user) |
| 5760 | |
| 5761 | def create(self, request, *args, **kwargs): |
| 5762 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5763 | if not (serializer.is_valid()): |
| 5764 | response = {"error": "validation", |
| 5765 | "specific_error": "not serializer.is_valid()",
|
| 5766 | "reasons": serializer.errors}
|
| 5767 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5768 | obj = serializer.object |
| 5769 | obj.caller = request.user |
| 5770 | if obj.can_update(request.user): |
| 5771 | return super(ControllerSlicesList, self).create(request, *args, **kwargs) |
| 5772 | else: |
| 5773 | raise Exception("failed obj.can_update") |
| 5774 | |
| 5775 | ret = super(ControllerSlicesList, self).create(request, *args, **kwargs) |
| 5776 | if (ret.status_code%100 != 200): |
| 5777 | raise Exception(ret.data) |
| 5778 | |
| 5779 | return ret |
| 5780 | |
| 5781 | |
| 5782 | class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5783 | queryset = ControllerSlices.objects.select_related().all() |
| 5784 | serializer_class = ControllerSlicesSerializer |
| 5785 | id_serializer_class = ControllerSlicesIdSerializer |
| 5786 | |
| 5787 | def get_serializer_class(self): |
| 5788 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5789 | if (no_hyperlinks): |
| 5790 | return self.id_serializer_class |
| 5791 | else: |
| 5792 | return self.serializer_class |
| 5793 | |
| 5794 | def get_queryset(self): |
| 5795 | return ControllerSlices.select_by_user(self.request.user) |
| 5796 | |
| 5797 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5798 | |
| 5799 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5800 | |
| 5801 | |
| 5802 | |