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 | |
| 71 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 72 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
| 73 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 74 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 75 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 76 | |
| 77 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 78 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 79 | |
| 80 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 81 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 82 | |
| 83 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 84 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 85 | |
| 86 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 87 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 88 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 89 | url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetworks-list'), |
| 90 | url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetworks-detail'), |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 91 | |
| 92 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 93 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 94 | |
| 95 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 96 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 97 | |
| 98 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 99 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 100 | |
| 101 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 102 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 103 | |
| 104 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 105 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 106 | |
| 107 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 108 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 109 | |
| 110 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 111 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 112 | |
| 113 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 114 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 115 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 116 | url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 117 | 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] | 118 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 119 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 120 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 121 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 122 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 123 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 124 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 125 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 126 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 127 | |
| 128 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 129 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 130 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 131 | url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'), |
| 132 | url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
| 133 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 134 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 135 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 136 | |
| 137 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 138 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 139 | |
| 140 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 141 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
| 142 | |
| 143 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 144 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 145 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 146 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 147 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 148 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 149 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 150 | 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] | 151 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 152 | url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'), |
| 153 | url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'), |
| 154 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 155 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 156 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 157 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 158 | url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 159 | url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
| 160 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 161 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 162 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 163 | |
| 164 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 165 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 166 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 167 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 168 | 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] | 169 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 170 | url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controllerusers-list'), |
| 171 | url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controllerusers-detail'), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 172 | |
| 173 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 174 | 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] | 175 | |
| 176 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 177 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 178 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 179 | url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployments-list'), |
| 180 | url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployments-detail'), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 181 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 182 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 183 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 184 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 185 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 186 | 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] | 187 | |
| 188 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 189 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 190 | |
| 191 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 192 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 193 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 194 | url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslices-list'), |
| 195 | url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslices-detail'), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 196 | |
Scott Baker | 55a2e29 | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 197 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 198 | |
| 199 | @api_view(['GET']) |
| 200 | def api_root(request, format=None): |
| 201 | return Response({ |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 202 | 'flavors': reverse('flavor-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 203 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 204 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 205 | 'images': reverse('image-list', request=request, format=format), |
| 206 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 207 | 'sites': reverse('site-list', request=request, format=format), |
| 208 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 209 | 'tags': reverse('tag-list', request=request, format=format), |
| 210 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 211 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 212 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 213 | 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 214 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 215 | 'projects': reverse('project-list', request=request, format=format), |
| 216 | 'slices': reverse('slice-list', request=request, format=format), |
| 217 | 'networks': reverse('network-list', request=request, format=format), |
| 218 | 'services': reverse('service-list', request=request, format=format), |
| 219 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 220 | 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 221 | 'charges': reverse('charge-list', request=request, format=format), |
| 222 | 'roles': reverse('role-list', request=request, format=format), |
| 223 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 224 | 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 225 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 226 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 227 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 228 | 'nodes': reverse('node-list', request=request, format=format), |
| 229 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 230 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 231 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 232 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 233 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 234 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 235 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 236 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 237 | 'users': reverse('user-list', request=request, format=format), |
| 238 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 239 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 240 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 241 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 242 | 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 243 | 'accounts': reverse('account-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 244 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 245 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 246 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 247 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 248 | 'controlleruserses': reverse('controllerusers-list', request=request, format=format), |
| 249 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 250 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 251 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 252 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 253 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 254 | 'routers': reverse('router-list', request=request, format=format), |
| 255 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 256 | 'controllersliceses': reverse('controllerslices-list', request=request, format=format), |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 257 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 258 | }) |
| 259 | |
| 260 | # Based on serializers.py |
| 261 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 262 | class XOSModelSerializer(serializers.ModelSerializer): |
| 263 | def save_object(self, obj, **kwargs): |
| 264 | |
| 265 | """ rest_framework can't deal with ManyToMany relations that have a |
| 266 | through table. In plstackapi, most of the through tables we have |
| 267 | use defaults or blank fields, so there's no reason why we shouldn't |
| 268 | be able to save these objects. |
| 269 | |
| 270 | So, let's strip out these m2m relations, and deal with them ourself. |
| 271 | """ |
| 272 | obj._complex_m2m_data={};
|
| 273 | if getattr(obj, '_m2m_data', None):
|
| 274 | for relatedObject in obj._meta.get_all_related_many_to_many_objects():
|
| 275 | if (relatedObject.field.rel.through._meta.auto_created):
|
| 276 | # These are non-trough ManyToMany relations and
|
| 277 | # can be updated just fine
|
| 278 | continue
|
| 279 | fieldName = relatedObject.get_accessor_name()
|
| 280 | if fieldName in obj._m2m_data.keys():
|
| 281 | obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
|
| 282 | del obj._m2m_data[fieldName]
|
| 283 |
|
| 284 | serializers.ModelSerializer.save_object(self, obj, **kwargs); |
| 285 | |
| 286 | for (accessor, stuff) in obj._complex_m2m_data.items(): |
| 287 | (relatedObject, data) = stuff |
| 288 | through = relatedObject.field.rel.through |
| 289 | local_fieldName = relatedObject.field.m2m_reverse_field_name() |
| 290 | remote_fieldName = relatedObject.field.m2m_field_name() |
| 291 | |
| 292 | # get the current set of existing relations |
| 293 | existing = through.objects.filter(**{local_fieldName: obj}); |
| 294 | |
| 295 | data_ids = [item.id for item in data] |
| 296 | existing_ids = [getattr(item,remote_fieldName).id for item in existing] |
| 297 | |
| 298 | #print "data_ids", data_ids |
| 299 | #print "existing_ids", existing_ids |
| 300 | |
| 301 | # remove relations that are in 'existing' but not in 'data' |
| 302 | for item in list(existing): |
| 303 | if (getattr(item,remote_fieldName).id not in data_ids): |
| 304 | print "delete", getattr(item,remote_fieldName) |
| 305 | item.delete() #(purge=True) |
| 306 | |
| 307 | # add relations that are in 'data' but not in 'existing' |
| 308 | for item in data: |
| 309 | if (item.id not in existing_ids): |
| 310 | #print "add", item |
| 311 | newModel = through(**{local_fieldName: obj, remote_fieldName: item}) |
| 312 | newModel.save() |
| 313 | |
| 314 | |
| 315 | |
| 316 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 317 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 318 | |
| 319 | |
| 320 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 321 | |
| 322 | |
| 323 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 324 | validators = serializers.SerializerMethodField("getValidators") |
| 325 | def getHumanReadableName(self, obj):
|
| 326 | return str(obj) |
| 327 | def getValidators(self, obj): |
| 328 | try: |
| 329 | return obj.getValidators() |
| 330 | except: |
| 331 | return None |
| 332 | class Meta: |
| 333 | model = Flavor |
| 334 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 335 | |
| 336 | class FlavorIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 337 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 338 | |
| 339 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 340 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 341 | |
| 342 | |
| 343 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 344 | validators = serializers.SerializerMethodField("getValidators") |
| 345 | def getHumanReadableName(self, obj):
|
| 346 | return str(obj)
|
| 347 | def getValidators(self, obj):
|
| 348 | try: |
| 349 | return obj.getValidators() |
| 350 | except: |
| 351 | return None
|
| 352 | class Meta:
|
| 353 | model = Flavor |
| 354 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 355 | |
| 356 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 357 | |
| 358 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 359 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 360 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 361 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 362 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 363 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 364 | def getHumanReadableName(self, obj):
|
| 365 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 366 | def getValidators(self, obj): |
| 367 | try: |
| 368 | return obj.getValidators() |
| 369 | except: |
| 370 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 371 | class Meta: |
| 372 | model = ServiceAttribute |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 373 | 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] | 374 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 375 | class ServiceAttributeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 376 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 377 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 378 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 379 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 380 | def getHumanReadableName(self, obj):
|
| 381 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 382 | def getValidators(self, obj):
|
| 383 | try: |
| 384 | return obj.getValidators() |
| 385 | except: |
| 386 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 387 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 388 | model = ServiceAttribute |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 389 | 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] | 390 | |
| 391 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 392 | |
| 393 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 394 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 395 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 396 | |
| 397 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 398 | validators = serializers.SerializerMethodField("getValidators") |
| 399 | def getHumanReadableName(self, obj):
|
| 400 | return str(obj) |
| 401 | def getValidators(self, obj): |
| 402 | try: |
| 403 | return obj.getValidators() |
| 404 | except: |
| 405 | return None |
| 406 | class Meta: |
| 407 | model = ControllerImages |
| 408 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 409 | |
| 410 | class ControllerImagesIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 411 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 412 | |
| 413 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 414 | validators = serializers.SerializerMethodField("getValidators") |
| 415 | def getHumanReadableName(self, obj):
|
| 416 | return str(obj)
|
| 417 | def getValidators(self, obj):
|
| 418 | try: |
| 419 | return obj.getValidators() |
| 420 | except: |
| 421 | return None
|
| 422 | class Meta:
|
| 423 | model = ControllerImages |
| 424 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 429 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 430 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 431 | |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 432 | |
| 433 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 434 | |
| 435 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 436 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 437 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 438 | def getHumanReadableName(self, obj):
|
| 439 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 440 | def getValidators(self, obj): |
| 441 | try: |
| 442 | return obj.getValidators() |
| 443 | except: |
| 444 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 445 | class Meta: |
| 446 | model = Image |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 447 | 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] | 448 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 449 | class ImageIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 450 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 451 | |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 452 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 453 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 454 | |
| 455 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 456 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 457 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 458 | def getHumanReadableName(self, obj):
|
| 459 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 460 | def getValidators(self, obj):
|
| 461 | try: |
| 462 | return obj.getValidators() |
| 463 | except: |
| 464 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 465 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 466 | model = Image |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 467 | 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] | 468 | |
| 469 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 470 | |
| 471 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 472 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 473 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 474 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 475 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 476 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 477 | def getHumanReadableName(self, obj):
|
| 478 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 479 | def getValidators(self, obj): |
| 480 | try: |
| 481 | return obj.getValidators() |
| 482 | except: |
| 483 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 484 | class Meta: |
| 485 | model = NetworkParameter |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 486 | 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] | 487 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 488 | class NetworkParameterIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 489 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 490 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 491 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 492 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 493 | def getHumanReadableName(self, obj):
|
| 494 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 495 | def getValidators(self, obj):
|
| 496 | try: |
| 497 | return obj.getValidators() |
| 498 | except: |
| 499 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 500 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 501 | model = NetworkParameter |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 502 | 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] | 503 | |
| 504 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 505 | |
| 506 | |
| 507 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 508 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 509 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 510 | |
| 511 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 512 | |
| 513 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 514 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 515 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 516 | def getHumanReadableName(self, obj):
|
| 517 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 518 | def getValidators(self, obj): |
| 519 | try: |
| 520 | return obj.getValidators() |
| 521 | except: |
| 522 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 523 | class Meta: |
| 524 | model = Site |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 525 | 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] | 526 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 527 | class SiteIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 528 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 529 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 530 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 531 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 532 | |
| 533 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 534 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 535 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 536 | def getHumanReadableName(self, obj):
|
| 537 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 538 | def getValidators(self, obj):
|
| 539 | try: |
| 540 | return obj.getValidators() |
| 541 | except: |
| 542 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 543 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 544 | model = Site |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 545 | 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] | 546 | |
| 547 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 548 | |
| 549 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 550 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 551 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 552 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 553 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 554 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 555 | def getHumanReadableName(self, obj):
|
| 556 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 557 | def getValidators(self, obj): |
| 558 | try: |
| 559 | return obj.getValidators() |
| 560 | except: |
| 561 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 562 | class Meta: |
| 563 | model = SliceRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 564 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 565 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 566 | class SliceRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 567 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 568 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 569 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 570 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 571 | def getHumanReadableName(self, obj):
|
| 572 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 573 | def getValidators(self, obj):
|
| 574 | try: |
| 575 | return obj.getValidators() |
| 576 | except: |
| 577 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 578 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 579 | model = SliceRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 580 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 581 | |
| 582 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 583 | |
| 584 | |
| 585 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 586 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 587 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 588 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 589 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 590 | def getHumanReadableName(self, obj):
|
| 591 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 592 | def getValidators(self, obj): |
| 593 | try: |
| 594 | return obj.getValidators() |
| 595 | except: |
| 596 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 597 | class Meta: |
| 598 | model = Tag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 599 | 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] | 600 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 601 | class TagIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 602 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 603 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 604 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 605 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 606 | def getHumanReadableName(self, obj):
|
| 607 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 608 | def getValidators(self, obj):
|
| 609 | try: |
| 610 | return obj.getValidators() |
| 611 | except: |
| 612 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 613 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 614 | model = Tag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 615 | 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] | 616 | |
| 617 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 618 | |
| 619 | |
| 620 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 621 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 622 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 623 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 624 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 625 | def getHumanReadableName(self, obj):
|
| 626 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 627 | def getValidators(self, obj): |
| 628 | try: |
| 629 | return obj.getValidators() |
| 630 | except: |
| 631 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 632 | class Meta: |
| 633 | model = Invoice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 634 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 635 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 636 | class InvoiceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 637 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 638 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 639 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 640 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 641 | def getHumanReadableName(self, obj):
|
| 642 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 643 | def getValidators(self, obj):
|
| 644 | try: |
| 645 | return obj.getValidators() |
| 646 | except: |
| 647 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 648 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 649 | model = Invoice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 650 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 651 | |
| 652 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 653 | |
| 654 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 655 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 656 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 657 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 658 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 659 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 660 | def getHumanReadableName(self, obj):
|
| 661 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 662 | def getValidators(self, obj): |
| 663 | try: |
| 664 | return obj.getValidators() |
| 665 | except: |
| 666 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 667 | class Meta: |
| 668 | model = SlicePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 669 | 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] | 670 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 671 | class SlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 672 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 673 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 674 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 675 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 676 | def getHumanReadableName(self, obj):
|
| 677 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 678 | def getValidators(self, obj):
|
| 679 | try: |
| 680 | return obj.getValidators() |
| 681 | except: |
| 682 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 683 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 684 | model = SlicePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 685 | 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] | 686 | |
| 687 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 688 | |
| 689 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 690 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 691 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 692 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 693 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 694 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 695 | def getHumanReadableName(self, obj):
|
| 696 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 697 | def getValidators(self, obj): |
| 698 | try: |
| 699 | return obj.getValidators() |
| 700 | except: |
| 701 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 702 | class Meta: |
| 703 | model = PlanetStackRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 704 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 705 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 706 | class PlanetStackRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 707 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 708 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 709 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 710 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 711 | def getHumanReadableName(self, obj):
|
| 712 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 713 | def getValidators(self, obj):
|
| 714 | try: |
| 715 | return obj.getValidators() |
| 716 | except: |
| 717 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 718 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 719 | model = PlanetStackRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 720 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 721 | |
| 722 | |
| 723 | |
| 724 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 725 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 726 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 727 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 728 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 729 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 730 | def getHumanReadableName(self, obj):
|
| 731 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 732 | def getValidators(self, obj): |
| 733 | try: |
| 734 | return obj.getValidators() |
| 735 | except: |
| 736 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 737 | class Meta: |
| 738 | model = NetworkSliver |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 739 | 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] | 740 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 741 | class NetworkSliverIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 742 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 743 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 744 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 745 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 746 | def getHumanReadableName(self, obj):
|
| 747 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 748 | def getValidators(self, obj):
|
| 749 | try: |
| 750 | return obj.getValidators() |
| 751 | except: |
| 752 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 753 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 754 | model = NetworkSliver |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 755 | 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] | 756 | |
| 757 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 758 | |
| 759 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 760 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 761 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 762 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 763 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 764 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 765 | def getHumanReadableName(self, obj):
|
| 766 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 767 | def getValidators(self, obj): |
| 768 | try: |
| 769 | return obj.getValidators() |
| 770 | except: |
| 771 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 772 | class Meta: |
| 773 | model = Project |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 774 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 775 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 776 | class ProjectIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 777 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 778 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 779 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 780 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 781 | def getHumanReadableName(self, obj):
|
| 782 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 783 | def getValidators(self, obj):
|
| 784 | try: |
| 785 | return obj.getValidators() |
| 786 | except: |
| 787 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 788 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 789 | model = Project |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 790 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 791 | |
| 792 | |
| 793 | |
| 794 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 795 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 796 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 797 | |
| 798 | |
| 799 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 800 | |
| 801 | |
| 802 | |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 803 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 804 | |
| 805 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 806 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 807 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 808 | def getHumanReadableName(self, obj):
|
| 809 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 810 | def getValidators(self, obj): |
| 811 | try: |
| 812 | return obj.getValidators() |
| 813 | except: |
| 814 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 815 | class Meta: |
| 816 | model = Slice |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 817 | 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] | 818 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 819 | class SliceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 820 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 821 | |
| 822 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 823 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 824 | |
| 825 | |
| 826 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 827 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 828 | |
| 829 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 830 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 831 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 832 | def getHumanReadableName(self, obj):
|
| 833 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 834 | def getValidators(self, obj):
|
| 835 | try: |
| 836 | return obj.getValidators() |
| 837 | except: |
| 838 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 839 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 840 | model = Slice |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 841 | 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] | 842 | |
| 843 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 844 | |
| 845 | |
| 846 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 847 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 848 | |
| 849 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 850 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 851 | |
| 852 | |
| 853 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 854 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 855 | |
| 856 | |
| 857 | |
| 858 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 859 | |
| 860 | |
| 861 | |
| 862 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 863 | |
| 864 | |
| 865 | |
| 866 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 867 | |
| 868 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 869 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 870 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 871 | def getHumanReadableName(self, obj):
|
| 872 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 873 | def getValidators(self, obj): |
| 874 | try: |
| 875 | return obj.getValidators() |
| 876 | except: |
| 877 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 878 | class Meta: |
| 879 | model = Network |
Scott Baker | 95bdf0a | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 880 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 881 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 882 | class NetworkIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 883 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 884 | |
| 885 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 886 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 887 | |
| 888 | |
| 889 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 890 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 891 | |
| 892 | |
| 893 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 894 | slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 895 | |
| 896 | |
| 897 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 898 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 899 | |
| 900 | |
| 901 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 902 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 903 | |
| 904 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 905 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 906 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 907 | def getHumanReadableName(self, obj):
|
| 908 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 909 | def getValidators(self, obj):
|
| 910 | try: |
| 911 | return obj.getValidators() |
| 912 | except: |
| 913 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 914 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 915 | model = Network |
Scott Baker | 95bdf0a | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 916 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 917 | |
| 918 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 919 | |
| 920 | |
| 921 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 922 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 923 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 924 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 925 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 926 | def getHumanReadableName(self, obj):
|
| 927 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 928 | def getValidators(self, obj): |
| 929 | try: |
| 930 | return obj.getValidators() |
| 931 | except: |
| 932 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 933 | class Meta: |
| 934 | model = Service |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 935 | 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] | 936 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 937 | class ServiceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 938 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 939 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 940 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 941 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 942 | def getHumanReadableName(self, obj):
|
| 943 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 944 | def getValidators(self, obj):
|
| 945 | try: |
| 946 | return obj.getValidators() |
| 947 | except: |
| 948 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 949 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 950 | model = Service |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 951 | 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] | 952 | |
| 953 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 954 | |
| 955 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 956 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 957 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 958 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 959 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 960 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 961 | def getHumanReadableName(self, obj):
|
| 962 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 963 | def getValidators(self, obj): |
| 964 | try: |
| 965 | return obj.getValidators() |
| 966 | except: |
| 967 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 968 | class Meta: |
| 969 | model = ServiceClass |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 970 | 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] | 971 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 972 | class ServiceClassIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 973 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 974 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 975 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 976 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 977 | def getHumanReadableName(self, obj):
|
| 978 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 979 | def getValidators(self, obj):
|
| 980 | try: |
| 981 | return obj.getValidators() |
| 982 | except: |
| 983 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 984 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 985 | model = ServiceClass |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 986 | 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] | 987 | |
| 988 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 989 | |
| 990 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 991 | class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 992 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 993 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 994 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 995 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 996 | def getHumanReadableName(self, obj):
|
| 997 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 998 | def getValidators(self, obj): |
| 999 | try: |
| 1000 | return obj.getValidators() |
| 1001 | except: |
| 1002 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1003 | class Meta: |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1004 | model = ControllerNetwork |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1005 | 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] | 1006 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1007 | class ControllerNetworkIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1008 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1009 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1010 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1011 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1012 | def getHumanReadableName(self, obj):
|
| 1013 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1014 | def getValidators(self, obj):
|
| 1015 | try: |
| 1016 | return obj.getValidators() |
| 1017 | except: |
| 1018 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1019 | class Meta:
|
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1020 | model = ControllerNetwork |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1021 | 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] | 1022 | |
| 1023 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1024 | |
| 1025 | |
| 1026 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1027 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1028 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1029 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1030 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1031 | def getHumanReadableName(self, obj):
|
| 1032 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1033 | def getValidators(self, obj): |
| 1034 | try: |
| 1035 | return obj.getValidators() |
| 1036 | except: |
| 1037 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1038 | class Meta: |
| 1039 | model = Charge |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1040 | 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] | 1041 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1042 | class ChargeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1043 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1044 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1045 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1046 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1047 | def getHumanReadableName(self, obj):
|
| 1048 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1049 | def getValidators(self, obj):
|
| 1050 | try: |
| 1051 | return obj.getValidators() |
| 1052 | except: |
| 1053 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1054 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1055 | model = Charge |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1056 | 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] | 1057 | |
| 1058 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1059 | |
| 1060 | |
| 1061 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1062 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1063 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1064 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1065 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1066 | def getHumanReadableName(self, obj):
|
| 1067 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1068 | def getValidators(self, obj): |
| 1069 | try: |
| 1070 | return obj.getValidators() |
| 1071 | except: |
| 1072 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1073 | class Meta: |
| 1074 | model = Role |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1075 | 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] | 1076 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1077 | class RoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1078 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1079 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1080 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1081 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1082 | def getHumanReadableName(self, obj):
|
| 1083 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1084 | def getValidators(self, obj):
|
| 1085 | try: |
| 1086 | return obj.getValidators() |
| 1087 | except: |
| 1088 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1089 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1090 | model = Role |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1091 | 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] | 1092 | |
| 1093 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1094 | |
| 1095 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1096 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1097 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1098 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1099 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1100 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1101 | def getHumanReadableName(self, obj):
|
| 1102 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1103 | def getValidators(self, obj): |
| 1104 | try: |
| 1105 | return obj.getValidators() |
| 1106 | except: |
| 1107 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1108 | class Meta: |
| 1109 | model = UsableObject |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1110 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1111 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1112 | class UsableObjectIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1113 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1114 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1115 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1116 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1117 | def getHumanReadableName(self, obj):
|
| 1118 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1119 | def getValidators(self, obj):
|
| 1120 | try: |
| 1121 | return obj.getValidators() |
| 1122 | except: |
| 1123 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1124 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1125 | model = UsableObject |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1126 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1127 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1128 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1129 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1130 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1131 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1132 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1133 | def getHumanReadableName(self, obj):
|
| 1134 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1135 | def getValidators(self, obj): |
| 1136 | try: |
| 1137 | return obj.getValidators() |
| 1138 | except: |
| 1139 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1140 | class Meta: |
| 1141 | model = SiteRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1142 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1143 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1144 | class SiteRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1145 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1146 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1147 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1148 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1149 | def getHumanReadableName(self, obj):
|
| 1150 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1151 | def getValidators(self, obj):
|
| 1152 | try: |
| 1153 | return obj.getValidators() |
| 1154 | except: |
| 1155 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1156 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1157 | model = SiteRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1158 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1159 | |
| 1160 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1161 | |
| 1162 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1163 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1164 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1165 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1166 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1167 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1168 | def getHumanReadableName(self, obj):
|
| 1169 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1170 | def getValidators(self, obj): |
| 1171 | try: |
| 1172 | return obj.getValidators() |
| 1173 | except: |
| 1174 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1175 | class Meta: |
| 1176 | model = SliceCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1177 | 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] | 1178 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1179 | class SliceCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1180 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1181 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1182 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1183 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1184 | def getHumanReadableName(self, obj):
|
| 1185 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1186 | def getValidators(self, obj):
|
| 1187 | try: |
| 1188 | return obj.getValidators() |
| 1189 | except: |
| 1190 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1191 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1192 | model = SliceCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1193 | 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] | 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1198 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1199 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1200 | |
| 1201 | |
| 1202 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1203 | |
| 1204 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1205 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1206 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1207 | def getHumanReadableName(self, obj):
|
| 1208 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1209 | def getValidators(self, obj): |
| 1210 | try: |
| 1211 | return obj.getValidators() |
| 1212 | except: |
| 1213 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1214 | class Meta: |
| 1215 | model = Sliver |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 1216 | 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] | 1217 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1218 | class SliverIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1219 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1220 | |
| 1221 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1222 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1223 | |
| 1224 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1225 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1226 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1227 | def getHumanReadableName(self, obj):
|
| 1228 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1229 | def getValidators(self, obj):
|
| 1230 | try: |
| 1231 | return obj.getValidators() |
| 1232 | except: |
| 1233 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1234 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1235 | model = Sliver |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 1236 | 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] | 1237 | |
| 1238 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1239 | |
| 1240 | |
| 1241 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1242 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1243 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1244 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1245 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1246 | def getHumanReadableName(self, obj):
|
| 1247 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1248 | def getValidators(self, obj): |
| 1249 | try: |
| 1250 | return obj.getValidators() |
| 1251 | except: |
| 1252 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1253 | class Meta: |
| 1254 | model = Node |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1255 | 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] | 1256 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1257 | class NodeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1258 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1259 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1260 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1261 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1262 | def getHumanReadableName(self, obj):
|
| 1263 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1264 | def getValidators(self, obj):
|
| 1265 | try: |
| 1266 | return obj.getValidators() |
| 1267 | except: |
| 1268 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1269 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1270 | model = Node |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1271 | 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] | 1272 | |
| 1273 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1274 | |
| 1275 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1276 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1277 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1278 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1279 | |
| 1280 | controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail') |
| 1281 | |
| 1282 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1283 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1284 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1285 | def getHumanReadableName(self, obj):
|
| 1286 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1287 | def getValidators(self, obj): |
| 1288 | try: |
| 1289 | return obj.getValidators() |
| 1290 | except: |
| 1291 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1292 | class Meta: |
| 1293 | model = DashboardView |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1294 | 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] | 1295 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1296 | class DashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1297 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1298 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1299 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1300 | controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1301 | |
| 1302 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1303 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1304 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1305 | def getHumanReadableName(self, obj):
|
| 1306 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1307 | def getValidators(self, obj):
|
| 1308 | try: |
| 1309 | return obj.getValidators() |
| 1310 | except: |
| 1311 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1312 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1313 | model = DashboardView |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1314 | 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] | 1315 | |
| 1316 | |
| 1317 | |
| 1318 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1319 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1320 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1321 | |
| 1322 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1323 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1324 | def getHumanReadableName(self, obj):
|
| 1325 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1326 | def getValidators(self, obj): |
| 1327 | try: |
| 1328 | return obj.getValidators() |
| 1329 | except: |
| 1330 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1331 | class Meta: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1332 | model = ImageDeployments |
| 1333 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1334 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1335 | class ImageDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1336 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1337 | |
| 1338 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1339 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1340 | def getHumanReadableName(self, obj):
|
| 1341 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1342 | def getValidators(self, obj):
|
| 1343 | try: |
| 1344 | return obj.getValidators() |
| 1345 | except: |
| 1346 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1347 | class Meta:
|
| 1348 | model = ImageDeployments |
| 1349 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1350 | |
| 1351 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1352 | |
| 1353 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1354 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1355 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1356 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1357 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1358 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1359 | def getHumanReadableName(self, obj):
|
| 1360 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1361 | def getValidators(self, obj): |
| 1362 | try: |
| 1363 | return obj.getValidators() |
| 1364 | except: |
| 1365 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1366 | class Meta: |
| 1367 | model = ReservedResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1368 | 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] | 1369 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1370 | class ReservedResourceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1371 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1372 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1373 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1374 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1375 | def getHumanReadableName(self, obj):
|
| 1376 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1377 | def getValidators(self, obj):
|
| 1378 | try: |
| 1379 | return obj.getValidators() |
| 1380 | except: |
| 1381 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1382 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1383 | model = ReservedResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1384 | 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] | 1385 | |
| 1386 | |
| 1387 | |
| 1388 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1389 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1390 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1391 | |
| 1392 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1393 | validators = serializers.SerializerMethodField("getValidators") |
| 1394 | def getHumanReadableName(self, obj):
|
| 1395 | return str(obj) |
| 1396 | def getValidators(self, obj): |
| 1397 | try: |
| 1398 | return obj.getValidators() |
| 1399 | except: |
| 1400 | return None |
| 1401 | class Meta: |
| 1402 | model = Payment |
| 1403 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1404 | |
| 1405 | class PaymentIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1406 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1407 | |
| 1408 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1409 | validators = serializers.SerializerMethodField("getValidators") |
| 1410 | def getHumanReadableName(self, obj):
|
| 1411 | return str(obj)
|
| 1412 | def getValidators(self, obj):
|
| 1413 | try: |
| 1414 | return obj.getValidators() |
| 1415 | except: |
| 1416 | return None
|
| 1417 | class Meta:
|
| 1418 | model = Payment |
| 1419 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1420 | |
| 1421 | |
| 1422 | |
| 1423 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1424 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1425 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1426 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1427 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1428 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1429 | def getHumanReadableName(self, obj):
|
| 1430 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1431 | def getValidators(self, obj): |
| 1432 | try: |
| 1433 | return obj.getValidators() |
| 1434 | except: |
| 1435 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1436 | class Meta: |
| 1437 | model = NetworkSlice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1438 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1439 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1440 | class NetworkSliceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1441 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1442 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1443 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1444 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1445 | def getHumanReadableName(self, obj):
|
| 1446 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1447 | def getValidators(self, obj):
|
| 1448 | try: |
| 1449 | return obj.getValidators() |
| 1450 | except: |
| 1451 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1452 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1453 | model = NetworkSlice |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1454 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1455 | |
| 1456 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1457 | |
| 1458 | |
| 1459 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1460 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1461 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1462 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1463 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1464 | def getHumanReadableName(self, obj):
|
| 1465 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1466 | def getValidators(self, obj): |
| 1467 | try: |
| 1468 | return obj.getValidators() |
| 1469 | except: |
| 1470 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1471 | class Meta: |
| 1472 | model = UserDashboardView |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1473 | 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] | 1474 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1475 | class UserDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1476 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1477 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1478 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1479 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1480 | def getHumanReadableName(self, obj):
|
| 1481 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1482 | def getValidators(self, obj):
|
| 1483 | try: |
| 1484 | return obj.getValidators() |
| 1485 | except: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1486 | return None
|
| 1487 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1488 | model = UserDashboardView |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1489 | 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] | 1490 | |
| 1491 | |
| 1492 | |
| 1493 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1494 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1495 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1496 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1497 | |
| 1498 | dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail') |
| 1499 | |
| 1500 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1501 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1502 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1503 | def getHumanReadableName(self, obj):
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1504 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1505 | def getValidators(self, obj): |
| 1506 | try: |
| 1507 | return obj.getValidators() |
| 1508 | except: |
| 1509 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1510 | class Meta: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1511 | model = Controller |
| 1512 | 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] | 1513 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1514 | class ControllerIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1515 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1516 | |
| 1517 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1518 | dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all()) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1519 | |
| 1520 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1521 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1522 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1523 | def getHumanReadableName(self, obj):
|
| 1524 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1525 | def getValidators(self, obj):
|
| 1526 | try: |
| 1527 | return obj.getValidators() |
| 1528 | except: |
| 1529 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1530 | class Meta:
|
| 1531 | model = Controller |
| 1532 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 1533 | |
| 1534 | |
| 1535 | |
| 1536 | |
| 1537 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1538 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1539 | |
| 1540 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1541 | validators = serializers.SerializerMethodField("getValidators") |
| 1542 | def getHumanReadableName(self, obj):
|
| 1543 | return str(obj) |
| 1544 | def getValidators(self, obj): |
| 1545 | try: |
| 1546 | return obj.getValidators() |
| 1547 | except: |
| 1548 | return None |
| 1549 | class Meta: |
| 1550 | model = PlanetStackPrivilege |
| 1551 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1552 | |
| 1553 | class PlanetStackPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1554 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1555 | |
| 1556 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1557 | validators = serializers.SerializerMethodField("getValidators") |
| 1558 | def getHumanReadableName(self, obj):
|
| 1559 | return str(obj)
|
| 1560 | def getValidators(self, obj):
|
| 1561 | try: |
| 1562 | return obj.getValidators() |
| 1563 | except: |
| 1564 | return None
|
| 1565 | class Meta:
|
| 1566 | model = PlanetStackPrivilege |
| 1567 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1568 | |
| 1569 | |
| 1570 | |
| 1571 | |
| 1572 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1573 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1574 | |
| 1575 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1576 | validators = serializers.SerializerMethodField("getValidators") |
| 1577 | def getHumanReadableName(self, obj):
|
| 1578 | return str(obj) |
| 1579 | def getValidators(self, obj): |
| 1580 | try: |
| 1581 | return obj.getValidators() |
| 1582 | except: |
| 1583 | return None |
| 1584 | class Meta: |
| 1585 | model = User |
| 1586 | 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',) |
| 1587 | |
| 1588 | class UserIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1589 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1590 | |
| 1591 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1592 | validators = serializers.SerializerMethodField("getValidators") |
| 1593 | def getHumanReadableName(self, obj):
|
| 1594 | return str(obj)
|
| 1595 | def getValidators(self, obj):
|
| 1596 | try: |
| 1597 | return obj.getValidators() |
| 1598 | except: |
| 1599 | return None
|
| 1600 | class Meta:
|
| 1601 | model = User |
| 1602 | 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',) |
| 1603 | |
| 1604 | |
| 1605 | |
| 1606 | |
| 1607 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1608 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1609 | |
| 1610 | |
| 1611 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1612 | |
| 1613 | |
| 1614 | |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1615 | images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail') |
| 1616 | |
| 1617 | |
| 1618 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1619 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1620 | |
| 1621 | |
| 1622 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1623 | validators = serializers.SerializerMethodField("getValidators") |
| 1624 | def getHumanReadableName(self, obj):
|
| 1625 | return str(obj) |
| 1626 | def getValidators(self, obj): |
| 1627 | try: |
| 1628 | return obj.getValidators() |
| 1629 | except: |
| 1630 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1631 | class Meta: |
| 1632 | model = Deployment |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1633 | 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] | 1634 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1635 | class DeploymentIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1636 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1637 | |
| 1638 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1639 | flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1640 | |
| 1641 | |
| 1642 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1643 | images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all()) |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1644 | |
| 1645 | |
| 1646 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1647 | sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1648 | |
| 1649 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1650 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1651 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1652 | def getHumanReadableName(self, obj):
|
| 1653 | return str(obj)
|
| 1654 | def getValidators(self, obj):
|
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1655 | try: |
| 1656 | return obj.getValidators() |
| 1657 | except: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1658 | return None
|
| 1659 | class Meta:
|
| 1660 | model = Deployment |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1661 | 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] | 1662 | |
| 1663 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1664 | |
| 1665 | |
| 1666 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1667 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1668 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1669 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1670 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1671 | def getHumanReadableName(self, obj):
|
| 1672 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1673 | def getValidators(self, obj): |
| 1674 | try: |
| 1675 | return obj.getValidators() |
| 1676 | except: |
| 1677 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1678 | class Meta: |
| 1679 | model = Reservation |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1680 | 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] | 1681 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1682 | class ReservationIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1683 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1684 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1685 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1686 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1687 | def getHumanReadableName(self, obj):
|
| 1688 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1689 | def getValidators(self, obj):
|
| 1690 | try: |
| 1691 | return obj.getValidators() |
| 1692 | except: |
| 1693 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1694 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1695 | model = Reservation |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1696 | 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] | 1697 | |
| 1698 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1699 | |
| 1700 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1701 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1702 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1703 | |
| 1704 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1705 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1706 | def getHumanReadableName(self, obj):
|
| 1707 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1708 | def getValidators(self, obj): |
| 1709 | try: |
| 1710 | return obj.getValidators() |
| 1711 | except: |
| 1712 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1713 | class Meta: |
| 1714 | model = SitePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1715 | 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] | 1716 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1717 | class SitePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1718 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1719 | |
| 1720 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1721 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1722 | def getHumanReadableName(self, obj):
|
| 1723 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1724 | def getValidators(self, obj):
|
| 1725 | try: |
| 1726 | return obj.getValidators() |
| 1727 | except: |
| 1728 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1729 | class Meta:
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1730 | model = SitePrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1731 | 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] | 1732 | |
| 1733 | |
| 1734 | |
| 1735 | |
| 1736 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1737 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1738 | |
| 1739 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1740 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1741 | def getHumanReadableName(self, obj):
|
| 1742 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1743 | def getValidators(self, obj): |
| 1744 | try: |
| 1745 | return obj.getValidators() |
| 1746 | except: |
| 1747 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1748 | class Meta: |
| 1749 | model = PlanetStack |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1750 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1751 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1752 | class PlanetStackIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1753 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1754 | |
| 1755 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1756 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1757 | def getHumanReadableName(self, obj):
|
| 1758 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1759 | def getValidators(self, obj):
|
| 1760 | try: |
| 1761 | return obj.getValidators() |
| 1762 | except: |
| 1763 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1764 | class Meta:
|
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1765 | model = PlanetStack |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1766 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1767 | |
| 1768 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1769 | |
| 1770 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1771 | class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1772 | id = IdField() |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1773 | |
| 1774 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1775 | validators = serializers.SerializerMethodField("getValidators") |
| 1776 | def getHumanReadableName(self, obj):
|
| 1777 | return str(obj) |
| 1778 | def getValidators(self, obj): |
| 1779 | try: |
| 1780 | return obj.getValidators() |
| 1781 | except: |
| 1782 | return None |
| 1783 | class Meta: |
| 1784 | model = ControllerDashboardView |
| 1785 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1786 | |
| 1787 | class ControllerDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1788 | id = IdField() |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1789 | |
| 1790 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1791 | validators = serializers.SerializerMethodField("getValidators") |
| 1792 | def getHumanReadableName(self, obj):
|
| 1793 | return str(obj)
|
| 1794 | def getValidators(self, obj):
|
| 1795 | try: |
| 1796 | return obj.getValidators() |
| 1797 | except: |
| 1798 | return None
|
| 1799 | class Meta:
|
| 1800 | model = ControllerDashboardView |
| 1801 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1802 | |
| 1803 | |
| 1804 | |
| 1805 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1806 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1807 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1808 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1809 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1810 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1811 | def getHumanReadableName(self, obj):
|
| 1812 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1813 | def getValidators(self, obj): |
| 1814 | try: |
| 1815 | return obj.getValidators() |
| 1816 | except: |
| 1817 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1818 | class Meta: |
| 1819 | model = Account |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1820 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1821 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1822 | class AccountIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1823 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1824 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1825 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1826 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1827 | def getHumanReadableName(self, obj):
|
| 1828 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1829 | def getValidators(self, obj):
|
| 1830 | try: |
| 1831 | return obj.getValidators() |
| 1832 | except: |
| 1833 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1834 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1835 | model = Account |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1836 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1837 | |
| 1838 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1839 | |
| 1840 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1841 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1842 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1843 | |
| 1844 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1845 | validators = serializers.SerializerMethodField("getValidators") |
| 1846 | def getHumanReadableName(self, obj):
|
| 1847 | return str(obj) |
| 1848 | def getValidators(self, obj): |
| 1849 | try: |
| 1850 | return obj.getValidators() |
| 1851 | except: |
| 1852 | return None |
| 1853 | class Meta: |
| 1854 | model = ControllerRole |
| 1855 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1856 | |
| 1857 | class ControllerRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1858 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1859 | |
| 1860 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1861 | validators = serializers.SerializerMethodField("getValidators") |
| 1862 | def getHumanReadableName(self, obj):
|
| 1863 | return str(obj)
|
| 1864 | def getValidators(self, obj):
|
| 1865 | try: |
| 1866 | return obj.getValidators() |
| 1867 | except: |
| 1868 | return None
|
| 1869 | class Meta:
|
| 1870 | model = ControllerRole |
| 1871 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1872 | |
| 1873 | |
| 1874 | |
| 1875 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1876 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1877 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1878 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1879 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1880 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1881 | def getHumanReadableName(self, obj):
|
| 1882 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1883 | def getValidators(self, obj): |
| 1884 | try: |
| 1885 | return obj.getValidators() |
| 1886 | except: |
| 1887 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1888 | class Meta: |
| 1889 | model = NetworkParameterType |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1890 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1891 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1892 | class NetworkParameterTypeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1893 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1894 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1895 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1896 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1897 | def getHumanReadableName(self, obj):
|
| 1898 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1899 | def getValidators(self, obj):
|
| 1900 | try: |
| 1901 | return obj.getValidators() |
| 1902 | except: |
| 1903 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1904 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1905 | model = NetworkParameterType |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1906 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1907 | |
| 1908 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1909 | |
| 1910 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1911 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1912 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1913 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1914 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1915 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1916 | def getHumanReadableName(self, obj):
|
| 1917 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1918 | def getValidators(self, obj): |
| 1919 | try: |
| 1920 | return obj.getValidators() |
| 1921 | except: |
| 1922 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1923 | class Meta: |
| 1924 | model = SiteCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1925 | 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] | 1926 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1927 | class SiteCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1928 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1929 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1930 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1931 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1932 | def getHumanReadableName(self, obj):
|
| 1933 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1934 | def getValidators(self, obj):
|
| 1935 | try: |
| 1936 | return obj.getValidators() |
| 1937 | except: |
| 1938 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1939 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1940 | model = SiteCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1941 | 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] | 1942 | |
| 1943 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1944 | |
| 1945 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1946 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1947 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1948 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1949 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1950 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1951 | def getHumanReadableName(self, obj):
|
| 1952 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1953 | def getValidators(self, obj): |
| 1954 | try: |
| 1955 | return obj.getValidators() |
| 1956 | except: |
| 1957 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1958 | class Meta: |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1959 | model = DeploymentPrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1960 | 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] | 1961 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1962 | class DeploymentPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1963 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1964 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1965 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1966 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1967 | def getHumanReadableName(self, obj):
|
| 1968 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1969 | def getValidators(self, obj):
|
| 1970 | try: |
| 1971 | return obj.getValidators() |
| 1972 | except: |
| 1973 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1974 | class Meta:
|
| 1975 | model = DeploymentPrivilege |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1976 | 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] | 1977 | |
| 1978 | |
| 1979 | |
| 1980 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1981 | class ControllerUserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1982 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1983 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1984 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1985 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1986 | def getHumanReadableName(self, obj):
|
| 1987 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1988 | def getValidators(self, obj): |
| 1989 | try: |
| 1990 | return obj.getValidators() |
| 1991 | except: |
| 1992 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1993 | class Meta: |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1994 | model = ControllerUser |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1995 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 1996 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1997 | class ControllerUserIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1998 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1999 | |
| 2000 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2001 | validators = serializers.SerializerMethodField("getValidators") |
| 2002 | def getHumanReadableName(self, obj):
|
| 2003 | return str(obj)
|
| 2004 | def getValidators(self, obj):
|
| 2005 | try: |
| 2006 | return obj.getValidators() |
| 2007 | except: |
| 2008 | return None
|
| 2009 | class Meta:
|
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2010 | model = ControllerUser |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2011 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2012 | |
| 2013 | |
| 2014 | |
| 2015 | |
| 2016 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2017 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2018 | |
| 2019 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2020 | validators = serializers.SerializerMethodField("getValidators") |
| 2021 | def getHumanReadableName(self, obj):
|
| 2022 | return str(obj) |
| 2023 | def getValidators(self, obj): |
| 2024 | try: |
| 2025 | return obj.getValidators() |
| 2026 | except: |
| 2027 | return None |
| 2028 | class Meta: |
| 2029 | model = DeploymentRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2030 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2031 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2032 | class DeploymentRoleIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2033 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2034 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2035 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2036 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2037 | def getHumanReadableName(self, obj):
|
| 2038 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2039 | def getValidators(self, obj):
|
| 2040 | try: |
| 2041 | return obj.getValidators() |
| 2042 | except: |
| 2043 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2044 | class Meta:
|
| 2045 | model = DeploymentRole |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2046 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2047 | |
| 2048 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2049 | |
| 2050 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2051 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2052 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2053 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2054 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2055 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2056 | def getHumanReadableName(self, obj):
|
| 2057 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2058 | def getValidators(self, obj): |
| 2059 | try: |
| 2060 | return obj.getValidators() |
| 2061 | except: |
| 2062 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2063 | class Meta: |
| 2064 | model = UserCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2065 | 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] | 2066 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2067 | class UserCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2068 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2069 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2070 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2071 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2072 | def getHumanReadableName(self, obj):
|
| 2073 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2074 | def getValidators(self, obj):
|
| 2075 | try: |
| 2076 | return obj.getValidators() |
| 2077 | except: |
| 2078 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2079 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2080 | model = UserCredential |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2081 | 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] | 2082 | |
| 2083 | |
| 2084 | |
| 2085 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2086 | class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2087 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2088 | |
| 2089 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2090 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2091 | def getHumanReadableName(self, obj):
|
| 2092 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2093 | def getValidators(self, obj): |
| 2094 | try: |
| 2095 | return obj.getValidators() |
| 2096 | except: |
| 2097 | return None |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2098 | class Meta: |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2099 | model = SiteDeployment |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2100 | 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] | 2101 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2102 | class SiteDeploymentIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2103 | id = IdField() |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2104 | |
| 2105 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2106 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2107 | def getHumanReadableName(self, obj):
|
| 2108 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2109 | def getValidators(self, obj):
|
| 2110 | try: |
| 2111 | return obj.getValidators() |
| 2112 | except: |
| 2113 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2114 | class Meta:
|
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2115 | model = SiteDeployment |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2116 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
| 2117 | |
| 2118 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2119 | |
| 2120 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2121 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2122 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2123 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2124 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2125 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2126 | def getHumanReadableName(self, obj):
|
| 2127 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2128 | def getValidators(self, obj): |
| 2129 | try: |
| 2130 | return obj.getValidators() |
| 2131 | except: |
| 2132 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2133 | class Meta: |
| 2134 | model = SliceTag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2135 | 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] | 2136 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2137 | class SliceTagIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2138 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2139 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2140 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2141 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2142 | def getHumanReadableName(self, obj):
|
| 2143 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2144 | def getValidators(self, obj):
|
| 2145 | try: |
| 2146 | return obj.getValidators() |
| 2147 | except: |
| 2148 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2149 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2150 | model = SliceTag |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2151 | 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] | 2152 | |
| 2153 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2154 | |
| 2155 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2156 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2157 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2158 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2159 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2160 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2161 | def getHumanReadableName(self, obj):
|
| 2162 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2163 | def getValidators(self, obj): |
| 2164 | try: |
| 2165 | return obj.getValidators() |
| 2166 | except: |
| 2167 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2168 | class Meta: |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2169 | model = NetworkTemplate |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 2170 | 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] | 2171 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2172 | class NetworkTemplateIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2173 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2174 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2175 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2176 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2177 | def getHumanReadableName(self, obj):
|
| 2178 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2179 | def getValidators(self, obj):
|
| 2180 | try: |
| 2181 | return obj.getValidators() |
| 2182 | except: |
| 2183 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2184 | class Meta:
|
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2185 | model = NetworkTemplate |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 2186 | 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] | 2187 | |
| 2188 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2189 | |
| 2190 | |
| 2191 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2192 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2193 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2194 | |
| 2195 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2196 | |
| 2197 | |
| 2198 | |
| 2199 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2200 | |
| 2201 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2202 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2203 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2204 | def getHumanReadableName(self, obj):
|
| 2205 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2206 | def getValidators(self, obj): |
| 2207 | try: |
| 2208 | return obj.getValidators() |
| 2209 | except: |
| 2210 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2211 | class Meta: |
| 2212 | model = Router |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2213 | 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] | 2214 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2215 | class RouterIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2216 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2217 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2218 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2219 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2220 | |
| 2221 | |
| 2222 | |
Scott Baker | a3134fe | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2223 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2224 | |
| 2225 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2226 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2227 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2228 | def getHumanReadableName(self, obj):
|
| 2229 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2230 | def getValidators(self, obj):
|
| 2231 | try: |
| 2232 | return obj.getValidators() |
| 2233 | except: |
| 2234 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2235 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2236 | model = Router |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2237 | 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] | 2238 | |
| 2239 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2240 | |
| 2241 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2242 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2243 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2244 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2245 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2246 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2247 | def getHumanReadableName(self, obj):
|
| 2248 | return str(obj) |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2249 | def getValidators(self, obj): |
| 2250 | try: |
| 2251 | return obj.getValidators() |
| 2252 | except: |
| 2253 | return None |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2254 | class Meta: |
| 2255 | model = ServiceResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2256 | 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] | 2257 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2258 | class ServiceResourceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2259 | id = IdField() |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2260 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2261 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2262 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2263 | def getHumanReadableName(self, obj):
|
| 2264 | return str(obj)
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2265 | def getValidators(self, obj):
|
| 2266 | try: |
| 2267 | return obj.getValidators() |
| 2268 | except: |
| 2269 | return None
|
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2270 | class Meta:
|
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2271 | model = ServiceResource |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2272 | 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] | 2273 | |
| 2274 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2275 | |
| 2276 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2277 | class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2278 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2279 | |
| 2280 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2281 | validators = serializers.SerializerMethodField("getValidators") |
| 2282 | def getHumanReadableName(self, obj):
|
| 2283 | return str(obj) |
| 2284 | def getValidators(self, obj): |
| 2285 | try: |
| 2286 | return obj.getValidators() |
| 2287 | except: |
| 2288 | return None |
| 2289 | class Meta: |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2290 | model = ControllerSlice |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2291 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2292 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2293 | class ControllerSliceIdSerializer(XOSModelSerializer): |
Scott Baker | c8af575 | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2294 | id = IdField() |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2295 | |
| 2296 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2297 | validators = serializers.SerializerMethodField("getValidators") |
| 2298 | def getHumanReadableName(self, obj):
|
| 2299 | return str(obj)
|
| 2300 | def getValidators(self, obj):
|
| 2301 | try: |
| 2302 | return obj.getValidators() |
| 2303 | except: |
| 2304 | return None
|
| 2305 | class Meta:
|
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2306 | model = ControllerSlice |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2307 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2308 | |
| 2309 | |
| 2310 | |
| 2311 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2312 | serializerLookUp = { |
| 2313 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2314 | Flavor: FlavorSerializer, |
| 2315 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2316 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2317 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2318 | ControllerImages: ControllerImagesSerializer, |
| 2319 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2320 | Image: ImageSerializer, |
| 2321 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2322 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2323 | |
| 2324 | Site: SiteSerializer, |
| 2325 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2326 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2327 | |
| 2328 | Tag: TagSerializer, |
| 2329 | |
| 2330 | Invoice: InvoiceSerializer, |
| 2331 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2332 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2333 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2334 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2335 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2336 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2337 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2338 | Project: ProjectSerializer, |
| 2339 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2340 | Slice: SliceSerializer, |
| 2341 | |
| 2342 | Network: NetworkSerializer, |
| 2343 | |
| 2344 | Service: ServiceSerializer, |
| 2345 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2346 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2347 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2348 | ControllerNetwork: ControllerNetworkSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2349 | |
| 2350 | Charge: ChargeSerializer, |
| 2351 | |
| 2352 | Role: RoleSerializer, |
| 2353 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2354 | UsableObject: UsableObjectSerializer, |
| 2355 | |
| 2356 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2357 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2358 | SliceCredential: SliceCredentialSerializer, |
| 2359 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2360 | Sliver: SliverSerializer, |
| 2361 | |
| 2362 | Node: NodeSerializer, |
| 2363 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2364 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2365 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2366 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2367 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2368 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 645dc9d | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2369 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2370 | Payment: PaymentSerializer, |
| 2371 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2372 | NetworkSlice: NetworkSliceSerializer, |
| 2373 | |
| 2374 | UserDashboardView: UserDashboardViewSerializer, |
| 2375 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2376 | Controller: ControllerSerializer, |
| 2377 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2378 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2379 | |
| 2380 | User: UserSerializer, |
| 2381 | |
| 2382 | Deployment: DeploymentSerializer, |
| 2383 | |
| 2384 | Reservation: ReservationSerializer, |
| 2385 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2386 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2387 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2388 | PlanetStack: PlanetStackSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2389 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2390 | ControllerDashboardView: ControllerDashboardViewSerializer, |
| 2391 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2392 | Account: AccountSerializer, |
| 2393 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2394 | ControllerRole: ControllerRoleSerializer, |
| 2395 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2396 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2397 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2398 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2399 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2400 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2401 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2402 | ControllerUser: ControllerUserSerializer, |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2403 | |
| 2404 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2405 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2406 | UserCredential: UserCredentialSerializer, |
| 2407 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2408 | SiteDeployment: SiteDeploymentSerializer, |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2409 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2410 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2411 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2412 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2413 | |
| 2414 | Router: RouterSerializer, |
| 2415 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2416 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2417 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2418 | ControllerSlice: ControllerSliceSerializer, |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2419 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2420 | None: None, |
| 2421 | } |
| 2422 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2423 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2424 | |
| 2425 | # To handle fine-grained field permissions, we have to check can_update |
| 2426 | # the object has been updated but before it has been saved. |
| 2427 | |
| 2428 | def update(self, request, *args, **kwargs):
|
| 2429 | partial = kwargs.pop('partial', False)
|
| 2430 | self.object = self.get_object_or_none()
|
| 2431 |
|
| 2432 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2433 | files=request.FILES, partial=partial)
|
| 2434 |
|
| 2435 | if not serializer.is_valid():
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2436 | response = {"error": "validation",
|
| 2437 | "specific_error": "not serializer.is_valid()",
|
| 2438 | "reasons": serializer.errors}
|
| 2439 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2440 |
|
| 2441 | try:
|
| 2442 | self.pre_save(serializer.object)
|
| 2443 | except ValidationError as err:
|
| 2444 | # full_clean on model instance may be called in pre_save,
|
| 2445 | # so we have to handle eventual errors.
|
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2446 | response = {"error": "validation",
|
| 2447 | "specific_error": "ValidationError in pre_save",
|
| 2448 | "reasons": err.message_dict}
|
| 2449 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2450 |
|
| 2451 | if serializer.object is not None:
|
| 2452 | if not serializer.object.can_update(request.user):
|
| 2453 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2454 |
|
| 2455 | if self.object is None:
|
| 2456 | self.object = serializer.save(force_insert=True)
|
| 2457 | self.post_save(self.object, created=True)
|
| 2458 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2459 |
|
| 2460 | self.object = serializer.save(force_update=True)
|
| 2461 | self.post_save(self.object, created=False)
|
| 2462 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2463 | |
| 2464 | def destroy(self, request, *args, **kwargs): |
| 2465 | obj = self.get_object() |
| 2466 | if obj.can_update(request.user): |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2467 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2468 | else: |
| 2469 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2470 | |
| 2471 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2472 | # Based on core/views/*.py |
| 2473 | |
| 2474 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2475 | class FlavorList(generics.ListCreateAPIView): |
| 2476 | queryset = Flavor.objects.select_related().all() |
| 2477 | serializer_class = FlavorSerializer |
| 2478 | id_serializer_class = FlavorIdSerializer |
| 2479 | filter_backends = (filters.DjangoFilterBackend,) |
| 2480 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 2481 | |
| 2482 | def get_serializer_class(self): |
| 2483 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2484 | if (no_hyperlinks): |
| 2485 | return self.id_serializer_class |
| 2486 | else: |
| 2487 | return self.serializer_class |
| 2488 | |
| 2489 | def get_queryset(self): |
| 2490 | return Flavor.select_by_user(self.request.user) |
| 2491 | |
| 2492 | def create(self, request, *args, **kwargs): |
| 2493 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2494 | if not (serializer.is_valid()): |
| 2495 | response = {"error": "validation", |
| 2496 | "specific_error": "not serializer.is_valid()",
|
| 2497 | "reasons": serializer.errors}
|
| 2498 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2499 | obj = serializer.object |
| 2500 | obj.caller = request.user |
| 2501 | if obj.can_update(request.user): |
| 2502 | return super(FlavorList, self).create(request, *args, **kwargs) |
| 2503 | else: |
| 2504 | raise Exception("failed obj.can_update") |
| 2505 | |
| 2506 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 2507 | if (ret.status_code%100 != 200): |
| 2508 | raise Exception(ret.data) |
| 2509 | |
| 2510 | return ret |
| 2511 | |
| 2512 | |
| 2513 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2514 | queryset = Flavor.objects.select_related().all() |
| 2515 | serializer_class = FlavorSerializer |
| 2516 | id_serializer_class = FlavorIdSerializer |
| 2517 | |
| 2518 | def get_serializer_class(self): |
| 2519 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2520 | if (no_hyperlinks): |
| 2521 | return self.id_serializer_class |
| 2522 | else: |
| 2523 | return self.serializer_class |
| 2524 | |
| 2525 | def get_queryset(self): |
| 2526 | return Flavor.select_by_user(self.request.user) |
| 2527 | |
| 2528 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2529 | |
| 2530 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2531 | |
| 2532 | |
| 2533 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2534 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 2535 | queryset = ServiceAttribute.objects.select_related().all() |
| 2536 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2537 | id_serializer_class = ServiceAttributeIdSerializer |
| 2538 | filter_backends = (filters.DjangoFilterBackend,) |
| 2539 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 2540 | |
| 2541 | def get_serializer_class(self): |
| 2542 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2543 | if (no_hyperlinks): |
| 2544 | return self.id_serializer_class |
| 2545 | else: |
| 2546 | return self.serializer_class |
| 2547 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2548 | def get_queryset(self): |
| 2549 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2550 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2551 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2552 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2553 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2554 | response = {"error": "validation", |
| 2555 | "specific_error": "not serializer.is_valid()",
|
| 2556 | "reasons": serializer.errors}
|
| 2557 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2558 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2559 | obj.caller = request.user |
| 2560 | if obj.can_update(request.user): |
| 2561 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2562 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2563 | raise Exception("failed obj.can_update") |
| 2564 | |
| 2565 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2566 | if (ret.status_code%100 != 200): |
| 2567 | raise Exception(ret.data) |
| 2568 | |
| 2569 | return ret |
| 2570 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2571 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2572 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2573 | queryset = ServiceAttribute.objects.select_related().all() |
| 2574 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2575 | id_serializer_class = ServiceAttributeIdSerializer |
| 2576 | |
| 2577 | def get_serializer_class(self): |
| 2578 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2579 | if (no_hyperlinks): |
| 2580 | return self.id_serializer_class |
| 2581 | else: |
| 2582 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2583 | |
| 2584 | def get_queryset(self): |
| 2585 | return ServiceAttribute.select_by_user(self.request.user) |
| 2586 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2587 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2588 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2589 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2590 | |
| 2591 | |
| 2592 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2593 | class ControllerImagesList(generics.ListCreateAPIView): |
| 2594 | queryset = ControllerImages.objects.select_related().all() |
| 2595 | serializer_class = ControllerImagesSerializer |
| 2596 | id_serializer_class = ControllerImagesIdSerializer |
| 2597 | filter_backends = (filters.DjangoFilterBackend,) |
| 2598 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 2599 | |
| 2600 | def get_serializer_class(self): |
| 2601 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2602 | if (no_hyperlinks): |
| 2603 | return self.id_serializer_class |
| 2604 | else: |
| 2605 | return self.serializer_class |
| 2606 | |
| 2607 | def get_queryset(self): |
| 2608 | return ControllerImages.select_by_user(self.request.user) |
| 2609 | |
| 2610 | def create(self, request, *args, **kwargs): |
| 2611 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2612 | if not (serializer.is_valid()): |
| 2613 | response = {"error": "validation", |
| 2614 | "specific_error": "not serializer.is_valid()",
|
| 2615 | "reasons": serializer.errors}
|
| 2616 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2617 | obj = serializer.object |
| 2618 | obj.caller = request.user |
| 2619 | if obj.can_update(request.user): |
| 2620 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2621 | else: |
| 2622 | raise Exception("failed obj.can_update") |
| 2623 | |
| 2624 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2625 | if (ret.status_code%100 != 200): |
| 2626 | raise Exception(ret.data) |
| 2627 | |
| 2628 | return ret |
| 2629 | |
| 2630 | |
| 2631 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2632 | queryset = ControllerImages.objects.select_related().all() |
| 2633 | serializer_class = ControllerImagesSerializer |
| 2634 | id_serializer_class = ControllerImagesIdSerializer |
| 2635 | |
| 2636 | def get_serializer_class(self): |
| 2637 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2638 | if (no_hyperlinks): |
| 2639 | return self.id_serializer_class |
| 2640 | else: |
| 2641 | return self.serializer_class |
| 2642 | |
| 2643 | def get_queryset(self): |
| 2644 | return ControllerImages.select_by_user(self.request.user) |
| 2645 | |
| 2646 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2647 | |
| 2648 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2649 | |
| 2650 | |
| 2651 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2652 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2653 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2654 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2655 | id_serializer_class = ImageIdSerializer |
| 2656 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 2657 | 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] | 2658 | |
| 2659 | def get_serializer_class(self): |
| 2660 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2661 | if (no_hyperlinks): |
| 2662 | return self.id_serializer_class |
| 2663 | else: |
| 2664 | return self.serializer_class |
| 2665 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2666 | def get_queryset(self): |
| 2667 | return Image.select_by_user(self.request.user) |
| 2668 | |
| 2669 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2670 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2671 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2672 | response = {"error": "validation", |
| 2673 | "specific_error": "not serializer.is_valid()",
|
| 2674 | "reasons": serializer.errors}
|
| 2675 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2676 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2677 | obj.caller = request.user |
| 2678 | if obj.can_update(request.user): |
| 2679 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2680 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2681 | raise Exception("failed obj.can_update") |
| 2682 | |
| 2683 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2684 | if (ret.status_code%100 != 200): |
| 2685 | raise Exception(ret.data) |
| 2686 | |
| 2687 | return ret |
| 2688 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2689 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2690 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2691 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2692 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2693 | id_serializer_class = ImageIdSerializer |
| 2694 | |
| 2695 | def get_serializer_class(self): |
| 2696 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2697 | if (no_hyperlinks): |
| 2698 | return self.id_serializer_class |
| 2699 | else: |
| 2700 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2701 | |
| 2702 | def get_queryset(self): |
| 2703 | return Image.select_by_user(self.request.user) |
| 2704 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2705 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2706 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2707 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2708 | |
| 2709 | |
| 2710 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2711 | class NetworkParameterList(generics.ListCreateAPIView): |
| 2712 | queryset = NetworkParameter.objects.select_related().all() |
| 2713 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2714 | id_serializer_class = NetworkParameterIdSerializer |
| 2715 | filter_backends = (filters.DjangoFilterBackend,) |
| 2716 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 2717 | |
| 2718 | def get_serializer_class(self): |
| 2719 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2720 | if (no_hyperlinks): |
| 2721 | return self.id_serializer_class |
| 2722 | else: |
| 2723 | return self.serializer_class |
| 2724 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2725 | def get_queryset(self): |
| 2726 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2727 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2728 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2729 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2730 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2731 | response = {"error": "validation", |
| 2732 | "specific_error": "not serializer.is_valid()",
|
| 2733 | "reasons": serializer.errors}
|
| 2734 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2735 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2736 | obj.caller = request.user |
| 2737 | if obj.can_update(request.user): |
| 2738 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2739 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2740 | raise Exception("failed obj.can_update") |
| 2741 | |
| 2742 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2743 | if (ret.status_code%100 != 200): |
| 2744 | raise Exception(ret.data) |
| 2745 | |
| 2746 | return ret |
| 2747 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2748 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2749 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2750 | queryset = NetworkParameter.objects.select_related().all() |
| 2751 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2752 | id_serializer_class = NetworkParameterIdSerializer |
| 2753 | |
| 2754 | def get_serializer_class(self): |
| 2755 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2756 | if (no_hyperlinks): |
| 2757 | return self.id_serializer_class |
| 2758 | else: |
| 2759 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2760 | |
| 2761 | def get_queryset(self): |
| 2762 | return NetworkParameter.select_by_user(self.request.user) |
| 2763 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2764 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2765 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2766 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2767 | |
| 2768 | |
| 2769 | |
| 2770 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2771 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2772 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2773 | id_serializer_class = SiteIdSerializer |
| 2774 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2775 | 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] | 2776 | |
| 2777 | def get_serializer_class(self): |
| 2778 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2779 | if (no_hyperlinks): |
| 2780 | return self.id_serializer_class |
| 2781 | else: |
| 2782 | return self.serializer_class |
| 2783 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2784 | def get_queryset(self): |
| 2785 | return Site.select_by_user(self.request.user) |
| 2786 | |
| 2787 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2788 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2789 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2790 | response = {"error": "validation", |
| 2791 | "specific_error": "not serializer.is_valid()",
|
| 2792 | "reasons": serializer.errors}
|
| 2793 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2794 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2795 | obj.caller = request.user |
| 2796 | if obj.can_update(request.user): |
| 2797 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2798 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2799 | raise Exception("failed obj.can_update") |
| 2800 | |
| 2801 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2802 | if (ret.status_code%100 != 200): |
| 2803 | raise Exception(ret.data) |
| 2804 | |
| 2805 | return ret |
| 2806 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2807 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2808 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2809 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2810 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2811 | id_serializer_class = SiteIdSerializer |
| 2812 | |
| 2813 | def get_serializer_class(self): |
| 2814 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2815 | if (no_hyperlinks): |
| 2816 | return self.id_serializer_class |
| 2817 | else: |
| 2818 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2819 | |
| 2820 | def get_queryset(self): |
| 2821 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2822 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2823 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2824 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2825 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2826 | |
| 2827 | |
| 2828 | |
| 2829 | class SliceRoleList(generics.ListCreateAPIView): |
| 2830 | queryset = SliceRole.objects.select_related().all() |
| 2831 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2832 | id_serializer_class = SliceRoleIdSerializer |
| 2833 | filter_backends = (filters.DjangoFilterBackend,) |
| 2834 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2835 | |
| 2836 | def get_serializer_class(self): |
| 2837 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2838 | if (no_hyperlinks): |
| 2839 | return self.id_serializer_class |
| 2840 | else: |
| 2841 | return self.serializer_class |
| 2842 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2843 | def get_queryset(self): |
| 2844 | return SliceRole.select_by_user(self.request.user) |
| 2845 | |
| 2846 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2847 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2848 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2849 | response = {"error": "validation", |
| 2850 | "specific_error": "not serializer.is_valid()",
|
| 2851 | "reasons": serializer.errors}
|
| 2852 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2853 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2854 | obj.caller = request.user |
| 2855 | if obj.can_update(request.user): |
| 2856 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2857 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2858 | raise Exception("failed obj.can_update") |
| 2859 | |
| 2860 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2861 | if (ret.status_code%100 != 200): |
| 2862 | raise Exception(ret.data) |
| 2863 | |
| 2864 | return ret |
| 2865 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2866 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2867 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2868 | queryset = SliceRole.objects.select_related().all() |
| 2869 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2870 | id_serializer_class = SliceRoleIdSerializer |
| 2871 | |
| 2872 | def get_serializer_class(self): |
| 2873 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2874 | if (no_hyperlinks): |
| 2875 | return self.id_serializer_class |
| 2876 | else: |
| 2877 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2878 | |
| 2879 | def get_queryset(self): |
| 2880 | return SliceRole.select_by_user(self.request.user) |
| 2881 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2882 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2883 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2884 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2885 | |
| 2886 | |
| 2887 | |
| 2888 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2889 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2890 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2891 | id_serializer_class = TagIdSerializer |
| 2892 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2893 | 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] | 2894 | |
| 2895 | def get_serializer_class(self): |
| 2896 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2897 | if (no_hyperlinks): |
| 2898 | return self.id_serializer_class |
| 2899 | else: |
| 2900 | return self.serializer_class |
| 2901 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2902 | def get_queryset(self): |
| 2903 | return Tag.select_by_user(self.request.user) |
| 2904 | |
| 2905 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2906 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2907 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2908 | response = {"error": "validation", |
| 2909 | "specific_error": "not serializer.is_valid()",
|
| 2910 | "reasons": serializer.errors}
|
| 2911 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2912 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2913 | obj.caller = request.user |
| 2914 | if obj.can_update(request.user): |
| 2915 | return super(TagList, self).create(request, *args, **kwargs) |
| 2916 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2917 | raise Exception("failed obj.can_update") |
| 2918 | |
| 2919 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 2920 | if (ret.status_code%100 != 200): |
| 2921 | raise Exception(ret.data) |
| 2922 | |
| 2923 | return ret |
| 2924 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2925 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2926 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2927 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2928 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2929 | id_serializer_class = TagIdSerializer |
| 2930 | |
| 2931 | def get_serializer_class(self): |
| 2932 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2933 | if (no_hyperlinks): |
| 2934 | return self.id_serializer_class |
| 2935 | else: |
| 2936 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2937 | |
| 2938 | def get_queryset(self): |
| 2939 | return Tag.select_by_user(self.request.user) |
| 2940 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2941 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2942 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2943 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2944 | |
| 2945 | |
| 2946 | |
| 2947 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2948 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2949 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2950 | id_serializer_class = InvoiceIdSerializer |
| 2951 | filter_backends = (filters.DjangoFilterBackend,) |
| 2952 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 2953 | |
| 2954 | def get_serializer_class(self): |
| 2955 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2956 | if (no_hyperlinks): |
| 2957 | return self.id_serializer_class |
| 2958 | else: |
| 2959 | return self.serializer_class |
| 2960 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2961 | def get_queryset(self): |
| 2962 | return Invoice.select_by_user(self.request.user) |
| 2963 | |
| 2964 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2965 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2966 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2967 | response = {"error": "validation", |
| 2968 | "specific_error": "not serializer.is_valid()",
|
| 2969 | "reasons": serializer.errors}
|
| 2970 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2971 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2972 | obj.caller = request.user |
| 2973 | if obj.can_update(request.user): |
| 2974 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 2975 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2976 | raise Exception("failed obj.can_update") |
| 2977 | |
| 2978 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 2979 | if (ret.status_code%100 != 200): |
| 2980 | raise Exception(ret.data) |
| 2981 | |
| 2982 | return ret |
| 2983 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2984 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2985 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2986 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2987 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2988 | id_serializer_class = InvoiceIdSerializer |
| 2989 | |
| 2990 | def get_serializer_class(self): |
| 2991 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2992 | if (no_hyperlinks): |
| 2993 | return self.id_serializer_class |
| 2994 | else: |
| 2995 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2996 | |
| 2997 | def get_queryset(self): |
| 2998 | return Invoice.select_by_user(self.request.user) |
| 2999 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3000 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3001 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3002 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3003 | |
| 3004 | |
| 3005 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3006 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 3007 | queryset = SlicePrivilege.objects.select_related().all() |
| 3008 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3009 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3010 | filter_backends = (filters.DjangoFilterBackend,) |
| 3011 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 3012 | |
| 3013 | def get_serializer_class(self): |
| 3014 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3015 | if (no_hyperlinks): |
| 3016 | return self.id_serializer_class |
| 3017 | else: |
| 3018 | return self.serializer_class |
| 3019 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3020 | def get_queryset(self): |
| 3021 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3022 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3023 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3024 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3025 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3026 | response = {"error": "validation", |
| 3027 | "specific_error": "not serializer.is_valid()",
|
| 3028 | "reasons": serializer.errors}
|
| 3029 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3030 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3031 | obj.caller = request.user |
| 3032 | if obj.can_update(request.user): |
| 3033 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3034 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3035 | raise Exception("failed obj.can_update") |
| 3036 | |
| 3037 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3038 | if (ret.status_code%100 != 200): |
| 3039 | raise Exception(ret.data) |
| 3040 | |
| 3041 | return ret |
| 3042 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3043 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3044 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3045 | queryset = SlicePrivilege.objects.select_related().all() |
| 3046 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3047 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3048 | |
| 3049 | def get_serializer_class(self): |
| 3050 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3051 | if (no_hyperlinks): |
| 3052 | return self.id_serializer_class |
| 3053 | else: |
| 3054 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3055 | |
| 3056 | def get_queryset(self): |
| 3057 | return SlicePrivilege.select_by_user(self.request.user) |
| 3058 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3059 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3060 | |
| 3061 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3062 | |
| 3063 | |
| 3064 | |
| 3065 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 3066 | queryset = PlanetStackRole.objects.select_related().all() |
| 3067 | serializer_class = PlanetStackRoleSerializer |
| 3068 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3069 | filter_backends = (filters.DjangoFilterBackend,) |
| 3070 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3071 | |
| 3072 | def get_serializer_class(self): |
| 3073 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3074 | if (no_hyperlinks): |
| 3075 | return self.id_serializer_class |
| 3076 | else: |
| 3077 | return self.serializer_class |
| 3078 | |
| 3079 | def get_queryset(self): |
| 3080 | return PlanetStackRole.select_by_user(self.request.user) |
| 3081 | |
| 3082 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3083 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3084 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3085 | response = {"error": "validation", |
| 3086 | "specific_error": "not serializer.is_valid()",
|
| 3087 | "reasons": serializer.errors}
|
| 3088 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3089 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3090 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3091 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3092 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3093 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3094 | raise Exception("failed obj.can_update") |
| 3095 | |
| 3096 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 3097 | if (ret.status_code%100 != 200): |
| 3098 | raise Exception(ret.data) |
| 3099 | |
| 3100 | return ret |
| 3101 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3102 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3103 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3104 | queryset = PlanetStackRole.objects.select_related().all() |
| 3105 | serializer_class = PlanetStackRoleSerializer |
| 3106 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3107 | |
| 3108 | def get_serializer_class(self): |
| 3109 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3110 | if (no_hyperlinks): |
| 3111 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3112 | else: |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3113 | return self.serializer_class |
| 3114 | |
| 3115 | def get_queryset(self): |
| 3116 | return PlanetStackRole.select_by_user(self.request.user) |
| 3117 | |
| 3118 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3119 | |
| 3120 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3121 | |
| 3122 | |
| 3123 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3124 | class NetworkSliverList(generics.ListCreateAPIView): |
| 3125 | queryset = NetworkSliver.objects.select_related().all() |
| 3126 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3127 | id_serializer_class = NetworkSliverIdSerializer |
| 3128 | filter_backends = (filters.DjangoFilterBackend,) |
| 3129 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 3130 | |
| 3131 | def get_serializer_class(self): |
| 3132 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3133 | if (no_hyperlinks): |
| 3134 | return self.id_serializer_class |
| 3135 | else: |
| 3136 | return self.serializer_class |
| 3137 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3138 | def get_queryset(self): |
| 3139 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3140 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3141 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3142 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3143 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3144 | response = {"error": "validation", |
| 3145 | "specific_error": "not serializer.is_valid()",
|
| 3146 | "reasons": serializer.errors}
|
| 3147 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3148 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3149 | obj.caller = request.user |
| 3150 | if obj.can_update(request.user): |
| 3151 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3152 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3153 | raise Exception("failed obj.can_update") |
| 3154 | |
| 3155 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3156 | if (ret.status_code%100 != 200): |
| 3157 | raise Exception(ret.data) |
| 3158 | |
| 3159 | return ret |
| 3160 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3161 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3162 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3163 | queryset = NetworkSliver.objects.select_related().all() |
| 3164 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3165 | id_serializer_class = NetworkSliverIdSerializer |
| 3166 | |
| 3167 | def get_serializer_class(self): |
| 3168 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3169 | if (no_hyperlinks): |
| 3170 | return self.id_serializer_class |
| 3171 | else: |
| 3172 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3173 | |
| 3174 | def get_queryset(self): |
| 3175 | return NetworkSliver.select_by_user(self.request.user) |
| 3176 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3177 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3178 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3179 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3180 | |
| 3181 | |
| 3182 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3183 | class ProjectList(generics.ListCreateAPIView): |
| 3184 | queryset = Project.objects.select_related().all() |
| 3185 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3186 | id_serializer_class = ProjectIdSerializer |
| 3187 | filter_backends = (filters.DjangoFilterBackend,) |
| 3188 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3189 | |
| 3190 | def get_serializer_class(self): |
| 3191 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3192 | if (no_hyperlinks): |
| 3193 | return self.id_serializer_class |
| 3194 | else: |
| 3195 | return self.serializer_class |
| 3196 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3197 | def get_queryset(self): |
| 3198 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3199 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3200 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3201 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3202 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3203 | response = {"error": "validation", |
| 3204 | "specific_error": "not serializer.is_valid()",
|
| 3205 | "reasons": serializer.errors}
|
| 3206 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3207 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3208 | obj.caller = request.user |
| 3209 | if obj.can_update(request.user): |
| 3210 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 3211 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3212 | raise Exception("failed obj.can_update") |
| 3213 | |
| 3214 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 3215 | if (ret.status_code%100 != 200): |
| 3216 | raise Exception(ret.data) |
| 3217 | |
| 3218 | return ret |
| 3219 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3220 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3221 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3222 | queryset = Project.objects.select_related().all() |
| 3223 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3224 | id_serializer_class = ProjectIdSerializer |
| 3225 | |
| 3226 | def get_serializer_class(self): |
| 3227 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3228 | if (no_hyperlinks): |
| 3229 | return self.id_serializer_class |
| 3230 | else: |
| 3231 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3232 | |
| 3233 | def get_queryset(self): |
| 3234 | return Project.select_by_user(self.request.user) |
| 3235 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3236 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3237 | |
| 3238 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3239 | |
| 3240 | |
| 3241 | |
| 3242 | class SliceList(generics.ListCreateAPIView): |
| 3243 | queryset = Slice.objects.select_related().all() |
| 3244 | serializer_class = SliceSerializer |
| 3245 | id_serializer_class = SliceIdSerializer |
| 3246 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3247 | 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] | 3248 | |
| 3249 | def get_serializer_class(self): |
| 3250 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3251 | if (no_hyperlinks): |
| 3252 | return self.id_serializer_class |
| 3253 | else: |
| 3254 | return self.serializer_class |
| 3255 | |
| 3256 | def get_queryset(self): |
| 3257 | return Slice.select_by_user(self.request.user) |
| 3258 | |
| 3259 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3260 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3261 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3262 | response = {"error": "validation", |
| 3263 | "specific_error": "not serializer.is_valid()",
|
| 3264 | "reasons": serializer.errors}
|
| 3265 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3266 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3267 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3268 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3269 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3270 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3271 | raise Exception("failed obj.can_update") |
| 3272 | |
| 3273 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3274 | if (ret.status_code%100 != 200): |
| 3275 | raise Exception(ret.data) |
| 3276 | |
| 3277 | return ret |
| 3278 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3279 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3280 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3281 | queryset = Slice.objects.select_related().all() |
| 3282 | serializer_class = SliceSerializer |
| 3283 | id_serializer_class = SliceIdSerializer |
| 3284 | |
| 3285 | def get_serializer_class(self): |
| 3286 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3287 | if (no_hyperlinks): |
| 3288 | return self.id_serializer_class |
| 3289 | else: |
| 3290 | return self.serializer_class |
| 3291 | |
| 3292 | def get_queryset(self): |
| 3293 | return Slice.select_by_user(self.request.user) |
| 3294 | |
| 3295 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3296 | |
| 3297 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3298 | |
| 3299 | |
| 3300 | |
| 3301 | class NetworkList(generics.ListCreateAPIView): |
| 3302 | queryset = Network.objects.select_related().all() |
| 3303 | serializer_class = NetworkSerializer |
| 3304 | id_serializer_class = NetworkIdSerializer |
| 3305 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 95bdf0a | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 3306 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3307 | |
| 3308 | def get_serializer_class(self): |
| 3309 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3310 | if (no_hyperlinks): |
| 3311 | return self.id_serializer_class |
| 3312 | else: |
| 3313 | return self.serializer_class |
| 3314 | |
| 3315 | def get_queryset(self): |
| 3316 | return Network.select_by_user(self.request.user) |
| 3317 | |
| 3318 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3319 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3320 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3321 | response = {"error": "validation", |
| 3322 | "specific_error": "not serializer.is_valid()",
|
| 3323 | "reasons": serializer.errors}
|
| 3324 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3325 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3326 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3327 | if obj.can_update(request.user): |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3328 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3329 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3330 | raise Exception("failed obj.can_update") |
| 3331 | |
| 3332 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3333 | if (ret.status_code%100 != 200): |
| 3334 | raise Exception(ret.data) |
| 3335 | |
| 3336 | return ret |
| 3337 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3338 | |
| 3339 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3340 | queryset = Network.objects.select_related().all() |
| 3341 | serializer_class = NetworkSerializer |
| 3342 | id_serializer_class = NetworkIdSerializer |
| 3343 | |
| 3344 | def get_serializer_class(self): |
| 3345 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3346 | if (no_hyperlinks): |
| 3347 | return self.id_serializer_class |
| 3348 | else: |
| 3349 | return self.serializer_class |
| 3350 | |
| 3351 | def get_queryset(self): |
| 3352 | return Network.select_by_user(self.request.user) |
| 3353 | |
| 3354 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3355 | |
| 3356 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3357 | |
| 3358 | |
| 3359 | |
| 3360 | class ServiceList(generics.ListCreateAPIView): |
| 3361 | queryset = Service.objects.select_related().all() |
| 3362 | serializer_class = ServiceSerializer |
| 3363 | id_serializer_class = ServiceIdSerializer |
| 3364 | filter_backends = (filters.DjangoFilterBackend,) |
| 3365 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 3366 | |
| 3367 | def get_serializer_class(self): |
| 3368 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3369 | if (no_hyperlinks): |
| 3370 | return self.id_serializer_class |
| 3371 | else: |
| 3372 | return self.serializer_class |
| 3373 | |
| 3374 | def get_queryset(self): |
| 3375 | return Service.select_by_user(self.request.user) |
| 3376 | |
| 3377 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3378 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3379 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3380 | response = {"error": "validation", |
| 3381 | "specific_error": "not serializer.is_valid()",
|
| 3382 | "reasons": serializer.errors}
|
| 3383 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3384 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3385 | obj.caller = request.user |
| 3386 | if obj.can_update(request.user): |
| 3387 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3388 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3389 | raise Exception("failed obj.can_update") |
| 3390 | |
| 3391 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3392 | if (ret.status_code%100 != 200): |
| 3393 | raise Exception(ret.data) |
| 3394 | |
| 3395 | return ret |
| 3396 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3397 | |
| 3398 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3399 | queryset = Service.objects.select_related().all() |
| 3400 | serializer_class = ServiceSerializer |
| 3401 | id_serializer_class = ServiceIdSerializer |
| 3402 | |
| 3403 | def get_serializer_class(self): |
| 3404 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3405 | if (no_hyperlinks): |
| 3406 | return self.id_serializer_class |
| 3407 | else: |
| 3408 | return self.serializer_class |
| 3409 | |
| 3410 | def get_queryset(self): |
| 3411 | return Service.select_by_user(self.request.user) |
| 3412 | |
| 3413 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3414 | |
| 3415 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3416 | |
| 3417 | |
| 3418 | |
| 3419 | class ServiceClassList(generics.ListCreateAPIView): |
| 3420 | queryset = ServiceClass.objects.select_related().all() |
| 3421 | serializer_class = ServiceClassSerializer |
| 3422 | id_serializer_class = ServiceClassIdSerializer |
| 3423 | filter_backends = (filters.DjangoFilterBackend,) |
| 3424 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 3425 | |
| 3426 | def get_serializer_class(self): |
| 3427 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3428 | if (no_hyperlinks): |
| 3429 | return self.id_serializer_class |
| 3430 | else: |
| 3431 | return self.serializer_class |
| 3432 | |
| 3433 | def get_queryset(self): |
| 3434 | return ServiceClass.select_by_user(self.request.user) |
| 3435 | |
| 3436 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3437 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3438 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3439 | response = {"error": "validation", |
| 3440 | "specific_error": "not serializer.is_valid()",
|
| 3441 | "reasons": serializer.errors}
|
| 3442 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3443 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3444 | obj.caller = request.user |
| 3445 | if obj.can_update(request.user): |
| 3446 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3447 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3448 | raise Exception("failed obj.can_update") |
| 3449 | |
| 3450 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3451 | if (ret.status_code%100 != 200): |
| 3452 | raise Exception(ret.data) |
| 3453 | |
| 3454 | return ret |
| 3455 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3456 | |
| 3457 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3458 | queryset = ServiceClass.objects.select_related().all() |
| 3459 | serializer_class = ServiceClassSerializer |
| 3460 | id_serializer_class = ServiceClassIdSerializer |
| 3461 | |
| 3462 | def get_serializer_class(self): |
| 3463 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3464 | if (no_hyperlinks): |
| 3465 | return self.id_serializer_class |
| 3466 | else: |
| 3467 | return self.serializer_class |
| 3468 | |
| 3469 | def get_queryset(self): |
| 3470 | return ServiceClass.select_by_user(self.request.user) |
| 3471 | |
| 3472 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3473 | |
| 3474 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3475 | |
| 3476 | |
| 3477 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3478 | class ControllerNetworkList(generics.ListCreateAPIView): |
| 3479 | queryset = ControllerNetwork.objects.select_related().all() |
| 3480 | serializer_class = ControllerNetworkSerializer |
| 3481 | id_serializer_class = ControllerNetworkIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3482 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3483 | 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] | 3484 | |
| 3485 | def get_serializer_class(self): |
| 3486 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3487 | if (no_hyperlinks): |
| 3488 | return self.id_serializer_class |
| 3489 | else: |
| 3490 | return self.serializer_class |
| 3491 | |
| 3492 | def get_queryset(self): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3493 | return ControllerNetwork.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3494 | |
| 3495 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3496 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3497 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3498 | response = {"error": "validation", |
| 3499 | "specific_error": "not serializer.is_valid()",
|
| 3500 | "reasons": serializer.errors}
|
| 3501 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3502 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3503 | obj.caller = request.user |
| 3504 | if obj.can_update(request.user): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3505 | return super(ControllerNetworkList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3506 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3507 | raise Exception("failed obj.can_update") |
| 3508 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3509 | ret = super(ControllerNetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3510 | if (ret.status_code%100 != 200): |
| 3511 | raise Exception(ret.data) |
| 3512 | |
| 3513 | return ret |
| 3514 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3515 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3516 | class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3517 | queryset = ControllerNetwork.objects.select_related().all() |
| 3518 | serializer_class = ControllerNetworkSerializer |
| 3519 | id_serializer_class = ControllerNetworkIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3520 | |
| 3521 | def get_serializer_class(self): |
| 3522 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3523 | if (no_hyperlinks): |
| 3524 | return self.id_serializer_class |
| 3525 | else: |
| 3526 | return self.serializer_class |
| 3527 | |
| 3528 | def get_queryset(self): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3529 | return ControllerNetwork.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3530 | |
| 3531 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3532 | |
| 3533 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3534 | |
| 3535 | |
| 3536 | |
| 3537 | class ChargeList(generics.ListCreateAPIView): |
| 3538 | queryset = Charge.objects.select_related().all() |
| 3539 | serializer_class = ChargeSerializer |
| 3540 | id_serializer_class = ChargeIdSerializer |
| 3541 | filter_backends = (filters.DjangoFilterBackend,) |
| 3542 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 3543 | |
| 3544 | def get_serializer_class(self): |
| 3545 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3546 | if (no_hyperlinks): |
| 3547 | return self.id_serializer_class |
| 3548 | else: |
| 3549 | return self.serializer_class |
| 3550 | |
| 3551 | def get_queryset(self): |
| 3552 | return Charge.select_by_user(self.request.user) |
| 3553 | |
| 3554 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3555 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3556 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3557 | response = {"error": "validation", |
| 3558 | "specific_error": "not serializer.is_valid()",
|
| 3559 | "reasons": serializer.errors}
|
| 3560 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3561 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3562 | obj.caller = request.user |
| 3563 | if obj.can_update(request.user): |
| 3564 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3565 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3566 | raise Exception("failed obj.can_update") |
| 3567 | |
| 3568 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3569 | if (ret.status_code%100 != 200): |
| 3570 | raise Exception(ret.data) |
| 3571 | |
| 3572 | return ret |
| 3573 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3574 | |
| 3575 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3576 | queryset = Charge.objects.select_related().all() |
| 3577 | serializer_class = ChargeSerializer |
| 3578 | id_serializer_class = ChargeIdSerializer |
| 3579 | |
| 3580 | def get_serializer_class(self): |
| 3581 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3582 | if (no_hyperlinks): |
| 3583 | return self.id_serializer_class |
| 3584 | else: |
| 3585 | return self.serializer_class |
| 3586 | |
| 3587 | def get_queryset(self): |
| 3588 | return Charge.select_by_user(self.request.user) |
| 3589 | |
| 3590 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3591 | |
| 3592 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3593 | |
| 3594 | |
| 3595 | |
| 3596 | class RoleList(generics.ListCreateAPIView): |
| 3597 | queryset = Role.objects.select_related().all() |
| 3598 | serializer_class = RoleSerializer |
| 3599 | id_serializer_class = RoleIdSerializer |
| 3600 | filter_backends = (filters.DjangoFilterBackend,) |
| 3601 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 3602 | |
| 3603 | def get_serializer_class(self): |
| 3604 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3605 | if (no_hyperlinks): |
| 3606 | return self.id_serializer_class |
| 3607 | else: |
| 3608 | return self.serializer_class |
| 3609 | |
| 3610 | def get_queryset(self): |
| 3611 | return Role.select_by_user(self.request.user) |
| 3612 | |
| 3613 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3614 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3615 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3616 | response = {"error": "validation", |
| 3617 | "specific_error": "not serializer.is_valid()",
|
| 3618 | "reasons": serializer.errors}
|
| 3619 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3620 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3621 | obj.caller = request.user |
| 3622 | if obj.can_update(request.user): |
| 3623 | return super(RoleList, self).create(request, *args, **kwargs) |
| 3624 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3625 | raise Exception("failed obj.can_update") |
| 3626 | |
| 3627 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 3628 | if (ret.status_code%100 != 200): |
| 3629 | raise Exception(ret.data) |
| 3630 | |
| 3631 | return ret |
| 3632 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3633 | |
| 3634 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3635 | queryset = Role.objects.select_related().all() |
| 3636 | serializer_class = RoleSerializer |
| 3637 | id_serializer_class = RoleIdSerializer |
| 3638 | |
| 3639 | def get_serializer_class(self): |
| 3640 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3641 | if (no_hyperlinks): |
| 3642 | return self.id_serializer_class |
| 3643 | else: |
| 3644 | return self.serializer_class |
| 3645 | |
| 3646 | def get_queryset(self): |
| 3647 | return Role.select_by_user(self.request.user) |
| 3648 | |
| 3649 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3650 | |
| 3651 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3652 | |
| 3653 | |
| 3654 | |
| 3655 | class UsableObjectList(generics.ListCreateAPIView): |
| 3656 | queryset = UsableObject.objects.select_related().all() |
| 3657 | serializer_class = UsableObjectSerializer |
| 3658 | id_serializer_class = UsableObjectIdSerializer |
| 3659 | filter_backends = (filters.DjangoFilterBackend,) |
| 3660 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3661 | |
| 3662 | def get_serializer_class(self): |
| 3663 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3664 | if (no_hyperlinks): |
| 3665 | return self.id_serializer_class |
| 3666 | else: |
| 3667 | return self.serializer_class |
| 3668 | |
| 3669 | def get_queryset(self): |
| 3670 | return UsableObject.select_by_user(self.request.user) |
| 3671 | |
| 3672 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3673 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3674 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3675 | response = {"error": "validation", |
| 3676 | "specific_error": "not serializer.is_valid()",
|
| 3677 | "reasons": serializer.errors}
|
| 3678 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3679 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3680 | obj.caller = request.user |
| 3681 | if obj.can_update(request.user): |
| 3682 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3683 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3684 | raise Exception("failed obj.can_update") |
| 3685 | |
| 3686 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3687 | if (ret.status_code%100 != 200): |
| 3688 | raise Exception(ret.data) |
| 3689 | |
| 3690 | return ret |
| 3691 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3692 | |
| 3693 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3694 | queryset = UsableObject.objects.select_related().all() |
| 3695 | serializer_class = UsableObjectSerializer |
| 3696 | id_serializer_class = UsableObjectIdSerializer |
| 3697 | |
| 3698 | def get_serializer_class(self): |
| 3699 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3700 | if (no_hyperlinks): |
| 3701 | return self.id_serializer_class |
| 3702 | else: |
| 3703 | return self.serializer_class |
| 3704 | |
| 3705 | def get_queryset(self): |
| 3706 | return UsableObject.select_by_user(self.request.user) |
| 3707 | |
| 3708 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3709 | |
| 3710 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3711 | |
| 3712 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3713 | class SiteRoleList(generics.ListCreateAPIView): |
| 3714 | queryset = SiteRole.objects.select_related().all() |
| 3715 | serializer_class = SiteRoleSerializer |
| 3716 | id_serializer_class = SiteRoleIdSerializer |
| 3717 | filter_backends = (filters.DjangoFilterBackend,) |
| 3718 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3719 | |
| 3720 | def get_serializer_class(self): |
| 3721 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3722 | if (no_hyperlinks): |
| 3723 | return self.id_serializer_class |
| 3724 | else: |
| 3725 | return self.serializer_class |
| 3726 | |
| 3727 | def get_queryset(self): |
| 3728 | return SiteRole.select_by_user(self.request.user) |
| 3729 | |
| 3730 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3731 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3732 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3733 | response = {"error": "validation", |
| 3734 | "specific_error": "not serializer.is_valid()",
|
| 3735 | "reasons": serializer.errors}
|
| 3736 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3737 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3738 | obj.caller = request.user |
| 3739 | if obj.can_update(request.user): |
| 3740 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3741 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3742 | raise Exception("failed obj.can_update") |
| 3743 | |
| 3744 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3745 | if (ret.status_code%100 != 200): |
| 3746 | raise Exception(ret.data) |
| 3747 | |
| 3748 | return ret |
| 3749 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3750 | |
| 3751 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3752 | queryset = SiteRole.objects.select_related().all() |
| 3753 | serializer_class = SiteRoleSerializer |
| 3754 | id_serializer_class = SiteRoleIdSerializer |
| 3755 | |
| 3756 | def get_serializer_class(self): |
| 3757 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3758 | if (no_hyperlinks): |
| 3759 | return self.id_serializer_class |
| 3760 | else: |
| 3761 | return self.serializer_class |
| 3762 | |
| 3763 | def get_queryset(self): |
| 3764 | return SiteRole.select_by_user(self.request.user) |
| 3765 | |
| 3766 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3767 | |
| 3768 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3769 | |
| 3770 | |
| 3771 | |
| 3772 | class SliceCredentialList(generics.ListCreateAPIView): |
| 3773 | queryset = SliceCredential.objects.select_related().all() |
| 3774 | serializer_class = SliceCredentialSerializer |
| 3775 | id_serializer_class = SliceCredentialIdSerializer |
| 3776 | filter_backends = (filters.DjangoFilterBackend,) |
| 3777 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 3778 | |
| 3779 | def get_serializer_class(self): |
| 3780 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3781 | if (no_hyperlinks): |
| 3782 | return self.id_serializer_class |
| 3783 | else: |
| 3784 | return self.serializer_class |
| 3785 | |
| 3786 | def get_queryset(self): |
| 3787 | return SliceCredential.select_by_user(self.request.user) |
| 3788 | |
| 3789 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3790 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3791 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3792 | response = {"error": "validation", |
| 3793 | "specific_error": "not serializer.is_valid()",
|
| 3794 | "reasons": serializer.errors}
|
| 3795 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3796 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3797 | obj.caller = request.user |
| 3798 | if obj.can_update(request.user): |
| 3799 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3800 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3801 | raise Exception("failed obj.can_update") |
| 3802 | |
| 3803 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3804 | if (ret.status_code%100 != 200): |
| 3805 | raise Exception(ret.data) |
| 3806 | |
| 3807 | return ret |
| 3808 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3809 | |
| 3810 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3811 | queryset = SliceCredential.objects.select_related().all() |
| 3812 | serializer_class = SliceCredentialSerializer |
| 3813 | id_serializer_class = SliceCredentialIdSerializer |
| 3814 | |
| 3815 | def get_serializer_class(self): |
| 3816 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3817 | if (no_hyperlinks): |
| 3818 | return self.id_serializer_class |
| 3819 | else: |
| 3820 | return self.serializer_class |
| 3821 | |
| 3822 | def get_queryset(self): |
| 3823 | return SliceCredential.select_by_user(self.request.user) |
| 3824 | |
| 3825 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3826 | |
| 3827 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3828 | |
| 3829 | |
| 3830 | |
| 3831 | class SliverList(generics.ListCreateAPIView): |
| 3832 | queryset = Sliver.objects.select_related().all() |
| 3833 | serializer_class = SliverSerializer |
| 3834 | id_serializer_class = SliverIdSerializer |
| 3835 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 3836 | 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] | 3837 | |
| 3838 | def get_serializer_class(self): |
| 3839 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3840 | if (no_hyperlinks): |
| 3841 | return self.id_serializer_class |
| 3842 | else: |
| 3843 | return self.serializer_class |
| 3844 | |
| 3845 | def get_queryset(self): |
| 3846 | return Sliver.select_by_user(self.request.user) |
| 3847 | |
| 3848 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3849 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3850 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3851 | response = {"error": "validation", |
| 3852 | "specific_error": "not serializer.is_valid()",
|
| 3853 | "reasons": serializer.errors}
|
| 3854 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3855 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3856 | obj.caller = request.user |
| 3857 | if obj.can_update(request.user): |
| 3858 | return super(SliverList, self).create(request, *args, **kwargs) |
| 3859 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3860 | raise Exception("failed obj.can_update") |
| 3861 | |
| 3862 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 3863 | if (ret.status_code%100 != 200): |
| 3864 | raise Exception(ret.data) |
| 3865 | |
| 3866 | return ret |
| 3867 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3868 | |
| 3869 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3870 | queryset = Sliver.objects.select_related().all() |
| 3871 | serializer_class = SliverSerializer |
| 3872 | id_serializer_class = SliverIdSerializer |
| 3873 | |
| 3874 | def get_serializer_class(self): |
| 3875 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3876 | if (no_hyperlinks): |
| 3877 | return self.id_serializer_class |
| 3878 | else: |
| 3879 | return self.serializer_class |
| 3880 | |
| 3881 | def get_queryset(self): |
| 3882 | return Sliver.select_by_user(self.request.user) |
| 3883 | |
| 3884 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3885 | |
| 3886 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3887 | |
| 3888 | |
| 3889 | |
| 3890 | class NodeList(generics.ListCreateAPIView): |
| 3891 | queryset = Node.objects.select_related().all() |
| 3892 | serializer_class = NodeSerializer |
| 3893 | id_serializer_class = NodeIdSerializer |
| 3894 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3895 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3896 | |
| 3897 | def get_serializer_class(self): |
| 3898 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3899 | if (no_hyperlinks): |
| 3900 | return self.id_serializer_class |
| 3901 | else: |
| 3902 | return self.serializer_class |
| 3903 | |
| 3904 | def get_queryset(self): |
| 3905 | return Node.select_by_user(self.request.user) |
| 3906 | |
| 3907 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3908 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3909 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3910 | response = {"error": "validation", |
| 3911 | "specific_error": "not serializer.is_valid()",
|
| 3912 | "reasons": serializer.errors}
|
| 3913 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3914 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3915 | obj.caller = request.user |
| 3916 | if obj.can_update(request.user): |
| 3917 | return super(NodeList, self).create(request, *args, **kwargs) |
| 3918 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3919 | raise Exception("failed obj.can_update") |
| 3920 | |
| 3921 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 3922 | if (ret.status_code%100 != 200): |
| 3923 | raise Exception(ret.data) |
| 3924 | |
| 3925 | return ret |
| 3926 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3927 | |
| 3928 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3929 | queryset = Node.objects.select_related().all() |
| 3930 | serializer_class = NodeSerializer |
| 3931 | id_serializer_class = NodeIdSerializer |
| 3932 | |
| 3933 | def get_serializer_class(self): |
| 3934 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3935 | if (no_hyperlinks): |
| 3936 | return self.id_serializer_class |
| 3937 | else: |
| 3938 | return self.serializer_class |
| 3939 | |
| 3940 | def get_queryset(self): |
| 3941 | return Node.select_by_user(self.request.user) |
| 3942 | |
| 3943 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3944 | |
| 3945 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3946 | |
| 3947 | |
| 3948 | |
| 3949 | class DashboardViewList(generics.ListCreateAPIView): |
| 3950 | queryset = DashboardView.objects.select_related().all() |
| 3951 | serializer_class = DashboardViewSerializer |
| 3952 | id_serializer_class = DashboardViewIdSerializer |
| 3953 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3954 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3955 | |
| 3956 | def get_serializer_class(self): |
| 3957 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3958 | if (no_hyperlinks): |
| 3959 | return self.id_serializer_class |
| 3960 | else: |
| 3961 | return self.serializer_class |
| 3962 | |
| 3963 | def get_queryset(self): |
| 3964 | return DashboardView.select_by_user(self.request.user) |
| 3965 | |
| 3966 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3967 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3968 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3969 | response = {"error": "validation", |
| 3970 | "specific_error": "not serializer.is_valid()",
|
| 3971 | "reasons": serializer.errors}
|
| 3972 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3973 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3974 | obj.caller = request.user |
| 3975 | if obj.can_update(request.user): |
| 3976 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 3977 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3978 | raise Exception("failed obj.can_update") |
| 3979 | |
| 3980 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 3981 | if (ret.status_code%100 != 200): |
| 3982 | raise Exception(ret.data) |
| 3983 | |
| 3984 | return ret |
| 3985 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3986 | |
| 3987 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3988 | queryset = DashboardView.objects.select_related().all() |
| 3989 | serializer_class = DashboardViewSerializer |
| 3990 | id_serializer_class = DashboardViewIdSerializer |
| 3991 | |
| 3992 | def get_serializer_class(self): |
| 3993 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3994 | if (no_hyperlinks): |
| 3995 | return self.id_serializer_class |
| 3996 | else: |
| 3997 | return self.serializer_class |
| 3998 | |
| 3999 | def get_queryset(self): |
| 4000 | return DashboardView.select_by_user(self.request.user) |
| 4001 | |
| 4002 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4003 | |
| 4004 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4005 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4006 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4007 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4008 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 4009 | queryset = ImageDeployments.objects.select_related().all() |
| 4010 | serializer_class = ImageDeploymentsSerializer |
| 4011 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4012 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4013 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4014 | |
| 4015 | def get_serializer_class(self): |
| 4016 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4017 | if (no_hyperlinks): |
| 4018 | return self.id_serializer_class |
| 4019 | else: |
| 4020 | return self.serializer_class |
| 4021 | |
| 4022 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4023 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4024 | |
| 4025 | def create(self, request, *args, **kwargs): |
| 4026 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4027 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4028 | response = {"error": "validation", |
| 4029 | "specific_error": "not serializer.is_valid()",
|
| 4030 | "reasons": serializer.errors}
|
| 4031 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4032 | obj = serializer.object |
| 4033 | obj.caller = request.user |
| 4034 | if obj.can_update(request.user): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4035 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4036 | else: |
| 4037 | raise Exception("failed obj.can_update") |
| 4038 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4039 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4040 | if (ret.status_code%100 != 200): |
| 4041 | raise Exception(ret.data) |
| 4042 | |
| 4043 | return ret |
| 4044 | |
| 4045 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4046 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4047 | queryset = ImageDeployments.objects.select_related().all() |
| 4048 | serializer_class = ImageDeploymentsSerializer |
| 4049 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4050 | |
| 4051 | def get_serializer_class(self): |
| 4052 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4053 | if (no_hyperlinks): |
| 4054 | return self.id_serializer_class |
| 4055 | else: |
| 4056 | return self.serializer_class |
| 4057 | |
| 4058 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4059 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4060 | |
| 4061 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4062 | |
| 4063 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4064 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4065 | |
| 4066 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4067 | class ReservedResourceList(generics.ListCreateAPIView): |
| 4068 | queryset = ReservedResource.objects.select_related().all() |
| 4069 | serializer_class = ReservedResourceSerializer |
| 4070 | id_serializer_class = ReservedResourceIdSerializer |
| 4071 | filter_backends = (filters.DjangoFilterBackend,) |
| 4072 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 4073 | |
| 4074 | def get_serializer_class(self): |
| 4075 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4076 | if (no_hyperlinks): |
| 4077 | return self.id_serializer_class |
| 4078 | else: |
| 4079 | return self.serializer_class |
| 4080 | |
| 4081 | def get_queryset(self): |
| 4082 | return ReservedResource.select_by_user(self.request.user) |
| 4083 | |
| 4084 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4085 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4086 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4087 | response = {"error": "validation", |
| 4088 | "specific_error": "not serializer.is_valid()",
|
| 4089 | "reasons": serializer.errors}
|
| 4090 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4091 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4092 | obj.caller = request.user |
| 4093 | if obj.can_update(request.user): |
| 4094 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4095 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4096 | raise Exception("failed obj.can_update") |
| 4097 | |
| 4098 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4099 | if (ret.status_code%100 != 200): |
| 4100 | raise Exception(ret.data) |
| 4101 | |
| 4102 | return ret |
| 4103 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4104 | |
| 4105 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4106 | queryset = ReservedResource.objects.select_related().all() |
| 4107 | serializer_class = ReservedResourceSerializer |
| 4108 | id_serializer_class = ReservedResourceIdSerializer |
| 4109 | |
| 4110 | def get_serializer_class(self): |
| 4111 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4112 | if (no_hyperlinks): |
| 4113 | return self.id_serializer_class |
| 4114 | else: |
| 4115 | return self.serializer_class |
| 4116 | |
| 4117 | def get_queryset(self): |
| 4118 | return ReservedResource.select_by_user(self.request.user) |
| 4119 | |
| 4120 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4121 | |
| 4122 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4123 | |
| 4124 | |
| 4125 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4126 | class PaymentList(generics.ListCreateAPIView): |
| 4127 | queryset = Payment.objects.select_related().all() |
| 4128 | serializer_class = PaymentSerializer |
| 4129 | id_serializer_class = PaymentIdSerializer |
| 4130 | filter_backends = (filters.DjangoFilterBackend,) |
| 4131 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 4132 | |
| 4133 | def get_serializer_class(self): |
| 4134 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4135 | if (no_hyperlinks): |
| 4136 | return self.id_serializer_class |
| 4137 | else: |
| 4138 | return self.serializer_class |
| 4139 | |
| 4140 | def get_queryset(self): |
| 4141 | return Payment.select_by_user(self.request.user) |
| 4142 | |
| 4143 | def create(self, request, *args, **kwargs): |
| 4144 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4145 | if not (serializer.is_valid()): |
| 4146 | response = {"error": "validation", |
| 4147 | "specific_error": "not serializer.is_valid()",
|
| 4148 | "reasons": serializer.errors}
|
| 4149 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4150 | obj = serializer.object |
| 4151 | obj.caller = request.user |
| 4152 | if obj.can_update(request.user): |
| 4153 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 4154 | else: |
| 4155 | raise Exception("failed obj.can_update") |
| 4156 | |
| 4157 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 4158 | if (ret.status_code%100 != 200): |
| 4159 | raise Exception(ret.data) |
| 4160 | |
| 4161 | return ret |
| 4162 | |
| 4163 | |
| 4164 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4165 | queryset = Payment.objects.select_related().all() |
| 4166 | serializer_class = PaymentSerializer |
| 4167 | id_serializer_class = PaymentIdSerializer |
| 4168 | |
| 4169 | def get_serializer_class(self): |
| 4170 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4171 | if (no_hyperlinks): |
| 4172 | return self.id_serializer_class |
| 4173 | else: |
| 4174 | return self.serializer_class |
| 4175 | |
| 4176 | def get_queryset(self): |
| 4177 | return Payment.select_by_user(self.request.user) |
| 4178 | |
| 4179 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4180 | |
| 4181 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4182 | |
| 4183 | |
| 4184 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4185 | class NetworkSliceList(generics.ListCreateAPIView): |
| 4186 | queryset = NetworkSlice.objects.select_related().all() |
| 4187 | serializer_class = NetworkSliceSerializer |
| 4188 | id_serializer_class = NetworkSliceIdSerializer |
| 4189 | filter_backends = (filters.DjangoFilterBackend,) |
| 4190 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 4191 | |
| 4192 | def get_serializer_class(self): |
| 4193 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4194 | if (no_hyperlinks): |
| 4195 | return self.id_serializer_class |
| 4196 | else: |
| 4197 | return self.serializer_class |
| 4198 | |
| 4199 | def get_queryset(self): |
| 4200 | return NetworkSlice.select_by_user(self.request.user) |
| 4201 | |
| 4202 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4203 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4204 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4205 | response = {"error": "validation", |
| 4206 | "specific_error": "not serializer.is_valid()",
|
| 4207 | "reasons": serializer.errors}
|
| 4208 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4209 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4210 | obj.caller = request.user |
| 4211 | if obj.can_update(request.user): |
| 4212 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4213 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4214 | raise Exception("failed obj.can_update") |
| 4215 | |
| 4216 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4217 | if (ret.status_code%100 != 200): |
| 4218 | raise Exception(ret.data) |
| 4219 | |
| 4220 | return ret |
| 4221 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4222 | |
| 4223 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4224 | queryset = NetworkSlice.objects.select_related().all() |
| 4225 | serializer_class = NetworkSliceSerializer |
| 4226 | id_serializer_class = NetworkSliceIdSerializer |
| 4227 | |
| 4228 | def get_serializer_class(self): |
| 4229 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4230 | if (no_hyperlinks): |
| 4231 | return self.id_serializer_class |
| 4232 | else: |
| 4233 | return self.serializer_class |
| 4234 | |
| 4235 | def get_queryset(self): |
| 4236 | return NetworkSlice.select_by_user(self.request.user) |
| 4237 | |
| 4238 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4239 | |
| 4240 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4241 | |
| 4242 | |
| 4243 | |
| 4244 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 4245 | queryset = UserDashboardView.objects.select_related().all() |
| 4246 | serializer_class = UserDashboardViewSerializer |
| 4247 | id_serializer_class = UserDashboardViewIdSerializer |
| 4248 | filter_backends = (filters.DjangoFilterBackend,) |
| 4249 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 4250 | |
| 4251 | def get_serializer_class(self): |
| 4252 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4253 | if (no_hyperlinks): |
| 4254 | return self.id_serializer_class |
| 4255 | else: |
| 4256 | return self.serializer_class |
| 4257 | |
| 4258 | def get_queryset(self): |
| 4259 | return UserDashboardView.select_by_user(self.request.user) |
| 4260 | |
| 4261 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4262 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4263 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4264 | response = {"error": "validation", |
| 4265 | "specific_error": "not serializer.is_valid()",
|
| 4266 | "reasons": serializer.errors}
|
| 4267 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4268 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4269 | obj.caller = request.user |
| 4270 | if obj.can_update(request.user): |
| 4271 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4272 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4273 | raise Exception("failed obj.can_update") |
| 4274 | |
| 4275 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4276 | if (ret.status_code%100 != 200): |
| 4277 | raise Exception(ret.data) |
| 4278 | |
| 4279 | return ret |
| 4280 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4281 | |
| 4282 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4283 | queryset = UserDashboardView.objects.select_related().all() |
| 4284 | serializer_class = UserDashboardViewSerializer |
| 4285 | id_serializer_class = UserDashboardViewIdSerializer |
| 4286 | |
| 4287 | def get_serializer_class(self): |
| 4288 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4289 | if (no_hyperlinks): |
| 4290 | return self.id_serializer_class |
| 4291 | else: |
| 4292 | return self.serializer_class |
| 4293 | |
| 4294 | def get_queryset(self): |
| 4295 | return UserDashboardView.select_by_user(self.request.user) |
| 4296 | |
| 4297 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4298 | |
| 4299 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4300 | |
| 4301 | |
| 4302 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4303 | class ControllerList(generics.ListCreateAPIView): |
| 4304 | queryset = Controller.objects.select_related().all() |
| 4305 | serializer_class = ControllerSerializer |
| 4306 | id_serializer_class = ControllerIdSerializer |
| 4307 | filter_backends = (filters.DjangoFilterBackend,) |
| 4308 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 4309 | |
| 4310 | def get_serializer_class(self): |
| 4311 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4312 | if (no_hyperlinks): |
| 4313 | return self.id_serializer_class |
| 4314 | else: |
| 4315 | return self.serializer_class |
| 4316 | |
| 4317 | def get_queryset(self): |
| 4318 | return Controller.select_by_user(self.request.user) |
| 4319 | |
| 4320 | def create(self, request, *args, **kwargs): |
| 4321 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4322 | if not (serializer.is_valid()): |
| 4323 | response = {"error": "validation", |
| 4324 | "specific_error": "not serializer.is_valid()",
|
| 4325 | "reasons": serializer.errors}
|
| 4326 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4327 | obj = serializer.object |
| 4328 | obj.caller = request.user |
| 4329 | if obj.can_update(request.user): |
| 4330 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4331 | else: |
| 4332 | raise Exception("failed obj.can_update") |
| 4333 | |
| 4334 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 4335 | if (ret.status_code%100 != 200): |
| 4336 | raise Exception(ret.data) |
| 4337 | |
| 4338 | return ret |
| 4339 | |
| 4340 | |
| 4341 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4342 | queryset = Controller.objects.select_related().all() |
| 4343 | serializer_class = ControllerSerializer |
| 4344 | id_serializer_class = ControllerIdSerializer |
| 4345 | |
| 4346 | def get_serializer_class(self): |
| 4347 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4348 | if (no_hyperlinks): |
| 4349 | return self.id_serializer_class |
| 4350 | else: |
| 4351 | return self.serializer_class |
| 4352 | |
| 4353 | def get_queryset(self): |
| 4354 | return Controller.select_by_user(self.request.user) |
| 4355 | |
| 4356 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4357 | |
| 4358 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4359 | |
| 4360 | |
| 4361 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4362 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 4363 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4364 | serializer_class = PlanetStackPrivilegeSerializer |
| 4365 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4366 | filter_backends = (filters.DjangoFilterBackend,) |
| 4367 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 4368 | |
| 4369 | def get_serializer_class(self): |
| 4370 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4371 | if (no_hyperlinks): |
| 4372 | return self.id_serializer_class |
| 4373 | else: |
| 4374 | return self.serializer_class |
| 4375 | |
| 4376 | def get_queryset(self): |
| 4377 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4378 | |
| 4379 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4380 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4381 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4382 | response = {"error": "validation", |
| 4383 | "specific_error": "not serializer.is_valid()",
|
| 4384 | "reasons": serializer.errors}
|
| 4385 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4386 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4387 | obj.caller = request.user |
| 4388 | if obj.can_update(request.user): |
| 4389 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4390 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4391 | raise Exception("failed obj.can_update") |
| 4392 | |
| 4393 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4394 | if (ret.status_code%100 != 200): |
| 4395 | raise Exception(ret.data) |
| 4396 | |
| 4397 | return ret |
| 4398 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4399 | |
| 4400 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4401 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4402 | serializer_class = PlanetStackPrivilegeSerializer |
| 4403 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4404 | |
| 4405 | def get_serializer_class(self): |
| 4406 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4407 | if (no_hyperlinks): |
| 4408 | return self.id_serializer_class |
| 4409 | else: |
| 4410 | return self.serializer_class |
| 4411 | |
| 4412 | def get_queryset(self): |
| 4413 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4414 | |
| 4415 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4416 | |
| 4417 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4418 | |
| 4419 | |
| 4420 | |
| 4421 | class UserList(generics.ListCreateAPIView): |
| 4422 | queryset = User.objects.select_related().all() |
| 4423 | serializer_class = UserSerializer |
| 4424 | id_serializer_class = UserIdSerializer |
| 4425 | filter_backends = (filters.DjangoFilterBackend,) |
| 4426 | 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',) |
| 4427 | |
| 4428 | def get_serializer_class(self): |
| 4429 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4430 | if (no_hyperlinks): |
| 4431 | return self.id_serializer_class |
| 4432 | else: |
| 4433 | return self.serializer_class |
| 4434 | |
| 4435 | def get_queryset(self): |
| 4436 | return User.select_by_user(self.request.user) |
| 4437 | |
| 4438 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4439 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4440 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4441 | response = {"error": "validation", |
| 4442 | "specific_error": "not serializer.is_valid()",
|
| 4443 | "reasons": serializer.errors}
|
| 4444 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4445 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4446 | obj.caller = request.user |
| 4447 | if obj.can_update(request.user): |
| 4448 | return super(UserList, self).create(request, *args, **kwargs) |
| 4449 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4450 | raise Exception("failed obj.can_update") |
| 4451 | |
| 4452 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 4453 | if (ret.status_code%100 != 200): |
| 4454 | raise Exception(ret.data) |
| 4455 | |
| 4456 | return ret |
| 4457 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4458 | |
| 4459 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4460 | queryset = User.objects.select_related().all() |
| 4461 | serializer_class = UserSerializer |
| 4462 | id_serializer_class = UserIdSerializer |
| 4463 | |
| 4464 | def get_serializer_class(self): |
| 4465 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4466 | if (no_hyperlinks): |
| 4467 | return self.id_serializer_class |
| 4468 | else: |
| 4469 | return self.serializer_class |
| 4470 | |
| 4471 | def get_queryset(self): |
| 4472 | return User.select_by_user(self.request.user) |
| 4473 | |
| 4474 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4475 | |
| 4476 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4477 | |
| 4478 | |
| 4479 | |
| 4480 | class DeploymentList(generics.ListCreateAPIView): |
| 4481 | queryset = Deployment.objects.select_related().all() |
| 4482 | serializer_class = DeploymentSerializer |
| 4483 | id_serializer_class = DeploymentIdSerializer |
| 4484 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 93a79a9 | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 4485 | 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] | 4486 | |
| 4487 | def get_serializer_class(self): |
| 4488 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4489 | if (no_hyperlinks): |
| 4490 | return self.id_serializer_class |
| 4491 | else: |
| 4492 | return self.serializer_class |
| 4493 | |
| 4494 | def get_queryset(self): |
| 4495 | return Deployment.select_by_user(self.request.user) |
| 4496 | |
| 4497 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4498 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4499 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4500 | response = {"error": "validation", |
| 4501 | "specific_error": "not serializer.is_valid()",
|
| 4502 | "reasons": serializer.errors}
|
| 4503 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4504 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4505 | obj.caller = request.user |
| 4506 | if obj.can_update(request.user): |
| 4507 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 4508 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4509 | raise Exception("failed obj.can_update") |
| 4510 | |
| 4511 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 4512 | if (ret.status_code%100 != 200): |
| 4513 | raise Exception(ret.data) |
| 4514 | |
| 4515 | return ret |
| 4516 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4517 | |
| 4518 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4519 | queryset = Deployment.objects.select_related().all() |
| 4520 | serializer_class = DeploymentSerializer |
| 4521 | id_serializer_class = DeploymentIdSerializer |
| 4522 | |
| 4523 | def get_serializer_class(self): |
| 4524 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4525 | if (no_hyperlinks): |
| 4526 | return self.id_serializer_class |
| 4527 | else: |
| 4528 | return self.serializer_class |
| 4529 | |
| 4530 | def get_queryset(self): |
| 4531 | return Deployment.select_by_user(self.request.user) |
| 4532 | |
| 4533 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4534 | |
| 4535 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4536 | |
| 4537 | |
| 4538 | |
| 4539 | class ReservationList(generics.ListCreateAPIView): |
| 4540 | queryset = Reservation.objects.select_related().all() |
| 4541 | serializer_class = ReservationSerializer |
| 4542 | id_serializer_class = ReservationIdSerializer |
| 4543 | filter_backends = (filters.DjangoFilterBackend,) |
| 4544 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 4545 | |
| 4546 | def get_serializer_class(self): |
| 4547 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4548 | if (no_hyperlinks): |
| 4549 | return self.id_serializer_class |
| 4550 | else: |
| 4551 | return self.serializer_class |
| 4552 | |
| 4553 | def get_queryset(self): |
| 4554 | return Reservation.select_by_user(self.request.user) |
| 4555 | |
| 4556 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4557 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4558 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4559 | response = {"error": "validation", |
| 4560 | "specific_error": "not serializer.is_valid()",
|
| 4561 | "reasons": serializer.errors}
|
| 4562 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4563 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4564 | obj.caller = request.user |
| 4565 | if obj.can_update(request.user): |
| 4566 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 4567 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4568 | raise Exception("failed obj.can_update") |
| 4569 | |
| 4570 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 4571 | if (ret.status_code%100 != 200): |
| 4572 | raise Exception(ret.data) |
| 4573 | |
| 4574 | return ret |
| 4575 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4576 | |
| 4577 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4578 | queryset = Reservation.objects.select_related().all() |
| 4579 | serializer_class = ReservationSerializer |
| 4580 | id_serializer_class = ReservationIdSerializer |
| 4581 | |
| 4582 | def get_serializer_class(self): |
| 4583 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4584 | if (no_hyperlinks): |
| 4585 | return self.id_serializer_class |
| 4586 | else: |
| 4587 | return self.serializer_class |
| 4588 | |
| 4589 | def get_queryset(self): |
| 4590 | return Reservation.select_by_user(self.request.user) |
| 4591 | |
| 4592 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4593 | |
| 4594 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4595 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4596 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4597 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4598 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 4599 | queryset = SitePrivilege.objects.select_related().all() |
| 4600 | serializer_class = SitePrivilegeSerializer |
| 4601 | id_serializer_class = SitePrivilegeIdSerializer |
| 4602 | filter_backends = (filters.DjangoFilterBackend,) |
| 4603 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 4604 | |
| 4605 | def get_serializer_class(self): |
| 4606 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4607 | if (no_hyperlinks): |
| 4608 | return self.id_serializer_class |
| 4609 | else: |
| 4610 | return self.serializer_class |
| 4611 | |
| 4612 | def get_queryset(self): |
| 4613 | return SitePrivilege.select_by_user(self.request.user) |
| 4614 | |
| 4615 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4616 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4617 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4618 | response = {"error": "validation", |
| 4619 | "specific_error": "not serializer.is_valid()",
|
| 4620 | "reasons": serializer.errors}
|
| 4621 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4622 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4623 | obj.caller = request.user |
| 4624 | if obj.can_update(request.user): |
| 4625 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4626 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4627 | raise Exception("failed obj.can_update") |
| 4628 | |
| 4629 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4630 | if (ret.status_code%100 != 200): |
| 4631 | raise Exception(ret.data) |
| 4632 | |
| 4633 | return ret |
| 4634 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4635 | |
| 4636 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4637 | queryset = SitePrivilege.objects.select_related().all() |
| 4638 | serializer_class = SitePrivilegeSerializer |
| 4639 | id_serializer_class = SitePrivilegeIdSerializer |
| 4640 | |
| 4641 | def get_serializer_class(self): |
| 4642 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4643 | if (no_hyperlinks): |
| 4644 | return self.id_serializer_class |
| 4645 | else: |
| 4646 | return self.serializer_class |
| 4647 | |
| 4648 | def get_queryset(self): |
| 4649 | return SitePrivilege.select_by_user(self.request.user) |
| 4650 | |
| 4651 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4652 | |
| 4653 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4654 | |
| 4655 | |
| 4656 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4657 | class PlanetStackList(generics.ListCreateAPIView): |
| 4658 | queryset = PlanetStack.objects.select_related().all() |
| 4659 | serializer_class = PlanetStackSerializer |
| 4660 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4661 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4662 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4663 | |
| 4664 | def get_serializer_class(self): |
| 4665 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4666 | if (no_hyperlinks): |
| 4667 | return self.id_serializer_class |
| 4668 | else: |
| 4669 | return self.serializer_class |
| 4670 | |
| 4671 | def get_queryset(self): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4672 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4673 | |
| 4674 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4675 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4676 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4677 | response = {"error": "validation", |
| 4678 | "specific_error": "not serializer.is_valid()",
|
| 4679 | "reasons": serializer.errors}
|
| 4680 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4681 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4682 | obj.caller = request.user |
| 4683 | if obj.can_update(request.user): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4684 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4685 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4686 | raise Exception("failed obj.can_update") |
| 4687 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4688 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4689 | if (ret.status_code%100 != 200): |
| 4690 | raise Exception(ret.data) |
| 4691 | |
| 4692 | return ret |
| 4693 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4694 | |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4695 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4696 | queryset = PlanetStack.objects.select_related().all() |
| 4697 | serializer_class = PlanetStackSerializer |
| 4698 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4699 | |
| 4700 | def get_serializer_class(self): |
| 4701 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4702 | if (no_hyperlinks): |
| 4703 | return self.id_serializer_class |
| 4704 | else: |
| 4705 | return self.serializer_class |
| 4706 | |
| 4707 | def get_queryset(self): |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4708 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4709 | |
| 4710 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4711 | |
| 4712 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4713 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4714 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4715 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 4716 | class ControllerDashboardViewList(generics.ListCreateAPIView): |
| 4717 | queryset = ControllerDashboardView.objects.select_related().all() |
| 4718 | serializer_class = ControllerDashboardViewSerializer |
| 4719 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 4720 | filter_backends = (filters.DjangoFilterBackend,) |
| 4721 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 4722 | |
| 4723 | def get_serializer_class(self): |
| 4724 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4725 | if (no_hyperlinks): |
| 4726 | return self.id_serializer_class |
| 4727 | else: |
| 4728 | return self.serializer_class |
| 4729 | |
| 4730 | def get_queryset(self): |
| 4731 | return ControllerDashboardView.select_by_user(self.request.user) |
| 4732 | |
| 4733 | def create(self, request, *args, **kwargs): |
| 4734 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4735 | if not (serializer.is_valid()): |
| 4736 | response = {"error": "validation", |
| 4737 | "specific_error": "not serializer.is_valid()",
|
| 4738 | "reasons": serializer.errors}
|
| 4739 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4740 | obj = serializer.object |
| 4741 | obj.caller = request.user |
| 4742 | if obj.can_update(request.user): |
| 4743 | return super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 4744 | else: |
| 4745 | raise Exception("failed obj.can_update") |
| 4746 | |
| 4747 | ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 4748 | if (ret.status_code%100 != 200): |
| 4749 | raise Exception(ret.data) |
| 4750 | |
| 4751 | return ret |
| 4752 | |
| 4753 | |
| 4754 | class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4755 | queryset = ControllerDashboardView.objects.select_related().all() |
| 4756 | serializer_class = ControllerDashboardViewSerializer |
| 4757 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 4758 | |
| 4759 | def get_serializer_class(self): |
| 4760 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4761 | if (no_hyperlinks): |
| 4762 | return self.id_serializer_class |
| 4763 | else: |
| 4764 | return self.serializer_class |
| 4765 | |
| 4766 | def get_queryset(self): |
| 4767 | return ControllerDashboardView.select_by_user(self.request.user) |
| 4768 | |
| 4769 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4770 | |
| 4771 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4772 | |
| 4773 | |
| 4774 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4775 | class AccountList(generics.ListCreateAPIView): |
| 4776 | queryset = Account.objects.select_related().all() |
| 4777 | serializer_class = AccountSerializer |
| 4778 | id_serializer_class = AccountIdSerializer |
| 4779 | filter_backends = (filters.DjangoFilterBackend,) |
| 4780 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 4781 | |
| 4782 | def get_serializer_class(self): |
| 4783 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4784 | if (no_hyperlinks): |
| 4785 | return self.id_serializer_class |
| 4786 | else: |
| 4787 | return self.serializer_class |
| 4788 | |
| 4789 | def get_queryset(self): |
| 4790 | return Account.select_by_user(self.request.user) |
| 4791 | |
| 4792 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4793 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4794 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4795 | response = {"error": "validation", |
| 4796 | "specific_error": "not serializer.is_valid()",
|
| 4797 | "reasons": serializer.errors}
|
| 4798 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4799 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4800 | obj.caller = request.user |
| 4801 | if obj.can_update(request.user): |
| 4802 | return super(AccountList, self).create(request, *args, **kwargs) |
| 4803 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4804 | raise Exception("failed obj.can_update") |
| 4805 | |
| 4806 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 4807 | if (ret.status_code%100 != 200): |
| 4808 | raise Exception(ret.data) |
| 4809 | |
| 4810 | return ret |
| 4811 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4812 | |
| 4813 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4814 | queryset = Account.objects.select_related().all() |
| 4815 | serializer_class = AccountSerializer |
| 4816 | id_serializer_class = AccountIdSerializer |
| 4817 | |
| 4818 | def get_serializer_class(self): |
| 4819 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4820 | if (no_hyperlinks): |
| 4821 | return self.id_serializer_class |
| 4822 | else: |
| 4823 | return self.serializer_class |
| 4824 | |
| 4825 | def get_queryset(self): |
| 4826 | return Account.select_by_user(self.request.user) |
| 4827 | |
| 4828 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4829 | |
| 4830 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4831 | |
| 4832 | |
| 4833 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4834 | class ControllerRoleList(generics.ListCreateAPIView): |
| 4835 | queryset = ControllerRole.objects.select_related().all() |
| 4836 | serializer_class = ControllerRoleSerializer |
| 4837 | id_serializer_class = ControllerRoleIdSerializer |
| 4838 | filter_backends = (filters.DjangoFilterBackend,) |
| 4839 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 4840 | |
| 4841 | def get_serializer_class(self): |
| 4842 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4843 | if (no_hyperlinks): |
| 4844 | return self.id_serializer_class |
| 4845 | else: |
| 4846 | return self.serializer_class |
| 4847 | |
| 4848 | def get_queryset(self): |
| 4849 | return ControllerRole.select_by_user(self.request.user) |
| 4850 | |
| 4851 | def create(self, request, *args, **kwargs): |
| 4852 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4853 | if not (serializer.is_valid()): |
| 4854 | response = {"error": "validation", |
| 4855 | "specific_error": "not serializer.is_valid()",
|
| 4856 | "reasons": serializer.errors}
|
| 4857 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4858 | obj = serializer.object |
| 4859 | obj.caller = request.user |
| 4860 | if obj.can_update(request.user): |
| 4861 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 4862 | else: |
| 4863 | raise Exception("failed obj.can_update") |
| 4864 | |
| 4865 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 4866 | if (ret.status_code%100 != 200): |
| 4867 | raise Exception(ret.data) |
| 4868 | |
| 4869 | return ret |
| 4870 | |
| 4871 | |
| 4872 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4873 | queryset = ControllerRole.objects.select_related().all() |
| 4874 | serializer_class = ControllerRoleSerializer |
| 4875 | id_serializer_class = ControllerRoleIdSerializer |
| 4876 | |
| 4877 | def get_serializer_class(self): |
| 4878 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4879 | if (no_hyperlinks): |
| 4880 | return self.id_serializer_class |
| 4881 | else: |
| 4882 | return self.serializer_class |
| 4883 | |
| 4884 | def get_queryset(self): |
| 4885 | return ControllerRole.select_by_user(self.request.user) |
| 4886 | |
| 4887 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4888 | |
| 4889 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4890 | |
| 4891 | |
| 4892 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4893 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 4894 | queryset = NetworkParameterType.objects.select_related().all() |
| 4895 | serializer_class = NetworkParameterTypeSerializer |
| 4896 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 4897 | filter_backends = (filters.DjangoFilterBackend,) |
| 4898 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 4899 | |
| 4900 | def get_serializer_class(self): |
| 4901 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4902 | if (no_hyperlinks): |
| 4903 | return self.id_serializer_class |
| 4904 | else: |
| 4905 | return self.serializer_class |
| 4906 | |
| 4907 | def get_queryset(self): |
| 4908 | return NetworkParameterType.select_by_user(self.request.user) |
| 4909 | |
| 4910 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4911 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4912 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4913 | response = {"error": "validation", |
| 4914 | "specific_error": "not serializer.is_valid()",
|
| 4915 | "reasons": serializer.errors}
|
| 4916 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4917 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4918 | obj.caller = request.user |
| 4919 | if obj.can_update(request.user): |
| 4920 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 4921 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4922 | raise Exception("failed obj.can_update") |
| 4923 | |
| 4924 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 4925 | if (ret.status_code%100 != 200): |
| 4926 | raise Exception(ret.data) |
| 4927 | |
| 4928 | return ret |
| 4929 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4930 | |
| 4931 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4932 | queryset = NetworkParameterType.objects.select_related().all() |
| 4933 | serializer_class = NetworkParameterTypeSerializer |
| 4934 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 4935 | |
| 4936 | def get_serializer_class(self): |
| 4937 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4938 | if (no_hyperlinks): |
| 4939 | return self.id_serializer_class |
| 4940 | else: |
| 4941 | return self.serializer_class |
| 4942 | |
| 4943 | def get_queryset(self): |
| 4944 | return NetworkParameterType.select_by_user(self.request.user) |
| 4945 | |
| 4946 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4947 | |
| 4948 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4949 | |
| 4950 | |
| 4951 | |
| 4952 | class SiteCredentialList(generics.ListCreateAPIView): |
| 4953 | queryset = SiteCredential.objects.select_related().all() |
| 4954 | serializer_class = SiteCredentialSerializer |
| 4955 | id_serializer_class = SiteCredentialIdSerializer |
| 4956 | filter_backends = (filters.DjangoFilterBackend,) |
| 4957 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 4958 | |
| 4959 | def get_serializer_class(self): |
| 4960 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4961 | if (no_hyperlinks): |
| 4962 | return self.id_serializer_class |
| 4963 | else: |
| 4964 | return self.serializer_class |
| 4965 | |
| 4966 | def get_queryset(self): |
| 4967 | return SiteCredential.select_by_user(self.request.user) |
| 4968 | |
| 4969 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4970 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4971 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4972 | response = {"error": "validation", |
| 4973 | "specific_error": "not serializer.is_valid()",
|
| 4974 | "reasons": serializer.errors}
|
| 4975 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4976 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4977 | obj.caller = request.user |
| 4978 | if obj.can_update(request.user): |
| 4979 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 4980 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4981 | raise Exception("failed obj.can_update") |
| 4982 | |
| 4983 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 4984 | if (ret.status_code%100 != 200): |
| 4985 | raise Exception(ret.data) |
| 4986 | |
| 4987 | return ret |
| 4988 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4989 | |
| 4990 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4991 | queryset = SiteCredential.objects.select_related().all() |
| 4992 | serializer_class = SiteCredentialSerializer |
| 4993 | id_serializer_class = SiteCredentialIdSerializer |
| 4994 | |
| 4995 | def get_serializer_class(self): |
| 4996 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4997 | if (no_hyperlinks): |
| 4998 | return self.id_serializer_class |
| 4999 | else: |
| 5000 | return self.serializer_class |
| 5001 | |
| 5002 | def get_queryset(self): |
| 5003 | return SiteCredential.select_by_user(self.request.user) |
| 5004 | |
| 5005 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5006 | |
| 5007 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5008 | |
| 5009 | |
| 5010 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5011 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 5012 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5013 | serializer_class = DeploymentPrivilegeSerializer |
| 5014 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5015 | filter_backends = (filters.DjangoFilterBackend,) |
| 5016 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 5017 | |
| 5018 | def get_serializer_class(self): |
| 5019 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5020 | if (no_hyperlinks): |
| 5021 | return self.id_serializer_class |
| 5022 | else: |
| 5023 | return self.serializer_class |
| 5024 | |
| 5025 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5026 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5027 | |
| 5028 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5029 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5030 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5031 | response = {"error": "validation", |
| 5032 | "specific_error": "not serializer.is_valid()",
|
| 5033 | "reasons": serializer.errors}
|
| 5034 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5035 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5036 | obj.caller = request.user |
| 5037 | if obj.can_update(request.user): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5038 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5039 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5040 | raise Exception("failed obj.can_update") |
| 5041 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5042 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5043 | if (ret.status_code%100 != 200): |
| 5044 | raise Exception(ret.data) |
| 5045 | |
| 5046 | return ret |
| 5047 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5048 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5049 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5050 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5051 | serializer_class = DeploymentPrivilegeSerializer |
| 5052 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5053 | |
| 5054 | def get_serializer_class(self): |
| 5055 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5056 | if (no_hyperlinks): |
| 5057 | return self.id_serializer_class |
| 5058 | else: |
| 5059 | return self.serializer_class |
| 5060 | |
| 5061 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5062 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5063 | |
| 5064 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5065 | |
| 5066 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5067 | |
| 5068 | |
| 5069 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5070 | class ControllerUserList(generics.ListCreateAPIView): |
| 5071 | queryset = ControllerUser.objects.select_related().all() |
| 5072 | serializer_class = ControllerUserSerializer |
| 5073 | id_serializer_class = ControllerUserIdSerializer |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5074 | filter_backends = (filters.DjangoFilterBackend,) |
| 5075 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 5076 | |
| 5077 | def get_serializer_class(self): |
| 5078 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5079 | if (no_hyperlinks): |
| 5080 | return self.id_serializer_class |
| 5081 | else: |
| 5082 | return self.serializer_class |
| 5083 | |
| 5084 | def get_queryset(self): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5085 | return ControllerUser.select_by_user(self.request.user) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5086 | |
| 5087 | def create(self, request, *args, **kwargs): |
| 5088 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5089 | if not (serializer.is_valid()): |
| 5090 | response = {"error": "validation", |
| 5091 | "specific_error": "not serializer.is_valid()",
|
| 5092 | "reasons": serializer.errors}
|
| 5093 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5094 | obj = serializer.object |
| 5095 | obj.caller = request.user |
| 5096 | if obj.can_update(request.user): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5097 | return super(ControllerUserList, self).create(request, *args, **kwargs) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5098 | else: |
| 5099 | raise Exception("failed obj.can_update") |
| 5100 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5101 | ret = super(ControllerUserList, self).create(request, *args, **kwargs) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5102 | if (ret.status_code%100 != 200): |
| 5103 | raise Exception(ret.data) |
| 5104 | |
| 5105 | return ret |
| 5106 | |
| 5107 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5108 | class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5109 | queryset = ControllerUser.objects.select_related().all() |
| 5110 | serializer_class = ControllerUserSerializer |
| 5111 | id_serializer_class = ControllerUserIdSerializer |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5112 | |
| 5113 | def get_serializer_class(self): |
| 5114 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5115 | if (no_hyperlinks): |
| 5116 | return self.id_serializer_class |
| 5117 | else: |
| 5118 | return self.serializer_class |
| 5119 | |
| 5120 | def get_queryset(self): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5121 | return ControllerUser.select_by_user(self.request.user) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5122 | |
| 5123 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5124 | |
| 5125 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5126 | |
| 5127 | |
| 5128 | |
| 5129 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 5130 | queryset = DeploymentRole.objects.select_related().all() |
| 5131 | serializer_class = DeploymentRoleSerializer |
| 5132 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5133 | filter_backends = (filters.DjangoFilterBackend,) |
| 5134 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5135 | |
| 5136 | def get_serializer_class(self): |
| 5137 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5138 | if (no_hyperlinks): |
| 5139 | return self.id_serializer_class |
| 5140 | else: |
| 5141 | return self.serializer_class |
| 5142 | |
| 5143 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5144 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5145 | |
| 5146 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5147 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5148 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5149 | response = {"error": "validation", |
| 5150 | "specific_error": "not serializer.is_valid()",
|
| 5151 | "reasons": serializer.errors}
|
| 5152 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5153 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5154 | obj.caller = request.user |
| 5155 | if obj.can_update(request.user): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5156 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5157 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5158 | raise Exception("failed obj.can_update") |
| 5159 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5160 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5161 | if (ret.status_code%100 != 200): |
| 5162 | raise Exception(ret.data) |
| 5163 | |
| 5164 | return ret |
| 5165 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5166 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5167 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5168 | queryset = DeploymentRole.objects.select_related().all() |
| 5169 | serializer_class = DeploymentRoleSerializer |
| 5170 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5171 | |
| 5172 | def get_serializer_class(self): |
| 5173 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5174 | if (no_hyperlinks): |
| 5175 | return self.id_serializer_class |
| 5176 | else: |
| 5177 | return self.serializer_class |
| 5178 | |
| 5179 | def get_queryset(self): |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5180 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5181 | |
| 5182 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5183 | |
| 5184 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5185 | |
| 5186 | |
| 5187 | |
| 5188 | class UserCredentialList(generics.ListCreateAPIView): |
| 5189 | queryset = UserCredential.objects.select_related().all() |
| 5190 | serializer_class = UserCredentialSerializer |
| 5191 | id_serializer_class = UserCredentialIdSerializer |
| 5192 | filter_backends = (filters.DjangoFilterBackend,) |
| 5193 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 5194 | |
| 5195 | def get_serializer_class(self): |
| 5196 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5197 | if (no_hyperlinks): |
| 5198 | return self.id_serializer_class |
| 5199 | else: |
| 5200 | return self.serializer_class |
| 5201 | |
| 5202 | def get_queryset(self): |
| 5203 | return UserCredential.select_by_user(self.request.user) |
| 5204 | |
| 5205 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5206 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5207 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5208 | response = {"error": "validation", |
| 5209 | "specific_error": "not serializer.is_valid()",
|
| 5210 | "reasons": serializer.errors}
|
| 5211 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5212 | obj = serializer.object |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5213 | obj.caller = request.user |
| 5214 | if obj.can_update(request.user): |
| 5215 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5216 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5217 | raise Exception("failed obj.can_update") |
| 5218 | |
| 5219 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5220 | if (ret.status_code%100 != 200): |
| 5221 | raise Exception(ret.data) |
| 5222 | |
| 5223 | return ret |
| 5224 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5225 | |
| 5226 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5227 | queryset = UserCredential.objects.select_related().all() |
| 5228 | serializer_class = UserCredentialSerializer |
| 5229 | id_serializer_class = UserCredentialIdSerializer |
| 5230 | |
| 5231 | def get_serializer_class(self): |
| 5232 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5233 | if (no_hyperlinks): |
| 5234 | return self.id_serializer_class |
| 5235 | else: |
| 5236 | return self.serializer_class |
| 5237 | |
| 5238 | def get_queryset(self): |
| 5239 | return UserCredential.select_by_user(self.request.user) |
| 5240 | |
| 5241 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5242 | |
| 5243 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5244 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5245 | |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5246 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5247 | class SiteDeploymentList(generics.ListCreateAPIView): |
| 5248 | queryset = SiteDeployment.objects.select_related().all() |
| 5249 | serializer_class = SiteDeploymentSerializer |
| 5250 | id_serializer_class = SiteDeploymentIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5251 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5252 | 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] | 5253 | |
| 5254 | def get_serializer_class(self): |
| 5255 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5256 | if (no_hyperlinks): |
| 5257 | return self.id_serializer_class |
| 5258 | else: |
| 5259 | return self.serializer_class |
| 5260 | |
| 5261 | def get_queryset(self): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5262 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5263 | |
| 5264 | def create(self, request, *args, **kwargs): |
| 5265 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5266 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5267 | response = {"error": "validation", |
| 5268 | "specific_error": "not serializer.is_valid()",
|
| 5269 | "reasons": serializer.errors}
|
| 5270 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5271 | obj = serializer.object |
| 5272 | obj.caller = request.user |
| 5273 | if obj.can_update(request.user): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5274 | return super(SiteDeploymentList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5275 | else: |
| 5276 | raise Exception("failed obj.can_update") |
| 5277 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5278 | ret = super(SiteDeploymentList, self).create(request, *args, **kwargs) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5279 | if (ret.status_code%100 != 200): |
| 5280 | raise Exception(ret.data) |
| 5281 | |
| 5282 | return ret |
| 5283 | |
| 5284 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5285 | class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5286 | queryset = SiteDeployment.objects.select_related().all() |
| 5287 | serializer_class = SiteDeploymentSerializer |
| 5288 | id_serializer_class = SiteDeploymentIdSerializer |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5289 | |
| 5290 | def get_serializer_class(self): |
| 5291 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5292 | if (no_hyperlinks): |
| 5293 | return self.id_serializer_class |
| 5294 | else: |
| 5295 | return self.serializer_class |
| 5296 | |
| 5297 | def get_queryset(self): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5298 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | 196ffef | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5299 | |
| 5300 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5301 | |
| 5302 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5303 | |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5304 | |
| 5305 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5306 | class SliceTagList(generics.ListCreateAPIView): |
| 5307 | queryset = SliceTag.objects.select_related().all() |
| 5308 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5309 | id_serializer_class = SliceTagIdSerializer |
| 5310 | filter_backends = (filters.DjangoFilterBackend,) |
| 5311 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 5312 | |
| 5313 | def get_serializer_class(self): |
| 5314 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5315 | if (no_hyperlinks): |
| 5316 | return self.id_serializer_class |
| 5317 | else: |
| 5318 | return self.serializer_class |
| 5319 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5320 | def get_queryset(self): |
| 5321 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5322 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5323 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5324 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5325 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5326 | response = {"error": "validation", |
| 5327 | "specific_error": "not serializer.is_valid()",
|
| 5328 | "reasons": serializer.errors}
|
| 5329 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5330 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5331 | obj.caller = request.user |
| 5332 | if obj.can_update(request.user): |
| 5333 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 5334 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5335 | raise Exception("failed obj.can_update") |
| 5336 | |
| 5337 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 5338 | if (ret.status_code%100 != 200): |
| 5339 | raise Exception(ret.data) |
| 5340 | |
| 5341 | return ret |
| 5342 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5343 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5344 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5345 | queryset = SliceTag.objects.select_related().all() |
| 5346 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5347 | id_serializer_class = SliceTagIdSerializer |
| 5348 | |
| 5349 | def get_serializer_class(self): |
| 5350 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5351 | if (no_hyperlinks): |
| 5352 | return self.id_serializer_class |
| 5353 | else: |
| 5354 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5355 | |
| 5356 | def get_queryset(self): |
| 5357 | return SliceTag.select_by_user(self.request.user) |
| 5358 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5359 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5360 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5361 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5362 | |
| 5363 | |
| 5364 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5365 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 5366 | queryset = NetworkTemplate.objects.select_related().all() |
| 5367 | serializer_class = NetworkTemplateSerializer |
| 5368 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5369 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 6c95840 | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 5370 | 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] | 5371 | |
| 5372 | def get_serializer_class(self): |
| 5373 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5374 | if (no_hyperlinks): |
| 5375 | return self.id_serializer_class |
| 5376 | else: |
| 5377 | return self.serializer_class |
| 5378 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5379 | def get_queryset(self): |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5380 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5381 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5382 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5383 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5384 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5385 | response = {"error": "validation", |
| 5386 | "specific_error": "not serializer.is_valid()",
|
| 5387 | "reasons": serializer.errors}
|
| 5388 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5389 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5390 | obj.caller = request.user |
| 5391 | if obj.can_update(request.user): |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5392 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5393 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5394 | raise Exception("failed obj.can_update") |
| 5395 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5396 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5397 | if (ret.status_code%100 != 200): |
| 5398 | raise Exception(ret.data) |
| 5399 | |
| 5400 | return ret |
| 5401 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5402 | |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5403 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5404 | queryset = NetworkTemplate.objects.select_related().all() |
| 5405 | serializer_class = NetworkTemplateSerializer |
| 5406 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5407 | |
| 5408 | def get_serializer_class(self): |
| 5409 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5410 | if (no_hyperlinks): |
| 5411 | return self.id_serializer_class |
| 5412 | else: |
| 5413 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5414 | |
| 5415 | def get_queryset(self): |
Scott Baker | a6a0c77 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5416 | return NetworkTemplate.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5417 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5418 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5419 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5420 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5421 | |
| 5422 | |
| 5423 | |
| 5424 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5425 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5426 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5427 | id_serializer_class = RouterIdSerializer |
| 5428 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5429 | 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] | 5430 | |
| 5431 | def get_serializer_class(self): |
| 5432 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5433 | if (no_hyperlinks): |
| 5434 | return self.id_serializer_class |
| 5435 | else: |
| 5436 | return self.serializer_class |
| 5437 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5438 | def get_queryset(self): |
| 5439 | return Router.select_by_user(self.request.user) |
| 5440 | |
| 5441 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5442 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5443 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5444 | response = {"error": "validation", |
| 5445 | "specific_error": "not serializer.is_valid()",
|
| 5446 | "reasons": serializer.errors}
|
| 5447 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5448 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5449 | obj.caller = request.user |
| 5450 | if obj.can_update(request.user): |
| 5451 | return super(RouterList, self).create(request, *args, **kwargs) |
| 5452 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5453 | raise Exception("failed obj.can_update") |
| 5454 | |
| 5455 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 5456 | if (ret.status_code%100 != 200): |
| 5457 | raise Exception(ret.data) |
| 5458 | |
| 5459 | return ret |
| 5460 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5461 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5462 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5463 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5464 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5465 | id_serializer_class = RouterIdSerializer |
| 5466 | |
| 5467 | def get_serializer_class(self): |
| 5468 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5469 | if (no_hyperlinks): |
| 5470 | return self.id_serializer_class |
| 5471 | else: |
| 5472 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5473 | |
| 5474 | def get_queryset(self): |
| 5475 | return Router.select_by_user(self.request.user) |
| 5476 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5477 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5478 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5479 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5480 | |
| 5481 | |
| 5482 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5483 | class ServiceResourceList(generics.ListCreateAPIView): |
| 5484 | queryset = ServiceResource.objects.select_related().all() |
| 5485 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5486 | id_serializer_class = ServiceResourceIdSerializer |
| 5487 | filter_backends = (filters.DjangoFilterBackend,) |
| 5488 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 5489 | |
| 5490 | def get_serializer_class(self): |
| 5491 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5492 | if (no_hyperlinks): |
| 5493 | return self.id_serializer_class |
| 5494 | else: |
| 5495 | return self.serializer_class |
| 5496 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5497 | def get_queryset(self): |
| 5498 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5499 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5500 | def create(self, request, *args, **kwargs): |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5501 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5502 | if not (serializer.is_valid()): |
Scott Baker | 351148c | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5503 | response = {"error": "validation", |
| 5504 | "specific_error": "not serializer.is_valid()",
|
| 5505 | "reasons": serializer.errors}
|
| 5506 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | f3816ac | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5507 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5508 | obj.caller = request.user |
| 5509 | if obj.can_update(request.user): |
| 5510 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5511 | else: |
Scott Baker | 08898c1 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5512 | raise Exception("failed obj.can_update") |
| 5513 | |
| 5514 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5515 | if (ret.status_code%100 != 200): |
| 5516 | raise Exception(ret.data) |
| 5517 | |
| 5518 | return ret |
| 5519 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5520 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5521 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5522 | queryset = ServiceResource.objects.select_related().all() |
| 5523 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5524 | id_serializer_class = ServiceResourceIdSerializer |
| 5525 | |
| 5526 | def get_serializer_class(self): |
| 5527 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5528 | if (no_hyperlinks): |
| 5529 | return self.id_serializer_class |
| 5530 | else: |
| 5531 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5532 | |
| 5533 | def get_queryset(self): |
| 5534 | return ServiceResource.select_by_user(self.request.user) |
| 5535 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5536 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5537 | |
Scott Baker | dcb9b5d | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5538 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5539 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5540 | |
| 5541 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5542 | class ControllerSliceList(generics.ListCreateAPIView): |
| 5543 | queryset = ControllerSlice.objects.select_related().all() |
| 5544 | serializer_class = ControllerSliceSerializer |
| 5545 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5546 | filter_backends = (filters.DjangoFilterBackend,) |
| 5547 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 5548 | |
| 5549 | def get_serializer_class(self): |
| 5550 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5551 | if (no_hyperlinks): |
| 5552 | return self.id_serializer_class |
| 5553 | else: |
| 5554 | return self.serializer_class |
| 5555 | |
| 5556 | def get_queryset(self): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5557 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5558 | |
| 5559 | def create(self, request, *args, **kwargs): |
| 5560 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5561 | if not (serializer.is_valid()): |
| 5562 | response = {"error": "validation", |
| 5563 | "specific_error": "not serializer.is_valid()",
|
| 5564 | "reasons": serializer.errors}
|
| 5565 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5566 | obj = serializer.object |
| 5567 | obj.caller = request.user |
| 5568 | if obj.can_update(request.user): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5569 | return super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5570 | else: |
| 5571 | raise Exception("failed obj.can_update") |
| 5572 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5573 | ret = super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5574 | if (ret.status_code%100 != 200): |
| 5575 | raise Exception(ret.data) |
| 5576 | |
| 5577 | return ret |
| 5578 | |
| 5579 | |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5580 | class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5581 | queryset = ControllerSlice.objects.select_related().all() |
| 5582 | serializer_class = ControllerSliceSerializer |
| 5583 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5584 | |
| 5585 | def get_serializer_class(self): |
| 5586 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5587 | if (no_hyperlinks): |
| 5588 | return self.id_serializer_class |
| 5589 | else: |
| 5590 | return self.serializer_class |
| 5591 | |
| 5592 | def get_queryset(self): |
Tony Mack | a7dbd42 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5593 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | c1d1191 | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5594 | |
| 5595 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5596 | |
| 5597 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5598 | |
| 5599 | |
| 5600 | |