Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1 | from rest_framework.decorators import api_view |
| 2 | from rest_framework.response import Response |
| 3 | from rest_framework.reverse import reverse |
| 4 | from rest_framework import serializers |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5 | from rest_framework import generics |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 7 | from rest_framework.generics import GenericAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 8 | from core.models import * |
| 9 | from django.forms import widgets |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 10 | from rest_framework import filters |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 11 | from django.conf.urls import patterns, url |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 12 | |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 13 | if hasattr(serializers, "ReadOnlyField"): |
| 14 | # rest_framework 3.x |
| 15 | IdField = serializers.ReadOnlyField |
| 16 | else: |
| 17 | # rest_framework 2.x |
| 18 | IdField = serializers.Field |
| 19 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 20 | """ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 21 | Schema of the generator object: |
| 22 | all: Set of all Model objects |
| 23 | all_if(regex): Set of Model objects that match regex |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 24 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 25 | Model object: |
| 26 | plural: English plural of object name |
| 27 | camel: CamelCase version of object name |
| 28 | refs: list of references to other Model objects |
| 29 | props: list of properties minus refs |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 30 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 31 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 32 | """ |
| 33 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 34 | def get_REST_patterns(): |
| 35 | return patterns('', |
| 36 | url(r'^plstackapi/$', api_root), |
| 37 | |
Scott Baker | 515dc9e | 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 | d51d0bd | 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 | 515dc9e | 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 | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 47 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 48 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
| 49 | |
| 50 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 51 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
| 52 | |
| 53 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 54 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
| 55 | |
| 56 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 57 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
| 58 | |
| 59 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 60 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
| 61 | |
| 62 | url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 63 | url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
| 64 | |
| 65 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 66 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
| 67 | |
| 68 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 69 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
| 70 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 71 | url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'), |
| 72 | url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'), |
| 73 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 74 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 75 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
| 76 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 77 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 78 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 79 | |
| 80 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 81 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 82 | |
| 83 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 84 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 85 | |
| 86 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 87 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 88 | |
| 89 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 90 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 91 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 92 | url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetworks-list'), |
| 93 | url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetworks-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 94 | |
| 95 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 96 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 97 | |
| 98 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 99 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 100 | |
| 101 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 102 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 103 | |
| 104 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 105 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 106 | |
| 107 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 108 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 109 | |
| 110 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 111 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 112 | |
| 113 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 114 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 115 | |
| 116 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 117 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 118 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 119 | url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 120 | url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 121 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 122 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 123 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 124 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 125 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 126 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 127 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 128 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 129 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 130 | |
| 131 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 132 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 133 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 134 | url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'), |
| 135 | url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
| 136 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 137 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 138 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 139 | |
| 140 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 141 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 142 | |
| 143 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 144 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
| 145 | |
| 146 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 147 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 148 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 149 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 150 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 151 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 152 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 153 | url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 154 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 155 | url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'), |
| 156 | url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'), |
| 157 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 158 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 159 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 160 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 161 | url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 162 | url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
| 163 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 164 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 165 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 166 | |
| 167 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 168 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 169 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 170 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 171 | url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 172 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 173 | url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controllerusers-list'), |
| 174 | url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controllerusers-detail'), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 175 | |
| 176 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 177 | url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 178 | |
| 179 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 180 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 181 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 182 | url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployments-list'), |
| 183 | url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployments-detail'), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 184 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 185 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 186 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 187 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 188 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 189 | url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 190 | |
| 191 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 192 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 193 | |
| 194 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 195 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 196 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 197 | url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslices-list'), |
| 198 | url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslices-detail'), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 199 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 200 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 201 | |
| 202 | @api_view(['GET']) |
| 203 | def api_root(request, format=None): |
| 204 | return Response({ |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 205 | 'flavors': reverse('flavor-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 206 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 207 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 208 | 'images': reverse('image-list', request=request, format=format), |
| 209 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 210 | 'sites': reverse('site-list', request=request, format=format), |
| 211 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 212 | 'tags': reverse('tag-list', request=request, format=format), |
| 213 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 214 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 215 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 216 | 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 217 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 218 | 'projects': reverse('project-list', request=request, format=format), |
| 219 | 'slices': reverse('slice-list', request=request, format=format), |
| 220 | 'networks': reverse('network-list', request=request, format=format), |
| 221 | 'services': reverse('service-list', request=request, format=format), |
| 222 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 223 | 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 224 | 'charges': reverse('charge-list', request=request, format=format), |
| 225 | 'roles': reverse('role-list', request=request, format=format), |
| 226 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 227 | 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 228 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 229 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 230 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 231 | 'nodes': reverse('node-list', request=request, format=format), |
| 232 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 233 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 234 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 235 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 236 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 237 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 238 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 239 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 240 | 'users': reverse('user-list', request=request, format=format), |
| 241 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 242 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 243 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 244 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 245 | 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 246 | 'accounts': reverse('account-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 247 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 248 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 249 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 250 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 251 | 'controlleruserses': reverse('controllerusers-list', request=request, format=format), |
| 252 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 253 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 254 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 255 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 256 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 257 | 'routers': reverse('router-list', request=request, format=format), |
| 258 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 259 | 'controllersliceses': reverse('controllerslices-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 260 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 261 | }) |
| 262 | |
| 263 | # Based on serializers.py |
| 264 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 265 | class XOSModelSerializer(serializers.ModelSerializer): |
| 266 | def save_object(self, obj, **kwargs): |
| 267 | |
| 268 | """ rest_framework can't deal with ManyToMany relations that have a |
| 269 | through table. In plstackapi, most of the through tables we have |
| 270 | use defaults or blank fields, so there's no reason why we shouldn't |
| 271 | be able to save these objects. |
| 272 | |
| 273 | So, let's strip out these m2m relations, and deal with them ourself. |
| 274 | """ |
| 275 | obj._complex_m2m_data={};
|
| 276 | if getattr(obj, '_m2m_data', None):
|
| 277 | for relatedObject in obj._meta.get_all_related_many_to_many_objects():
|
| 278 | if (relatedObject.field.rel.through._meta.auto_created):
|
| 279 | # These are non-trough ManyToMany relations and
|
| 280 | # can be updated just fine
|
| 281 | continue
|
| 282 | fieldName = relatedObject.get_accessor_name()
|
| 283 | if fieldName in obj._m2m_data.keys():
|
| 284 | obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
|
| 285 | del obj._m2m_data[fieldName]
|
| 286 |
|
| 287 | serializers.ModelSerializer.save_object(self, obj, **kwargs); |
| 288 | |
| 289 | for (accessor, stuff) in obj._complex_m2m_data.items(): |
| 290 | (relatedObject, data) = stuff |
| 291 | through = relatedObject.field.rel.through |
| 292 | local_fieldName = relatedObject.field.m2m_reverse_field_name() |
| 293 | remote_fieldName = relatedObject.field.m2m_field_name() |
| 294 | |
| 295 | # get the current set of existing relations |
| 296 | existing = through.objects.filter(**{local_fieldName: obj}); |
| 297 | |
| 298 | data_ids = [item.id for item in data] |
| 299 | existing_ids = [getattr(item,remote_fieldName).id for item in existing] |
| 300 | |
| 301 | #print "data_ids", data_ids |
| 302 | #print "existing_ids", existing_ids |
| 303 | |
| 304 | # remove relations that are in 'existing' but not in 'data' |
| 305 | for item in list(existing): |
| 306 | if (getattr(item,remote_fieldName).id not in data_ids): |
| 307 | print "delete", getattr(item,remote_fieldName) |
| 308 | item.delete() #(purge=True) |
| 309 | |
| 310 | # add relations that are in 'data' but not in 'existing' |
| 311 | for item in data: |
| 312 | if (item.id not in existing_ids): |
| 313 | #print "add", item |
| 314 | newModel = through(**{local_fieldName: obj, remote_fieldName: item}) |
| 315 | newModel.save() |
| 316 | |
| 317 | |
| 318 | |
| 319 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 320 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 321 | |
| 322 | |
| 323 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 324 | |
| 325 | |
| 326 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 327 | validators = serializers.SerializerMethodField("getValidators") |
| 328 | def getHumanReadableName(self, obj):
|
| 329 | return str(obj) |
| 330 | def getValidators(self, obj): |
| 331 | try: |
| 332 | return obj.getValidators() |
| 333 | except: |
| 334 | return None |
| 335 | class Meta: |
| 336 | model = Flavor |
| 337 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 338 | |
| 339 | class FlavorIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 340 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 341 | |
| 342 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 343 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 344 | |
| 345 | |
| 346 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 347 | validators = serializers.SerializerMethodField("getValidators") |
| 348 | def getHumanReadableName(self, obj):
|
| 349 | return str(obj)
|
| 350 | def getValidators(self, obj):
|
| 351 | try: |
| 352 | return obj.getValidators() |
| 353 | except: |
| 354 | return None
|
| 355 | class Meta:
|
| 356 | model = Flavor |
| 357 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 358 | |
| 359 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 360 | |
| 361 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 362 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 363 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 364 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 365 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 366 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 367 | def getHumanReadableName(self, obj):
|
| 368 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 369 | def getValidators(self, obj): |
| 370 | try: |
| 371 | return obj.getValidators() |
| 372 | except: |
| 373 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 374 | class Meta: |
| 375 | model = ServiceAttribute |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 376 | 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] | 377 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 378 | class ServiceAttributeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 379 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 380 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 381 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 382 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 383 | def getHumanReadableName(self, obj):
|
| 384 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 385 | def getValidators(self, obj):
|
| 386 | try: |
| 387 | return obj.getValidators() |
| 388 | except: |
| 389 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 390 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 391 | model = ServiceAttribute |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 392 | 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] | 393 | |
| 394 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 395 | |
| 396 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 397 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 398 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 399 | |
| 400 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 401 | validators = serializers.SerializerMethodField("getValidators") |
| 402 | def getHumanReadableName(self, obj):
|
| 403 | return str(obj) |
| 404 | def getValidators(self, obj): |
| 405 | try: |
| 406 | return obj.getValidators() |
| 407 | except: |
| 408 | return None |
| 409 | class Meta: |
| 410 | model = ControllerImages |
| 411 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 412 | |
| 413 | class ControllerImagesIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 414 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 415 | |
| 416 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 417 | validators = serializers.SerializerMethodField("getValidators") |
| 418 | def getHumanReadableName(self, obj):
|
| 419 | return str(obj)
|
| 420 | def getValidators(self, obj):
|
| 421 | try: |
| 422 | return obj.getValidators() |
| 423 | except: |
| 424 | return None
|
| 425 | class Meta:
|
| 426 | model = ControllerImages |
| 427 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 432 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 433 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 434 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 435 | |
| 436 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 437 | |
| 438 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 439 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 440 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 441 | def getHumanReadableName(self, obj):
|
| 442 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 443 | def getValidators(self, obj): |
| 444 | try: |
| 445 | return obj.getValidators() |
| 446 | except: |
| 447 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 448 | class Meta: |
| 449 | model = Image |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 450 | 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] | 451 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 452 | class ImageIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 453 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 454 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 455 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 456 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 457 | |
| 458 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 459 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 460 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 461 | def getHumanReadableName(self, obj):
|
| 462 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 463 | def getValidators(self, obj):
|
| 464 | try: |
| 465 | return obj.getValidators() |
| 466 | except: |
| 467 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 468 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 469 | model = Image |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 470 | 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] | 471 | |
| 472 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 473 | |
| 474 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 475 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 476 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 477 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 478 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 479 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 480 | def getHumanReadableName(self, obj):
|
| 481 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 482 | def getValidators(self, obj): |
| 483 | try: |
| 484 | return obj.getValidators() |
| 485 | except: |
| 486 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 487 | class Meta: |
| 488 | model = NetworkParameter |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 489 | 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] | 490 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 491 | class NetworkParameterIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 492 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 493 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 494 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 495 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 496 | def getHumanReadableName(self, obj):
|
| 497 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 498 | def getValidators(self, obj):
|
| 499 | try: |
| 500 | return obj.getValidators() |
| 501 | except: |
| 502 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 503 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 504 | model = NetworkParameter |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 505 | 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] | 506 | |
| 507 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 508 | |
| 509 | |
| 510 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 511 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 512 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 513 | |
| 514 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 515 | |
| 516 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 517 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 518 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 519 | def getHumanReadableName(self, obj):
|
| 520 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 521 | def getValidators(self, obj): |
| 522 | try: |
| 523 | return obj.getValidators() |
| 524 | except: |
| 525 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 526 | class Meta: |
| 527 | model = Site |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 528 | 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] | 529 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 530 | class SiteIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 531 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 532 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 533 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 534 | deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 535 | |
| 536 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 537 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 538 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 539 | def getHumanReadableName(self, obj):
|
| 540 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 541 | def getValidators(self, obj):
|
| 542 | try: |
| 543 | return obj.getValidators() |
| 544 | except: |
| 545 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 546 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 547 | model = Site |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 548 | 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] | 549 | |
| 550 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 551 | |
| 552 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 553 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 554 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 555 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 556 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 557 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 558 | def getHumanReadableName(self, obj):
|
| 559 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 560 | def getValidators(self, obj): |
| 561 | try: |
| 562 | return obj.getValidators() |
| 563 | except: |
| 564 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 565 | class Meta: |
| 566 | model = SliceRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 567 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 568 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 569 | class SliceRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 570 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 571 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 572 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 573 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 574 | def getHumanReadableName(self, obj):
|
| 575 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 576 | def getValidators(self, obj):
|
| 577 | try: |
| 578 | return obj.getValidators() |
| 579 | except: |
| 580 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 581 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 582 | model = SliceRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 583 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 584 | |
| 585 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 586 | |
| 587 | |
| 588 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 589 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 590 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 591 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 592 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 593 | def getHumanReadableName(self, obj):
|
| 594 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 595 | def getValidators(self, obj): |
| 596 | try: |
| 597 | return obj.getValidators() |
| 598 | except: |
| 599 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 600 | class Meta: |
| 601 | model = Tag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 602 | 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] | 603 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 604 | class TagIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 605 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 606 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 607 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 608 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 609 | def getHumanReadableName(self, obj):
|
| 610 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 611 | def getValidators(self, obj):
|
| 612 | try: |
| 613 | return obj.getValidators() |
| 614 | except: |
| 615 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 616 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 617 | model = Tag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 618 | 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] | 619 | |
| 620 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 621 | |
| 622 | |
| 623 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 624 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 625 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 626 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 627 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 628 | def getHumanReadableName(self, obj):
|
| 629 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 630 | def getValidators(self, obj): |
| 631 | try: |
| 632 | return obj.getValidators() |
| 633 | except: |
| 634 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 635 | class Meta: |
| 636 | model = Invoice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 637 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 638 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 639 | class InvoiceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 640 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 641 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 642 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 643 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 644 | def getHumanReadableName(self, obj):
|
| 645 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 646 | def getValidators(self, obj):
|
| 647 | try: |
| 648 | return obj.getValidators() |
| 649 | except: |
| 650 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 651 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 652 | model = Invoice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 653 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 654 | |
| 655 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 656 | |
| 657 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 658 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 659 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 660 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 661 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 662 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 663 | def getHumanReadableName(self, obj):
|
| 664 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 665 | def getValidators(self, obj): |
| 666 | try: |
| 667 | return obj.getValidators() |
| 668 | except: |
| 669 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 670 | class Meta: |
| 671 | model = SlicePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 672 | 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] | 673 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 674 | class SlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 675 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 676 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 677 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 678 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 679 | def getHumanReadableName(self, obj):
|
| 680 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 681 | def getValidators(self, obj):
|
| 682 | try: |
| 683 | return obj.getValidators() |
| 684 | except: |
| 685 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 686 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 687 | model = SlicePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 688 | 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] | 689 | |
| 690 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 691 | |
| 692 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 693 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 694 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 695 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 696 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 697 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 698 | def getHumanReadableName(self, obj):
|
| 699 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 700 | def getValidators(self, obj): |
| 701 | try: |
| 702 | return obj.getValidators() |
| 703 | except: |
| 704 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 705 | class Meta: |
| 706 | model = PlanetStackRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 707 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 708 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 709 | class PlanetStackRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 710 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 711 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 712 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 713 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 714 | def getHumanReadableName(self, obj):
|
| 715 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 716 | def getValidators(self, obj):
|
| 717 | try: |
| 718 | return obj.getValidators() |
| 719 | except: |
| 720 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 721 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 722 | model = PlanetStackRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 723 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 724 | |
| 725 | |
| 726 | |
| 727 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 728 | class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 729 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 730 | |
| 731 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 732 | validators = serializers.SerializerMethodField("getValidators") |
| 733 | def getHumanReadableName(self, obj):
|
| 734 | return str(obj) |
| 735 | def getValidators(self, obj): |
| 736 | try: |
| 737 | return obj.getValidators() |
| 738 | except: |
| 739 | return None |
| 740 | class Meta: |
| 741 | model = ControllerPrivilege |
| 742 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 743 | |
| 744 | class ControllerPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 745 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 746 | |
| 747 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 748 | validators = serializers.SerializerMethodField("getValidators") |
| 749 | def getHumanReadableName(self, obj):
|
| 750 | return str(obj)
|
| 751 | def getValidators(self, obj):
|
| 752 | try: |
| 753 | return obj.getValidators() |
| 754 | except: |
| 755 | return None
|
| 756 | class Meta:
|
| 757 | model = ControllerPrivilege |
| 758 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 763 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 764 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 765 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 766 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 767 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 768 | def getHumanReadableName(self, obj):
|
| 769 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 770 | def getValidators(self, obj): |
| 771 | try: |
| 772 | return obj.getValidators() |
| 773 | except: |
| 774 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 775 | class Meta: |
| 776 | model = NetworkSliver |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 777 | 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] | 778 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 779 | class NetworkSliverIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 780 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 781 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 782 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 783 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 784 | def getHumanReadableName(self, obj):
|
| 785 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 786 | def getValidators(self, obj):
|
| 787 | try: |
| 788 | return obj.getValidators() |
| 789 | except: |
| 790 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 791 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 792 | model = NetworkSliver |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 793 | 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] | 794 | |
| 795 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 796 | |
| 797 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 798 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 799 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 800 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 801 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 802 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 803 | def getHumanReadableName(self, obj):
|
| 804 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 805 | def getValidators(self, obj): |
| 806 | try: |
| 807 | return obj.getValidators() |
| 808 | except: |
| 809 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 810 | class Meta: |
| 811 | model = Project |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 812 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 813 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 814 | class ProjectIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 815 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 816 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 817 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 818 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 819 | def getHumanReadableName(self, obj):
|
| 820 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 821 | def getValidators(self, obj):
|
| 822 | try: |
| 823 | return obj.getValidators() |
| 824 | except: |
| 825 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 826 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 827 | model = Project |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 828 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 829 | |
| 830 | |
| 831 | |
| 832 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 833 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 834 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 835 | |
| 836 | |
| 837 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 838 | |
| 839 | |
| 840 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 841 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 842 | |
| 843 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 844 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 845 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 846 | def getHumanReadableName(self, obj):
|
| 847 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 848 | def getValidators(self, obj): |
| 849 | try: |
| 850 | return obj.getValidators() |
| 851 | except: |
| 852 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 853 | class Meta: |
| 854 | model = Slice |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 855 | 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] | 856 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 857 | class SliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 858 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 859 | |
| 860 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 861 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 862 | |
| 863 | |
| 864 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 865 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 866 | |
| 867 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 868 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 869 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 870 | def getHumanReadableName(self, obj):
|
| 871 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 872 | def getValidators(self, obj):
|
| 873 | try: |
| 874 | return obj.getValidators() |
| 875 | except: |
| 876 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 877 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 878 | model = Slice |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 879 | 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] | 880 | |
| 881 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 882 | |
| 883 | |
| 884 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 885 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 886 | |
| 887 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 888 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 889 | |
| 890 | |
| 891 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 892 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 893 | |
| 894 | |
| 895 | |
| 896 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 897 | |
| 898 | |
| 899 | |
| 900 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 901 | |
| 902 | |
| 903 | |
| 904 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 905 | |
| 906 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 907 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 908 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 909 | def getHumanReadableName(self, obj):
|
| 910 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 911 | def getValidators(self, obj): |
| 912 | try: |
| 913 | return obj.getValidators() |
| 914 | except: |
| 915 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 916 | class Meta: |
| 917 | model = Network |
Scott Baker | d188c01 | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 918 | 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] | 919 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 920 | class NetworkIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 921 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 922 | |
| 923 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 924 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 925 | |
| 926 | |
| 927 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 928 | slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 929 | |
| 930 | |
| 931 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 932 | slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 933 | |
| 934 | |
| 935 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 936 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 937 | |
| 938 | |
| 939 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 940 | routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 941 | |
| 942 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 943 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 944 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 945 | def getHumanReadableName(self, obj):
|
| 946 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 947 | def getValidators(self, obj):
|
| 948 | try: |
| 949 | return obj.getValidators() |
| 950 | except: |
| 951 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 952 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 953 | model = Network |
Scott Baker | d188c01 | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 954 | 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] | 955 | |
| 956 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 957 | |
| 958 | |
| 959 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 960 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 961 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 962 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 963 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 964 | def getHumanReadableName(self, obj):
|
| 965 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 966 | def getValidators(self, obj): |
| 967 | try: |
| 968 | return obj.getValidators() |
| 969 | except: |
| 970 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 971 | class Meta: |
| 972 | model = Service |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 973 | 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] | 974 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 975 | class ServiceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 976 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 977 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 978 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 979 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 980 | def getHumanReadableName(self, obj):
|
| 981 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 982 | def getValidators(self, obj):
|
| 983 | try: |
| 984 | return obj.getValidators() |
| 985 | except: |
| 986 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 987 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 988 | model = Service |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 989 | 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] | 990 | |
| 991 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 992 | |
| 993 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 994 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 995 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 996 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 997 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 998 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 999 | def getHumanReadableName(self, obj):
|
| 1000 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1001 | def getValidators(self, obj): |
| 1002 | try: |
| 1003 | return obj.getValidators() |
| 1004 | except: |
| 1005 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1006 | class Meta: |
| 1007 | model = ServiceClass |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1008 | 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] | 1009 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1010 | class ServiceClassIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1011 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1012 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1013 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1014 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1015 | def getHumanReadableName(self, obj):
|
| 1016 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1017 | def getValidators(self, obj):
|
| 1018 | try: |
| 1019 | return obj.getValidators() |
| 1020 | except: |
| 1021 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1022 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1023 | model = ServiceClass |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1024 | 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] | 1025 | |
| 1026 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1027 | |
| 1028 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1029 | class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1030 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1031 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1032 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1033 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1034 | def getHumanReadableName(self, obj):
|
| 1035 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1036 | def getValidators(self, obj): |
| 1037 | try: |
| 1038 | return obj.getValidators() |
| 1039 | except: |
| 1040 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1041 | class Meta: |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1042 | model = ControllerNetwork |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1043 | 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] | 1044 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1045 | class ControllerNetworkIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1046 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1047 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1048 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1049 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1050 | def getHumanReadableName(self, obj):
|
| 1051 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1052 | def getValidators(self, obj):
|
| 1053 | try: |
| 1054 | return obj.getValidators() |
| 1055 | except: |
| 1056 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1057 | class Meta:
|
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 1058 | model = ControllerNetwork |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1059 | 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] | 1060 | |
| 1061 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1062 | |
| 1063 | |
| 1064 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1065 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1066 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1067 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1068 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1069 | def getHumanReadableName(self, obj):
|
| 1070 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1071 | def getValidators(self, obj): |
| 1072 | try: |
| 1073 | return obj.getValidators() |
| 1074 | except: |
| 1075 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1076 | class Meta: |
| 1077 | model = Charge |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1078 | 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] | 1079 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1080 | class ChargeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1081 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1082 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1083 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1084 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1085 | def getHumanReadableName(self, obj):
|
| 1086 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1087 | def getValidators(self, obj):
|
| 1088 | try: |
| 1089 | return obj.getValidators() |
| 1090 | except: |
| 1091 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1092 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1093 | model = Charge |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1094 | 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] | 1095 | |
| 1096 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1097 | |
| 1098 | |
| 1099 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1100 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1101 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1102 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1103 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1104 | def getHumanReadableName(self, obj):
|
| 1105 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1106 | def getValidators(self, obj): |
| 1107 | try: |
| 1108 | return obj.getValidators() |
| 1109 | except: |
| 1110 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1111 | class Meta: |
| 1112 | model = Role |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1113 | 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] | 1114 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1115 | class RoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1116 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1117 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1118 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1119 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1120 | def getHumanReadableName(self, obj):
|
| 1121 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1122 | def getValidators(self, obj):
|
| 1123 | try: |
| 1124 | return obj.getValidators() |
| 1125 | except: |
| 1126 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1127 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1128 | model = Role |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1129 | 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] | 1130 | |
| 1131 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1132 | |
| 1133 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1134 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1135 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1136 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1137 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1138 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1139 | def getHumanReadableName(self, obj):
|
| 1140 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1141 | def getValidators(self, obj): |
| 1142 | try: |
| 1143 | return obj.getValidators() |
| 1144 | except: |
| 1145 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1146 | class Meta: |
| 1147 | model = UsableObject |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1148 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1149 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1150 | class UsableObjectIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1151 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1152 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1153 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1154 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1155 | def getHumanReadableName(self, obj):
|
| 1156 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1157 | def getValidators(self, obj):
|
| 1158 | try: |
| 1159 | return obj.getValidators() |
| 1160 | except: |
| 1161 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1162 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1163 | model = UsableObject |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1164 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1165 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1166 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1167 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1168 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1169 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1170 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1171 | def getHumanReadableName(self, obj):
|
| 1172 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1173 | def getValidators(self, obj): |
| 1174 | try: |
| 1175 | return obj.getValidators() |
| 1176 | except: |
| 1177 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1178 | class Meta: |
| 1179 | model = SiteRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1180 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1181 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1182 | class SiteRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1183 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1184 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1185 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1186 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1187 | def getHumanReadableName(self, obj):
|
| 1188 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1189 | def getValidators(self, obj):
|
| 1190 | try: |
| 1191 | return obj.getValidators() |
| 1192 | except: |
| 1193 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1194 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1195 | model = SiteRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1196 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1197 | |
| 1198 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1199 | |
| 1200 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1201 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1202 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1203 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1204 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1205 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1206 | def getHumanReadableName(self, obj):
|
| 1207 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1208 | def getValidators(self, obj): |
| 1209 | try: |
| 1210 | return obj.getValidators() |
| 1211 | except: |
| 1212 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1213 | class Meta: |
| 1214 | model = SliceCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1215 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1216 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1217 | class SliceCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1218 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1219 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1220 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1221 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1222 | def getHumanReadableName(self, obj):
|
| 1223 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1224 | def getValidators(self, obj):
|
| 1225 | try: |
| 1226 | return obj.getValidators() |
| 1227 | except: |
| 1228 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1229 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1230 | model = SliceCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1231 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1232 | |
| 1233 | |
| 1234 | |
| 1235 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1236 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1237 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1238 | |
| 1239 | |
| 1240 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1241 | |
| 1242 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1243 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1244 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1245 | def getHumanReadableName(self, obj):
|
| 1246 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1247 | def getValidators(self, obj): |
| 1248 | try: |
| 1249 | return obj.getValidators() |
| 1250 | except: |
| 1251 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1252 | class Meta: |
| 1253 | model = Sliver |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 1254 | 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] | 1255 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1256 | class SliverIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1257 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1258 | |
| 1259 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1260 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1261 | |
| 1262 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1263 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1264 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1265 | def getHumanReadableName(self, obj):
|
| 1266 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1267 | def getValidators(self, obj):
|
| 1268 | try: |
| 1269 | return obj.getValidators() |
| 1270 | except: |
| 1271 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1272 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1273 | model = Sliver |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 1274 | 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] | 1275 | |
| 1276 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1277 | |
| 1278 | |
| 1279 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1280 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1281 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1282 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1283 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1284 | def getHumanReadableName(self, obj):
|
| 1285 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1286 | def getValidators(self, obj): |
| 1287 | try: |
| 1288 | return obj.getValidators() |
| 1289 | except: |
| 1290 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1291 | class Meta: |
| 1292 | model = Node |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1293 | 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] | 1294 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1295 | class NodeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1296 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1297 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1298 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1299 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1300 | def getHumanReadableName(self, obj):
|
| 1301 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1302 | def getValidators(self, obj):
|
| 1303 | try: |
| 1304 | return obj.getValidators() |
| 1305 | except: |
| 1306 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1307 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1308 | model = Node |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1309 | 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] | 1310 | |
| 1311 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1312 | |
| 1313 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1314 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1315 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1316 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1317 | |
| 1318 | controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail') |
| 1319 | |
| 1320 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1321 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1322 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1323 | def getHumanReadableName(self, obj):
|
| 1324 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1325 | def getValidators(self, obj): |
| 1326 | try: |
| 1327 | return obj.getValidators() |
| 1328 | except: |
| 1329 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1330 | class Meta: |
| 1331 | model = DashboardView |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1332 | 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] | 1333 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1334 | class DashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1335 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1336 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1337 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1338 | controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1339 | |
| 1340 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1341 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1342 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1343 | def getHumanReadableName(self, obj):
|
| 1344 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1345 | def getValidators(self, obj):
|
| 1346 | try: |
| 1347 | return obj.getValidators() |
| 1348 | except: |
| 1349 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1350 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1351 | model = DashboardView |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1352 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1353 | |
| 1354 | |
| 1355 | |
| 1356 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1357 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1358 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1359 | |
| 1360 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1361 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1362 | def getHumanReadableName(self, obj):
|
| 1363 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1364 | def getValidators(self, obj): |
| 1365 | try: |
| 1366 | return obj.getValidators() |
| 1367 | except: |
| 1368 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1369 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1370 | model = ImageDeployments |
| 1371 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1372 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1373 | class ImageDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1374 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1375 | |
| 1376 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1377 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1378 | def getHumanReadableName(self, obj):
|
| 1379 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1380 | def getValidators(self, obj):
|
| 1381 | try: |
| 1382 | return obj.getValidators() |
| 1383 | except: |
| 1384 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1385 | class Meta:
|
| 1386 | model = ImageDeployments |
| 1387 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1388 | |
| 1389 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1390 | |
| 1391 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1392 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1393 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1394 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1395 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1396 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1397 | def getHumanReadableName(self, obj):
|
| 1398 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1399 | def getValidators(self, obj): |
| 1400 | try: |
| 1401 | return obj.getValidators() |
| 1402 | except: |
| 1403 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1404 | class Meta: |
| 1405 | model = ReservedResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1406 | 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] | 1407 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1408 | class ReservedResourceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1409 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1410 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1411 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1412 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1413 | def getHumanReadableName(self, obj):
|
| 1414 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1415 | def getValidators(self, obj):
|
| 1416 | try: |
| 1417 | return obj.getValidators() |
| 1418 | except: |
| 1419 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1420 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1421 | model = ReservedResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1422 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1423 | |
| 1424 | |
| 1425 | |
| 1426 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1427 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1428 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1429 | |
| 1430 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1431 | validators = serializers.SerializerMethodField("getValidators") |
| 1432 | def getHumanReadableName(self, obj):
|
| 1433 | return str(obj) |
| 1434 | def getValidators(self, obj): |
| 1435 | try: |
| 1436 | return obj.getValidators() |
| 1437 | except: |
| 1438 | return None |
| 1439 | class Meta: |
| 1440 | model = Payment |
| 1441 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1442 | |
| 1443 | class PaymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1444 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1445 | |
| 1446 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1447 | validators = serializers.SerializerMethodField("getValidators") |
| 1448 | def getHumanReadableName(self, obj):
|
| 1449 | return str(obj)
|
| 1450 | def getValidators(self, obj):
|
| 1451 | try: |
| 1452 | return obj.getValidators() |
| 1453 | except: |
| 1454 | return None
|
| 1455 | class Meta:
|
| 1456 | model = Payment |
| 1457 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1458 | |
| 1459 | |
| 1460 | |
| 1461 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1462 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1463 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1464 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1465 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1466 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1467 | def getHumanReadableName(self, obj):
|
| 1468 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1469 | def getValidators(self, obj): |
| 1470 | try: |
| 1471 | return obj.getValidators() |
| 1472 | except: |
| 1473 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1474 | class Meta: |
| 1475 | model = NetworkSlice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1476 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1477 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1478 | class NetworkSliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1479 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1480 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1481 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1482 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1483 | def getHumanReadableName(self, obj):
|
| 1484 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1485 | def getValidators(self, obj):
|
| 1486 | try: |
| 1487 | return obj.getValidators() |
| 1488 | except: |
| 1489 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1490 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1491 | model = NetworkSlice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1492 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1493 | |
| 1494 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1495 | |
| 1496 | |
| 1497 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1498 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1499 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1500 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1501 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1502 | def getHumanReadableName(self, obj):
|
| 1503 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1504 | def getValidators(self, obj): |
| 1505 | try: |
| 1506 | return obj.getValidators() |
| 1507 | except: |
| 1508 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1509 | class Meta: |
| 1510 | model = UserDashboardView |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1511 | 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] | 1512 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1513 | class UserDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1514 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1515 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1516 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1517 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1518 | def getHumanReadableName(self, obj):
|
| 1519 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1520 | def getValidators(self, obj):
|
| 1521 | try: |
| 1522 | return obj.getValidators() |
| 1523 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1524 | return None
|
| 1525 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1526 | model = UserDashboardView |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1527 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1528 | |
| 1529 | |
| 1530 | |
| 1531 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1532 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1533 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1534 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1535 | |
| 1536 | dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail') |
| 1537 | |
| 1538 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1539 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1540 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1541 | def getHumanReadableName(self, obj):
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1542 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1543 | def getValidators(self, obj): |
| 1544 | try: |
| 1545 | return obj.getValidators() |
| 1546 | except: |
| 1547 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1548 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1549 | model = Controller |
| 1550 | 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] | 1551 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1552 | class ControllerIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1553 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1554 | |
| 1555 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1556 | dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all()) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1557 | |
| 1558 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1559 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1560 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1561 | def getHumanReadableName(self, obj):
|
| 1562 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1563 | def getValidators(self, obj):
|
| 1564 | try: |
| 1565 | return obj.getValidators() |
| 1566 | except: |
| 1567 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1568 | class Meta:
|
| 1569 | model = Controller |
| 1570 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 1571 | |
| 1572 | |
| 1573 | |
| 1574 | |
| 1575 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1576 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1577 | |
| 1578 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1579 | validators = serializers.SerializerMethodField("getValidators") |
| 1580 | def getHumanReadableName(self, obj):
|
| 1581 | return str(obj) |
| 1582 | def getValidators(self, obj): |
| 1583 | try: |
| 1584 | return obj.getValidators() |
| 1585 | except: |
| 1586 | return None |
| 1587 | class Meta: |
| 1588 | model = PlanetStackPrivilege |
| 1589 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1590 | |
| 1591 | class PlanetStackPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1592 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1593 | |
| 1594 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1595 | validators = serializers.SerializerMethodField("getValidators") |
| 1596 | def getHumanReadableName(self, obj):
|
| 1597 | return str(obj)
|
| 1598 | def getValidators(self, obj):
|
| 1599 | try: |
| 1600 | return obj.getValidators() |
| 1601 | except: |
| 1602 | return None
|
| 1603 | class Meta:
|
| 1604 | model = PlanetStackPrivilege |
| 1605 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1606 | |
| 1607 | |
| 1608 | |
| 1609 | |
| 1610 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1611 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1612 | |
| 1613 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1614 | validators = serializers.SerializerMethodField("getValidators") |
| 1615 | def getHumanReadableName(self, obj):
|
| 1616 | return str(obj) |
| 1617 | def getValidators(self, obj): |
| 1618 | try: |
| 1619 | return obj.getValidators() |
| 1620 | except: |
| 1621 | return None |
| 1622 | class Meta: |
| 1623 | model = User |
| 1624 | 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',) |
| 1625 | |
| 1626 | class UserIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1627 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1628 | |
| 1629 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1630 | validators = serializers.SerializerMethodField("getValidators") |
| 1631 | def getHumanReadableName(self, obj):
|
| 1632 | return str(obj)
|
| 1633 | def getValidators(self, obj):
|
| 1634 | try: |
| 1635 | return obj.getValidators() |
| 1636 | except: |
| 1637 | return None
|
| 1638 | class Meta:
|
| 1639 | model = User |
| 1640 | 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',) |
| 1641 | |
| 1642 | |
| 1643 | |
| 1644 | |
| 1645 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1646 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1647 | |
| 1648 | |
| 1649 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1650 | |
| 1651 | |
| 1652 | |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1653 | images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail') |
| 1654 | |
| 1655 | |
| 1656 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1657 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1658 | |
| 1659 | |
| 1660 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1661 | validators = serializers.SerializerMethodField("getValidators") |
| 1662 | def getHumanReadableName(self, obj):
|
| 1663 | return str(obj) |
| 1664 | def getValidators(self, obj): |
| 1665 | try: |
| 1666 | return obj.getValidators() |
| 1667 | except: |
| 1668 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1669 | class Meta: |
| 1670 | model = Deployment |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1671 | 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] | 1672 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1673 | class DeploymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1674 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1675 | |
| 1676 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1677 | flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1678 | |
| 1679 | |
| 1680 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1681 | images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all()) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1682 | |
| 1683 | |
| 1684 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 1685 | sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1686 | |
| 1687 | |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1688 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1689 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1690 | def getHumanReadableName(self, obj):
|
| 1691 | return str(obj)
|
| 1692 | def getValidators(self, obj):
|
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1693 | try: |
| 1694 | return obj.getValidators() |
| 1695 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1696 | return None
|
| 1697 | class Meta:
|
| 1698 | model = Deployment |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 1699 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',) |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1700 | |
| 1701 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1702 | |
| 1703 | |
| 1704 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1705 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1706 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1707 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1708 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1709 | def getHumanReadableName(self, obj):
|
| 1710 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1711 | def getValidators(self, obj): |
| 1712 | try: |
| 1713 | return obj.getValidators() |
| 1714 | except: |
| 1715 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1716 | class Meta: |
| 1717 | model = Reservation |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1718 | 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] | 1719 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1720 | class ReservationIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1721 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1722 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1723 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1724 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1725 | def getHumanReadableName(self, obj):
|
| 1726 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1727 | def getValidators(self, obj):
|
| 1728 | try: |
| 1729 | return obj.getValidators() |
| 1730 | except: |
| 1731 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1732 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1733 | model = Reservation |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1734 | 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] | 1735 | |
| 1736 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1737 | |
| 1738 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1739 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1740 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1741 | |
| 1742 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1743 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1744 | def getHumanReadableName(self, obj):
|
| 1745 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1746 | def getValidators(self, obj): |
| 1747 | try: |
| 1748 | return obj.getValidators() |
| 1749 | except: |
| 1750 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1751 | class Meta: |
| 1752 | model = SitePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1753 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1754 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1755 | class SitePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1756 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1757 | |
| 1758 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1759 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1760 | def getHumanReadableName(self, obj):
|
| 1761 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1762 | def getValidators(self, obj):
|
| 1763 | try: |
| 1764 | return obj.getValidators() |
| 1765 | except: |
| 1766 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1767 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1768 | model = SitePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1769 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1770 | |
| 1771 | |
| 1772 | |
| 1773 | |
| 1774 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1775 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1776 | |
| 1777 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1778 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1779 | def getHumanReadableName(self, obj):
|
| 1780 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1781 | def getValidators(self, obj): |
| 1782 | try: |
| 1783 | return obj.getValidators() |
| 1784 | except: |
| 1785 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1786 | class Meta: |
| 1787 | model = PlanetStack |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1788 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1789 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1790 | class PlanetStackIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1791 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1792 | |
| 1793 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1794 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1795 | def getHumanReadableName(self, obj):
|
| 1796 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1797 | def getValidators(self, obj):
|
| 1798 | try: |
| 1799 | return obj.getValidators() |
| 1800 | except: |
| 1801 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1802 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1803 | model = PlanetStack |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1804 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1805 | |
| 1806 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1807 | |
| 1808 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1809 | class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1810 | id = IdField() |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1811 | |
| 1812 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1813 | validators = serializers.SerializerMethodField("getValidators") |
| 1814 | def getHumanReadableName(self, obj):
|
| 1815 | return str(obj) |
| 1816 | def getValidators(self, obj): |
| 1817 | try: |
| 1818 | return obj.getValidators() |
| 1819 | except: |
| 1820 | return None |
| 1821 | class Meta: |
| 1822 | model = ControllerDashboardView |
| 1823 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1824 | |
| 1825 | class ControllerDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1826 | id = IdField() |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 1827 | |
| 1828 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1829 | validators = serializers.SerializerMethodField("getValidators") |
| 1830 | def getHumanReadableName(self, obj):
|
| 1831 | return str(obj)
|
| 1832 | def getValidators(self, obj):
|
| 1833 | try: |
| 1834 | return obj.getValidators() |
| 1835 | except: |
| 1836 | return None
|
| 1837 | class Meta:
|
| 1838 | model = ControllerDashboardView |
| 1839 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 1840 | |
| 1841 | |
| 1842 | |
| 1843 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1844 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1845 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1846 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1847 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1848 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1849 | def getHumanReadableName(self, obj):
|
| 1850 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1851 | def getValidators(self, obj): |
| 1852 | try: |
| 1853 | return obj.getValidators() |
| 1854 | except: |
| 1855 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1856 | class Meta: |
| 1857 | model = Account |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1858 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1859 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1860 | class AccountIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1861 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1862 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1863 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1864 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1865 | def getHumanReadableName(self, obj):
|
| 1866 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1867 | def getValidators(self, obj):
|
| 1868 | try: |
| 1869 | return obj.getValidators() |
| 1870 | except: |
| 1871 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1872 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1873 | model = Account |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1874 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1875 | |
| 1876 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1877 | |
| 1878 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1879 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1880 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1881 | |
| 1882 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1883 | validators = serializers.SerializerMethodField("getValidators") |
| 1884 | def getHumanReadableName(self, obj):
|
| 1885 | return str(obj) |
| 1886 | def getValidators(self, obj): |
| 1887 | try: |
| 1888 | return obj.getValidators() |
| 1889 | except: |
| 1890 | return None |
| 1891 | class Meta: |
| 1892 | model = ControllerRole |
| 1893 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1894 | |
| 1895 | class ControllerRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1896 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1897 | |
| 1898 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1899 | validators = serializers.SerializerMethodField("getValidators") |
| 1900 | def getHumanReadableName(self, obj):
|
| 1901 | return str(obj)
|
| 1902 | def getValidators(self, obj):
|
| 1903 | try: |
| 1904 | return obj.getValidators() |
| 1905 | except: |
| 1906 | return None
|
| 1907 | class Meta:
|
| 1908 | model = ControllerRole |
| 1909 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1910 | |
| 1911 | |
| 1912 | |
| 1913 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1914 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1915 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1916 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1917 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1918 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1919 | def getHumanReadableName(self, obj):
|
| 1920 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1921 | def getValidators(self, obj): |
| 1922 | try: |
| 1923 | return obj.getValidators() |
| 1924 | except: |
| 1925 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1926 | class Meta: |
| 1927 | model = NetworkParameterType |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1928 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1929 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1930 | class NetworkParameterTypeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1931 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1932 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1933 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1934 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1935 | def getHumanReadableName(self, obj):
|
| 1936 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1937 | def getValidators(self, obj):
|
| 1938 | try: |
| 1939 | return obj.getValidators() |
| 1940 | except: |
| 1941 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1942 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1943 | model = NetworkParameterType |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1944 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1945 | |
| 1946 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1947 | |
| 1948 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1949 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1950 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1951 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1952 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1953 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1954 | def getHumanReadableName(self, obj):
|
| 1955 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1956 | def getValidators(self, obj): |
| 1957 | try: |
| 1958 | return obj.getValidators() |
| 1959 | except: |
| 1960 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1961 | class Meta: |
| 1962 | model = SiteCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1963 | 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] | 1964 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1965 | class SiteCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1966 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1967 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1968 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1969 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1970 | def getHumanReadableName(self, obj):
|
| 1971 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1972 | def getValidators(self, obj):
|
| 1973 | try: |
| 1974 | return obj.getValidators() |
| 1975 | except: |
| 1976 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1977 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1978 | model = SiteCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1979 | 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] | 1980 | |
| 1981 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1982 | |
| 1983 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1984 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 1985 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1986 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1987 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1988 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1989 | def getHumanReadableName(self, obj):
|
| 1990 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1991 | def getValidators(self, obj): |
| 1992 | try: |
| 1993 | return obj.getValidators() |
| 1994 | except: |
| 1995 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1996 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1997 | model = DeploymentPrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1998 | 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] | 1999 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2000 | class DeploymentPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2001 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2002 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2003 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2004 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2005 | def getHumanReadableName(self, obj):
|
| 2006 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2007 | def getValidators(self, obj):
|
| 2008 | try: |
| 2009 | return obj.getValidators() |
| 2010 | except: |
| 2011 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2012 | class Meta:
|
| 2013 | model = DeploymentPrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2014 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2015 | |
| 2016 | |
| 2017 | |
| 2018 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2019 | class ControllerUserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2020 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2021 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2022 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2023 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2024 | def getHumanReadableName(self, obj):
|
| 2025 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2026 | def getValidators(self, obj): |
| 2027 | try: |
| 2028 | return obj.getValidators() |
| 2029 | except: |
| 2030 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2031 | class Meta: |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2032 | model = ControllerUser |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2033 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2034 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2035 | class ControllerUserIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2036 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2037 | |
| 2038 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2039 | validators = serializers.SerializerMethodField("getValidators") |
| 2040 | def getHumanReadableName(self, obj):
|
| 2041 | return str(obj)
|
| 2042 | def getValidators(self, obj):
|
| 2043 | try: |
| 2044 | return obj.getValidators() |
| 2045 | except: |
| 2046 | return None
|
| 2047 | class Meta:
|
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2048 | model = ControllerUser |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2049 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2050 | |
| 2051 | |
| 2052 | |
| 2053 | |
| 2054 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2055 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2056 | |
| 2057 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2058 | validators = serializers.SerializerMethodField("getValidators") |
| 2059 | def getHumanReadableName(self, obj):
|
| 2060 | return str(obj) |
| 2061 | def getValidators(self, obj): |
| 2062 | try: |
| 2063 | return obj.getValidators() |
| 2064 | except: |
| 2065 | return None |
| 2066 | class Meta: |
| 2067 | model = DeploymentRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2068 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2069 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2070 | class DeploymentRoleIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2071 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2072 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2073 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2074 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2075 | def getHumanReadableName(self, obj):
|
| 2076 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2077 | def getValidators(self, obj):
|
| 2078 | try: |
| 2079 | return obj.getValidators() |
| 2080 | except: |
| 2081 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2082 | class Meta:
|
| 2083 | model = DeploymentRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2084 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2085 | |
| 2086 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2087 | |
| 2088 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2089 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2090 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2091 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2092 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2093 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2094 | def getHumanReadableName(self, obj):
|
| 2095 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2096 | def getValidators(self, obj): |
| 2097 | try: |
| 2098 | return obj.getValidators() |
| 2099 | except: |
| 2100 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2101 | class Meta: |
| 2102 | model = UserCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2103 | 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] | 2104 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2105 | class UserCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2106 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2107 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2108 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2109 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2110 | def getHumanReadableName(self, obj):
|
| 2111 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2112 | def getValidators(self, obj):
|
| 2113 | try: |
| 2114 | return obj.getValidators() |
| 2115 | except: |
| 2116 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2117 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2118 | model = UserCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2119 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2120 | |
| 2121 | |
| 2122 | |
| 2123 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2124 | class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2125 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2126 | |
| 2127 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2128 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2129 | def getHumanReadableName(self, obj):
|
| 2130 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2131 | def getValidators(self, obj): |
| 2132 | try: |
| 2133 | return obj.getValidators() |
| 2134 | except: |
| 2135 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2136 | class Meta: |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2137 | model = SiteDeployment |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2138 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2139 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2140 | class SiteDeploymentIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2141 | id = IdField() |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2142 | |
| 2143 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2144 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2145 | def getHumanReadableName(self, obj):
|
| 2146 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2147 | def getValidators(self, obj):
|
| 2148 | try: |
| 2149 | return obj.getValidators() |
| 2150 | except: |
| 2151 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2152 | class Meta:
|
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2153 | model = SiteDeployment |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2154 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
| 2155 | |
| 2156 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2157 | |
| 2158 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2159 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2160 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2161 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2162 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2163 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2164 | def getHumanReadableName(self, obj):
|
| 2165 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2166 | def getValidators(self, obj): |
| 2167 | try: |
| 2168 | return obj.getValidators() |
| 2169 | except: |
| 2170 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2171 | class Meta: |
| 2172 | model = SliceTag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2173 | 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] | 2174 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2175 | class SliceTagIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2176 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2177 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2178 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2179 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2180 | def getHumanReadableName(self, obj):
|
| 2181 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2182 | def getValidators(self, obj):
|
| 2183 | try: |
| 2184 | return obj.getValidators() |
| 2185 | except: |
| 2186 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2187 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2188 | model = SliceTag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2189 | 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] | 2190 | |
| 2191 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2192 | |
| 2193 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2194 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2195 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2196 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2197 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2198 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2199 | def getHumanReadableName(self, obj):
|
| 2200 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2201 | def getValidators(self, obj): |
| 2202 | try: |
| 2203 | return obj.getValidators() |
| 2204 | except: |
| 2205 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2206 | class Meta: |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2207 | model = NetworkTemplate |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 2208 | 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] | 2209 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2210 | class NetworkTemplateIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2211 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2212 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2213 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2214 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2215 | def getHumanReadableName(self, obj):
|
| 2216 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2217 | def getValidators(self, obj):
|
| 2218 | try: |
| 2219 | return obj.getValidators() |
| 2220 | except: |
| 2221 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2222 | class Meta:
|
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2223 | model = NetworkTemplate |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 2224 | 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] | 2225 | |
| 2226 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2227 | |
| 2228 | |
| 2229 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2230 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2231 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2232 | |
| 2233 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2234 | |
| 2235 | |
| 2236 | |
| 2237 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2238 | |
| 2239 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2240 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2241 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2242 | def getHumanReadableName(self, obj):
|
| 2243 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2244 | def getValidators(self, obj): |
| 2245 | try: |
| 2246 | return obj.getValidators() |
| 2247 | except: |
| 2248 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2249 | class Meta: |
| 2250 | model = Router |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2251 | 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] | 2252 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2253 | class RouterIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2254 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2255 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2256 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2257 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2258 | |
| 2259 | |
| 2260 | |
Scott Baker | 201f7da | 2014-12-23 10:56:06 -0800 | [diff] [blame] | 2261 | networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all()) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2262 | |
| 2263 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2264 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2265 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2266 | def getHumanReadableName(self, obj):
|
| 2267 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2268 | def getValidators(self, obj):
|
| 2269 | try: |
| 2270 | return obj.getValidators() |
| 2271 | except: |
| 2272 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2273 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2274 | model = Router |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2275 | 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] | 2276 | |
| 2277 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2278 | |
| 2279 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2280 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2281 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2282 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2283 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2284 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2285 | def getHumanReadableName(self, obj):
|
| 2286 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2287 | def getValidators(self, obj): |
| 2288 | try: |
| 2289 | return obj.getValidators() |
| 2290 | except: |
| 2291 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2292 | class Meta: |
| 2293 | model = ServiceResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2294 | 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] | 2295 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2296 | class ServiceResourceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2297 | id = IdField() |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2298 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2299 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2300 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2301 | def getHumanReadableName(self, obj):
|
| 2302 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2303 | def getValidators(self, obj):
|
| 2304 | try: |
| 2305 | return obj.getValidators() |
| 2306 | except: |
| 2307 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2308 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2309 | model = ServiceResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2310 | 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] | 2311 | |
| 2312 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2313 | |
| 2314 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2315 | class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2316 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2317 | |
| 2318 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2319 | validators = serializers.SerializerMethodField("getValidators") |
| 2320 | def getHumanReadableName(self, obj):
|
| 2321 | return str(obj) |
| 2322 | def getValidators(self, obj): |
| 2323 | try: |
| 2324 | return obj.getValidators() |
| 2325 | except: |
| 2326 | return None |
| 2327 | class Meta: |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2328 | model = ControllerSlice |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2329 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2330 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2331 | class ControllerSliceIdSerializer(XOSModelSerializer): |
Scott Baker | f0480fb | 2014-12-23 11:12:07 -0800 | [diff] [blame] | 2332 | id = IdField() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2333 | |
| 2334 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2335 | validators = serializers.SerializerMethodField("getValidators") |
| 2336 | def getHumanReadableName(self, obj):
|
| 2337 | return str(obj)
|
| 2338 | def getValidators(self, obj):
|
| 2339 | try: |
| 2340 | return obj.getValidators() |
| 2341 | except: |
| 2342 | return None
|
| 2343 | class Meta:
|
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2344 | model = ControllerSlice |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2345 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2346 | |
| 2347 | |
| 2348 | |
| 2349 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2350 | serializerLookUp = { |
| 2351 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2352 | Flavor: FlavorSerializer, |
| 2353 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2354 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2355 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2356 | ControllerImages: ControllerImagesSerializer, |
| 2357 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2358 | Image: ImageSerializer, |
| 2359 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2360 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2361 | |
| 2362 | Site: SiteSerializer, |
| 2363 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2364 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2365 | |
| 2366 | Tag: TagSerializer, |
| 2367 | |
| 2368 | Invoice: InvoiceSerializer, |
| 2369 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2370 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2371 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2372 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2373 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2374 | ControllerPrivilege: ControllerPrivilegeSerializer, |
| 2375 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2376 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2377 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2378 | Project: ProjectSerializer, |
| 2379 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2380 | Slice: SliceSerializer, |
| 2381 | |
| 2382 | Network: NetworkSerializer, |
| 2383 | |
| 2384 | Service: ServiceSerializer, |
| 2385 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2386 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2387 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2388 | ControllerNetwork: ControllerNetworkSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2389 | |
| 2390 | Charge: ChargeSerializer, |
| 2391 | |
| 2392 | Role: RoleSerializer, |
| 2393 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2394 | UsableObject: UsableObjectSerializer, |
| 2395 | |
| 2396 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2397 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2398 | SliceCredential: SliceCredentialSerializer, |
| 2399 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2400 | Sliver: SliverSerializer, |
| 2401 | |
| 2402 | Node: NodeSerializer, |
| 2403 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2404 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2405 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2406 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2407 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2408 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2409 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2410 | Payment: PaymentSerializer, |
| 2411 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2412 | NetworkSlice: NetworkSliceSerializer, |
| 2413 | |
| 2414 | UserDashboardView: UserDashboardViewSerializer, |
| 2415 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2416 | Controller: ControllerSerializer, |
| 2417 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2418 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2419 | |
| 2420 | User: UserSerializer, |
| 2421 | |
| 2422 | Deployment: DeploymentSerializer, |
| 2423 | |
| 2424 | Reservation: ReservationSerializer, |
| 2425 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2426 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2427 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2428 | PlanetStack: PlanetStackSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2429 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2430 | ControllerDashboardView: ControllerDashboardViewSerializer, |
| 2431 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2432 | Account: AccountSerializer, |
| 2433 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2434 | ControllerRole: ControllerRoleSerializer, |
| 2435 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2436 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2437 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2438 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2439 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2440 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2441 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2442 | ControllerUser: ControllerUserSerializer, |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2443 | |
| 2444 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2445 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2446 | UserCredential: UserCredentialSerializer, |
| 2447 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2448 | SiteDeployment: SiteDeploymentSerializer, |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2449 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2450 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2451 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 2452 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2453 | |
| 2454 | Router: RouterSerializer, |
| 2455 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2456 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2457 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 2458 | ControllerSlice: ControllerSliceSerializer, |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2459 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2460 | None: None, |
| 2461 | } |
| 2462 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2463 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2464 | |
| 2465 | # To handle fine-grained field permissions, we have to check can_update |
| 2466 | # the object has been updated but before it has been saved. |
| 2467 | |
| 2468 | def update(self, request, *args, **kwargs):
|
| 2469 | partial = kwargs.pop('partial', False)
|
| 2470 | self.object = self.get_object_or_none()
|
| 2471 |
|
| 2472 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2473 | files=request.FILES, partial=partial)
|
| 2474 |
|
| 2475 | if not serializer.is_valid():
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2476 | response = {"error": "validation",
|
| 2477 | "specific_error": "not serializer.is_valid()",
|
| 2478 | "reasons": serializer.errors}
|
| 2479 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2480 |
|
| 2481 | try:
|
| 2482 | self.pre_save(serializer.object)
|
| 2483 | except ValidationError as err:
|
| 2484 | # full_clean on model instance may be called in pre_save,
|
| 2485 | # so we have to handle eventual errors.
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2486 | response = {"error": "validation",
|
| 2487 | "specific_error": "ValidationError in pre_save",
|
| 2488 | "reasons": err.message_dict}
|
| 2489 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2490 |
|
| 2491 | if serializer.object is not None:
|
| 2492 | if not serializer.object.can_update(request.user):
|
| 2493 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2494 |
|
| 2495 | if self.object is None:
|
| 2496 | self.object = serializer.save(force_insert=True)
|
| 2497 | self.post_save(self.object, created=True)
|
| 2498 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2499 |
|
| 2500 | self.object = serializer.save(force_update=True)
|
| 2501 | self.post_save(self.object, created=False)
|
| 2502 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2503 | |
| 2504 | def destroy(self, request, *args, **kwargs): |
| 2505 | obj = self.get_object() |
| 2506 | if obj.can_update(request.user): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2507 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2508 | else: |
| 2509 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2510 | |
| 2511 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2512 | # Based on core/views/*.py |
| 2513 | |
| 2514 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2515 | class FlavorList(generics.ListCreateAPIView): |
| 2516 | queryset = Flavor.objects.select_related().all() |
| 2517 | serializer_class = FlavorSerializer |
| 2518 | id_serializer_class = FlavorIdSerializer |
| 2519 | filter_backends = (filters.DjangoFilterBackend,) |
| 2520 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 2521 | |
| 2522 | def get_serializer_class(self): |
| 2523 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2524 | if (no_hyperlinks): |
| 2525 | return self.id_serializer_class |
| 2526 | else: |
| 2527 | return self.serializer_class |
| 2528 | |
| 2529 | def get_queryset(self): |
| 2530 | return Flavor.select_by_user(self.request.user) |
| 2531 | |
| 2532 | def create(self, request, *args, **kwargs): |
| 2533 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2534 | if not (serializer.is_valid()): |
| 2535 | response = {"error": "validation", |
| 2536 | "specific_error": "not serializer.is_valid()",
|
| 2537 | "reasons": serializer.errors}
|
| 2538 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2539 | obj = serializer.object |
| 2540 | obj.caller = request.user |
| 2541 | if obj.can_update(request.user): |
| 2542 | return super(FlavorList, self).create(request, *args, **kwargs) |
| 2543 | else: |
| 2544 | raise Exception("failed obj.can_update") |
| 2545 | |
| 2546 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 2547 | if (ret.status_code%100 != 200): |
| 2548 | raise Exception(ret.data) |
| 2549 | |
| 2550 | return ret |
| 2551 | |
| 2552 | |
| 2553 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2554 | queryset = Flavor.objects.select_related().all() |
| 2555 | serializer_class = FlavorSerializer |
| 2556 | id_serializer_class = FlavorIdSerializer |
| 2557 | |
| 2558 | def get_serializer_class(self): |
| 2559 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2560 | if (no_hyperlinks): |
| 2561 | return self.id_serializer_class |
| 2562 | else: |
| 2563 | return self.serializer_class |
| 2564 | |
| 2565 | def get_queryset(self): |
| 2566 | return Flavor.select_by_user(self.request.user) |
| 2567 | |
| 2568 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2569 | |
| 2570 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2571 | |
| 2572 | |
| 2573 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2574 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 2575 | queryset = ServiceAttribute.objects.select_related().all() |
| 2576 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2577 | id_serializer_class = ServiceAttributeIdSerializer |
| 2578 | filter_backends = (filters.DjangoFilterBackend,) |
| 2579 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 2580 | |
| 2581 | def get_serializer_class(self): |
| 2582 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2583 | if (no_hyperlinks): |
| 2584 | return self.id_serializer_class |
| 2585 | else: |
| 2586 | return self.serializer_class |
| 2587 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2588 | def get_queryset(self): |
| 2589 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2590 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2591 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2592 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2593 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2594 | response = {"error": "validation", |
| 2595 | "specific_error": "not serializer.is_valid()",
|
| 2596 | "reasons": serializer.errors}
|
| 2597 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2598 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2599 | obj.caller = request.user |
| 2600 | if obj.can_update(request.user): |
| 2601 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2602 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2603 | raise Exception("failed obj.can_update") |
| 2604 | |
| 2605 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2606 | if (ret.status_code%100 != 200): |
| 2607 | raise Exception(ret.data) |
| 2608 | |
| 2609 | return ret |
| 2610 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2611 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2612 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2613 | queryset = ServiceAttribute.objects.select_related().all() |
| 2614 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2615 | id_serializer_class = ServiceAttributeIdSerializer |
| 2616 | |
| 2617 | def get_serializer_class(self): |
| 2618 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2619 | if (no_hyperlinks): |
| 2620 | return self.id_serializer_class |
| 2621 | else: |
| 2622 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2623 | |
| 2624 | def get_queryset(self): |
| 2625 | return ServiceAttribute.select_by_user(self.request.user) |
| 2626 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2627 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2628 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2629 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2630 | |
| 2631 | |
| 2632 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2633 | class ControllerImagesList(generics.ListCreateAPIView): |
| 2634 | queryset = ControllerImages.objects.select_related().all() |
| 2635 | serializer_class = ControllerImagesSerializer |
| 2636 | id_serializer_class = ControllerImagesIdSerializer |
| 2637 | filter_backends = (filters.DjangoFilterBackend,) |
| 2638 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 2639 | |
| 2640 | def get_serializer_class(self): |
| 2641 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2642 | if (no_hyperlinks): |
| 2643 | return self.id_serializer_class |
| 2644 | else: |
| 2645 | return self.serializer_class |
| 2646 | |
| 2647 | def get_queryset(self): |
| 2648 | return ControllerImages.select_by_user(self.request.user) |
| 2649 | |
| 2650 | def create(self, request, *args, **kwargs): |
| 2651 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2652 | if not (serializer.is_valid()): |
| 2653 | response = {"error": "validation", |
| 2654 | "specific_error": "not serializer.is_valid()",
|
| 2655 | "reasons": serializer.errors}
|
| 2656 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2657 | obj = serializer.object |
| 2658 | obj.caller = request.user |
| 2659 | if obj.can_update(request.user): |
| 2660 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2661 | else: |
| 2662 | raise Exception("failed obj.can_update") |
| 2663 | |
| 2664 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2665 | if (ret.status_code%100 != 200): |
| 2666 | raise Exception(ret.data) |
| 2667 | |
| 2668 | return ret |
| 2669 | |
| 2670 | |
| 2671 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2672 | queryset = ControllerImages.objects.select_related().all() |
| 2673 | serializer_class = ControllerImagesSerializer |
| 2674 | id_serializer_class = ControllerImagesIdSerializer |
| 2675 | |
| 2676 | def get_serializer_class(self): |
| 2677 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2678 | if (no_hyperlinks): |
| 2679 | return self.id_serializer_class |
| 2680 | else: |
| 2681 | return self.serializer_class |
| 2682 | |
| 2683 | def get_queryset(self): |
| 2684 | return ControllerImages.select_by_user(self.request.user) |
| 2685 | |
| 2686 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2687 | |
| 2688 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2689 | |
| 2690 | |
| 2691 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2692 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2693 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2694 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2695 | id_serializer_class = ImageIdSerializer |
| 2696 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 2697 | 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] | 2698 | |
| 2699 | def get_serializer_class(self): |
| 2700 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2701 | if (no_hyperlinks): |
| 2702 | return self.id_serializer_class |
| 2703 | else: |
| 2704 | return self.serializer_class |
| 2705 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2706 | def get_queryset(self): |
| 2707 | return Image.select_by_user(self.request.user) |
| 2708 | |
| 2709 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2710 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2711 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2712 | response = {"error": "validation", |
| 2713 | "specific_error": "not serializer.is_valid()",
|
| 2714 | "reasons": serializer.errors}
|
| 2715 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2716 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2717 | obj.caller = request.user |
| 2718 | if obj.can_update(request.user): |
| 2719 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2720 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2721 | raise Exception("failed obj.can_update") |
| 2722 | |
| 2723 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2724 | if (ret.status_code%100 != 200): |
| 2725 | raise Exception(ret.data) |
| 2726 | |
| 2727 | return ret |
| 2728 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2729 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2730 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2731 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2732 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2733 | id_serializer_class = ImageIdSerializer |
| 2734 | |
| 2735 | def get_serializer_class(self): |
| 2736 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2737 | if (no_hyperlinks): |
| 2738 | return self.id_serializer_class |
| 2739 | else: |
| 2740 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2741 | |
| 2742 | def get_queryset(self): |
| 2743 | return Image.select_by_user(self.request.user) |
| 2744 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2745 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2746 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2747 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2748 | |
| 2749 | |
| 2750 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2751 | class NetworkParameterList(generics.ListCreateAPIView): |
| 2752 | queryset = NetworkParameter.objects.select_related().all() |
| 2753 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2754 | id_serializer_class = NetworkParameterIdSerializer |
| 2755 | filter_backends = (filters.DjangoFilterBackend,) |
| 2756 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 2757 | |
| 2758 | def get_serializer_class(self): |
| 2759 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2760 | if (no_hyperlinks): |
| 2761 | return self.id_serializer_class |
| 2762 | else: |
| 2763 | return self.serializer_class |
| 2764 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2765 | def get_queryset(self): |
| 2766 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2767 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2768 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2769 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2770 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2771 | response = {"error": "validation", |
| 2772 | "specific_error": "not serializer.is_valid()",
|
| 2773 | "reasons": serializer.errors}
|
| 2774 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2775 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2776 | obj.caller = request.user |
| 2777 | if obj.can_update(request.user): |
| 2778 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2779 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2780 | raise Exception("failed obj.can_update") |
| 2781 | |
| 2782 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2783 | if (ret.status_code%100 != 200): |
| 2784 | raise Exception(ret.data) |
| 2785 | |
| 2786 | return ret |
| 2787 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2788 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2789 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2790 | queryset = NetworkParameter.objects.select_related().all() |
| 2791 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2792 | id_serializer_class = NetworkParameterIdSerializer |
| 2793 | |
| 2794 | def get_serializer_class(self): |
| 2795 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2796 | if (no_hyperlinks): |
| 2797 | return self.id_serializer_class |
| 2798 | else: |
| 2799 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2800 | |
| 2801 | def get_queryset(self): |
| 2802 | return NetworkParameter.select_by_user(self.request.user) |
| 2803 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2804 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2805 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2806 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2807 | |
| 2808 | |
| 2809 | |
| 2810 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2811 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2812 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2813 | id_serializer_class = SiteIdSerializer |
| 2814 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2815 | 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] | 2816 | |
| 2817 | def get_serializer_class(self): |
| 2818 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2819 | if (no_hyperlinks): |
| 2820 | return self.id_serializer_class |
| 2821 | else: |
| 2822 | return self.serializer_class |
| 2823 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2824 | def get_queryset(self): |
| 2825 | return Site.select_by_user(self.request.user) |
| 2826 | |
| 2827 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2828 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2829 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2830 | response = {"error": "validation", |
| 2831 | "specific_error": "not serializer.is_valid()",
|
| 2832 | "reasons": serializer.errors}
|
| 2833 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2834 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2835 | obj.caller = request.user |
| 2836 | if obj.can_update(request.user): |
| 2837 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2838 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2839 | raise Exception("failed obj.can_update") |
| 2840 | |
| 2841 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2842 | if (ret.status_code%100 != 200): |
| 2843 | raise Exception(ret.data) |
| 2844 | |
| 2845 | return ret |
| 2846 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2847 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2848 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2849 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2850 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2851 | id_serializer_class = SiteIdSerializer |
| 2852 | |
| 2853 | def get_serializer_class(self): |
| 2854 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2855 | if (no_hyperlinks): |
| 2856 | return self.id_serializer_class |
| 2857 | else: |
| 2858 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2859 | |
| 2860 | def get_queryset(self): |
| 2861 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2862 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2863 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2864 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2865 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2866 | |
| 2867 | |
| 2868 | |
| 2869 | class SliceRoleList(generics.ListCreateAPIView): |
| 2870 | queryset = SliceRole.objects.select_related().all() |
| 2871 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2872 | id_serializer_class = SliceRoleIdSerializer |
| 2873 | filter_backends = (filters.DjangoFilterBackend,) |
| 2874 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2875 | |
| 2876 | def get_serializer_class(self): |
| 2877 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2878 | if (no_hyperlinks): |
| 2879 | return self.id_serializer_class |
| 2880 | else: |
| 2881 | return self.serializer_class |
| 2882 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2883 | def get_queryset(self): |
| 2884 | return SliceRole.select_by_user(self.request.user) |
| 2885 | |
| 2886 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2887 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2888 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2889 | response = {"error": "validation", |
| 2890 | "specific_error": "not serializer.is_valid()",
|
| 2891 | "reasons": serializer.errors}
|
| 2892 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2893 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2894 | obj.caller = request.user |
| 2895 | if obj.can_update(request.user): |
| 2896 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2897 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2898 | raise Exception("failed obj.can_update") |
| 2899 | |
| 2900 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2901 | if (ret.status_code%100 != 200): |
| 2902 | raise Exception(ret.data) |
| 2903 | |
| 2904 | return ret |
| 2905 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2906 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2907 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2908 | queryset = SliceRole.objects.select_related().all() |
| 2909 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2910 | id_serializer_class = SliceRoleIdSerializer |
| 2911 | |
| 2912 | def get_serializer_class(self): |
| 2913 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2914 | if (no_hyperlinks): |
| 2915 | return self.id_serializer_class |
| 2916 | else: |
| 2917 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2918 | |
| 2919 | def get_queryset(self): |
| 2920 | return SliceRole.select_by_user(self.request.user) |
| 2921 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2922 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2923 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2924 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2925 | |
| 2926 | |
| 2927 | |
| 2928 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2929 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2930 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2931 | id_serializer_class = TagIdSerializer |
| 2932 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2933 | 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] | 2934 | |
| 2935 | def get_serializer_class(self): |
| 2936 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2937 | if (no_hyperlinks): |
| 2938 | return self.id_serializer_class |
| 2939 | else: |
| 2940 | return self.serializer_class |
| 2941 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2942 | def get_queryset(self): |
| 2943 | return Tag.select_by_user(self.request.user) |
| 2944 | |
| 2945 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2946 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2947 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2948 | response = {"error": "validation", |
| 2949 | "specific_error": "not serializer.is_valid()",
|
| 2950 | "reasons": serializer.errors}
|
| 2951 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2952 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2953 | obj.caller = request.user |
| 2954 | if obj.can_update(request.user): |
| 2955 | return super(TagList, self).create(request, *args, **kwargs) |
| 2956 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2957 | raise Exception("failed obj.can_update") |
| 2958 | |
| 2959 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 2960 | if (ret.status_code%100 != 200): |
| 2961 | raise Exception(ret.data) |
| 2962 | |
| 2963 | return ret |
| 2964 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2965 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2966 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2967 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2968 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2969 | id_serializer_class = TagIdSerializer |
| 2970 | |
| 2971 | def get_serializer_class(self): |
| 2972 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2973 | if (no_hyperlinks): |
| 2974 | return self.id_serializer_class |
| 2975 | else: |
| 2976 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2977 | |
| 2978 | def get_queryset(self): |
| 2979 | return Tag.select_by_user(self.request.user) |
| 2980 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2981 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2982 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2983 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2984 | |
| 2985 | |
| 2986 | |
| 2987 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2988 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2989 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2990 | id_serializer_class = InvoiceIdSerializer |
| 2991 | filter_backends = (filters.DjangoFilterBackend,) |
| 2992 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 2993 | |
| 2994 | def get_serializer_class(self): |
| 2995 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2996 | if (no_hyperlinks): |
| 2997 | return self.id_serializer_class |
| 2998 | else: |
| 2999 | return self.serializer_class |
| 3000 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3001 | def get_queryset(self): |
| 3002 | return Invoice.select_by_user(self.request.user) |
| 3003 | |
| 3004 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3005 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3006 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3007 | response = {"error": "validation", |
| 3008 | "specific_error": "not serializer.is_valid()",
|
| 3009 | "reasons": serializer.errors}
|
| 3010 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3011 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3012 | obj.caller = request.user |
| 3013 | if obj.can_update(request.user): |
| 3014 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 3015 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3016 | raise Exception("failed obj.can_update") |
| 3017 | |
| 3018 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 3019 | if (ret.status_code%100 != 200): |
| 3020 | raise Exception(ret.data) |
| 3021 | |
| 3022 | return ret |
| 3023 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3024 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3025 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3026 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3027 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3028 | id_serializer_class = InvoiceIdSerializer |
| 3029 | |
| 3030 | def get_serializer_class(self): |
| 3031 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3032 | if (no_hyperlinks): |
| 3033 | return self.id_serializer_class |
| 3034 | else: |
| 3035 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3036 | |
| 3037 | def get_queryset(self): |
| 3038 | return Invoice.select_by_user(self.request.user) |
| 3039 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3040 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3041 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3042 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3043 | |
| 3044 | |
| 3045 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3046 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 3047 | queryset = SlicePrivilege.objects.select_related().all() |
| 3048 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3049 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3050 | filter_backends = (filters.DjangoFilterBackend,) |
| 3051 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 3052 | |
| 3053 | def get_serializer_class(self): |
| 3054 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3055 | if (no_hyperlinks): |
| 3056 | return self.id_serializer_class |
| 3057 | else: |
| 3058 | return self.serializer_class |
| 3059 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3060 | def get_queryset(self): |
| 3061 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3062 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3063 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3064 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3065 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3066 | response = {"error": "validation", |
| 3067 | "specific_error": "not serializer.is_valid()",
|
| 3068 | "reasons": serializer.errors}
|
| 3069 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3070 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3071 | obj.caller = request.user |
| 3072 | if obj.can_update(request.user): |
| 3073 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3074 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3075 | raise Exception("failed obj.can_update") |
| 3076 | |
| 3077 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3078 | if (ret.status_code%100 != 200): |
| 3079 | raise Exception(ret.data) |
| 3080 | |
| 3081 | return ret |
| 3082 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3083 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3084 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3085 | queryset = SlicePrivilege.objects.select_related().all() |
| 3086 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3087 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3088 | |
| 3089 | def get_serializer_class(self): |
| 3090 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3091 | if (no_hyperlinks): |
| 3092 | return self.id_serializer_class |
| 3093 | else: |
| 3094 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3095 | |
| 3096 | def get_queryset(self): |
| 3097 | return SlicePrivilege.select_by_user(self.request.user) |
| 3098 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3099 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3100 | |
| 3101 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3102 | |
| 3103 | |
| 3104 | |
| 3105 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 3106 | queryset = PlanetStackRole.objects.select_related().all() |
| 3107 | serializer_class = PlanetStackRoleSerializer |
| 3108 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3109 | filter_backends = (filters.DjangoFilterBackend,) |
| 3110 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3111 | |
| 3112 | def get_serializer_class(self): |
| 3113 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3114 | if (no_hyperlinks): |
| 3115 | return self.id_serializer_class |
| 3116 | else: |
| 3117 | return self.serializer_class |
| 3118 | |
| 3119 | def get_queryset(self): |
| 3120 | return PlanetStackRole.select_by_user(self.request.user) |
| 3121 | |
| 3122 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3123 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3124 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3125 | response = {"error": "validation", |
| 3126 | "specific_error": "not serializer.is_valid()",
|
| 3127 | "reasons": serializer.errors}
|
| 3128 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3129 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3130 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3131 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3132 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3133 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3134 | raise Exception("failed obj.can_update") |
| 3135 | |
| 3136 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 3137 | if (ret.status_code%100 != 200): |
| 3138 | raise Exception(ret.data) |
| 3139 | |
| 3140 | return ret |
| 3141 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3142 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3143 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3144 | queryset = PlanetStackRole.objects.select_related().all() |
| 3145 | serializer_class = PlanetStackRoleSerializer |
| 3146 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3147 | |
| 3148 | def get_serializer_class(self): |
| 3149 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3150 | if (no_hyperlinks): |
| 3151 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3152 | else: |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3153 | return self.serializer_class |
| 3154 | |
| 3155 | def get_queryset(self): |
| 3156 | return PlanetStackRole.select_by_user(self.request.user) |
| 3157 | |
| 3158 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3159 | |
| 3160 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3161 | |
| 3162 | |
| 3163 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3164 | class ControllerPrivilegeList(generics.ListCreateAPIView): |
| 3165 | queryset = ControllerPrivilege.objects.select_related().all() |
| 3166 | serializer_class = ControllerPrivilegeSerializer |
| 3167 | id_serializer_class = ControllerPrivilegeIdSerializer |
| 3168 | filter_backends = (filters.DjangoFilterBackend,) |
| 3169 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 3170 | |
| 3171 | def get_serializer_class(self): |
| 3172 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3173 | if (no_hyperlinks): |
| 3174 | return self.id_serializer_class |
| 3175 | else: |
| 3176 | return self.serializer_class |
| 3177 | |
| 3178 | def get_queryset(self): |
| 3179 | return ControllerPrivilege.select_by_user(self.request.user) |
| 3180 | |
| 3181 | def create(self, request, *args, **kwargs): |
| 3182 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3183 | if not (serializer.is_valid()): |
| 3184 | response = {"error": "validation", |
| 3185 | "specific_error": "not serializer.is_valid()",
|
| 3186 | "reasons": serializer.errors}
|
| 3187 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3188 | obj = serializer.object |
| 3189 | obj.caller = request.user |
| 3190 | if obj.can_update(request.user): |
| 3191 | return super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
| 3192 | else: |
| 3193 | raise Exception("failed obj.can_update") |
| 3194 | |
| 3195 | ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
| 3196 | if (ret.status_code%100 != 200): |
| 3197 | raise Exception(ret.data) |
| 3198 | |
| 3199 | return ret |
| 3200 | |
| 3201 | |
| 3202 | class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3203 | queryset = ControllerPrivilege.objects.select_related().all() |
| 3204 | serializer_class = ControllerPrivilegeSerializer |
| 3205 | id_serializer_class = ControllerPrivilegeIdSerializer |
| 3206 | |
| 3207 | def get_serializer_class(self): |
| 3208 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3209 | if (no_hyperlinks): |
| 3210 | return self.id_serializer_class |
| 3211 | else: |
| 3212 | return self.serializer_class |
| 3213 | |
| 3214 | def get_queryset(self): |
| 3215 | return ControllerPrivilege.select_by_user(self.request.user) |
| 3216 | |
| 3217 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3218 | |
| 3219 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3220 | |
| 3221 | |
| 3222 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3223 | class NetworkSliverList(generics.ListCreateAPIView): |
| 3224 | queryset = NetworkSliver.objects.select_related().all() |
| 3225 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3226 | id_serializer_class = NetworkSliverIdSerializer |
| 3227 | filter_backends = (filters.DjangoFilterBackend,) |
| 3228 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 3229 | |
| 3230 | def get_serializer_class(self): |
| 3231 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3232 | if (no_hyperlinks): |
| 3233 | return self.id_serializer_class |
| 3234 | else: |
| 3235 | return self.serializer_class |
| 3236 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3237 | def get_queryset(self): |
| 3238 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3239 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3240 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3241 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3242 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3243 | response = {"error": "validation", |
| 3244 | "specific_error": "not serializer.is_valid()",
|
| 3245 | "reasons": serializer.errors}
|
| 3246 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3247 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3248 | obj.caller = request.user |
| 3249 | if obj.can_update(request.user): |
| 3250 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3251 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3252 | raise Exception("failed obj.can_update") |
| 3253 | |
| 3254 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3255 | if (ret.status_code%100 != 200): |
| 3256 | raise Exception(ret.data) |
| 3257 | |
| 3258 | return ret |
| 3259 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3260 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3261 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3262 | queryset = NetworkSliver.objects.select_related().all() |
| 3263 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3264 | id_serializer_class = NetworkSliverIdSerializer |
| 3265 | |
| 3266 | def get_serializer_class(self): |
| 3267 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3268 | if (no_hyperlinks): |
| 3269 | return self.id_serializer_class |
| 3270 | else: |
| 3271 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3272 | |
| 3273 | def get_queryset(self): |
| 3274 | return NetworkSliver.select_by_user(self.request.user) |
| 3275 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3276 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3277 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3278 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3279 | |
| 3280 | |
| 3281 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3282 | class ProjectList(generics.ListCreateAPIView): |
| 3283 | queryset = Project.objects.select_related().all() |
| 3284 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3285 | id_serializer_class = ProjectIdSerializer |
| 3286 | filter_backends = (filters.DjangoFilterBackend,) |
| 3287 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3288 | |
| 3289 | def get_serializer_class(self): |
| 3290 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3291 | if (no_hyperlinks): |
| 3292 | return self.id_serializer_class |
| 3293 | else: |
| 3294 | return self.serializer_class |
| 3295 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3296 | def get_queryset(self): |
| 3297 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3298 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3299 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3300 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3301 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3302 | response = {"error": "validation", |
| 3303 | "specific_error": "not serializer.is_valid()",
|
| 3304 | "reasons": serializer.errors}
|
| 3305 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3306 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3307 | obj.caller = request.user |
| 3308 | if obj.can_update(request.user): |
| 3309 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 3310 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3311 | raise Exception("failed obj.can_update") |
| 3312 | |
| 3313 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 3314 | if (ret.status_code%100 != 200): |
| 3315 | raise Exception(ret.data) |
| 3316 | |
| 3317 | return ret |
| 3318 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3319 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3320 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3321 | queryset = Project.objects.select_related().all() |
| 3322 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3323 | id_serializer_class = ProjectIdSerializer |
| 3324 | |
| 3325 | def get_serializer_class(self): |
| 3326 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3327 | if (no_hyperlinks): |
| 3328 | return self.id_serializer_class |
| 3329 | else: |
| 3330 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3331 | |
| 3332 | def get_queryset(self): |
| 3333 | return Project.select_by_user(self.request.user) |
| 3334 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3335 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3336 | |
| 3337 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3338 | |
| 3339 | |
| 3340 | |
| 3341 | class SliceList(generics.ListCreateAPIView): |
| 3342 | queryset = Slice.objects.select_related().all() |
| 3343 | serializer_class = SliceSerializer |
| 3344 | id_serializer_class = SliceIdSerializer |
| 3345 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3346 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3347 | |
| 3348 | def get_serializer_class(self): |
| 3349 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3350 | if (no_hyperlinks): |
| 3351 | return self.id_serializer_class |
| 3352 | else: |
| 3353 | return self.serializer_class |
| 3354 | |
| 3355 | def get_queryset(self): |
| 3356 | return Slice.select_by_user(self.request.user) |
| 3357 | |
| 3358 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3359 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3360 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3361 | response = {"error": "validation", |
| 3362 | "specific_error": "not serializer.is_valid()",
|
| 3363 | "reasons": serializer.errors}
|
| 3364 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3365 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3366 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3367 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3368 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3369 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3370 | raise Exception("failed obj.can_update") |
| 3371 | |
| 3372 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3373 | if (ret.status_code%100 != 200): |
| 3374 | raise Exception(ret.data) |
| 3375 | |
| 3376 | return ret |
| 3377 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3378 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3379 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3380 | queryset = Slice.objects.select_related().all() |
| 3381 | serializer_class = SliceSerializer |
| 3382 | id_serializer_class = SliceIdSerializer |
| 3383 | |
| 3384 | def get_serializer_class(self): |
| 3385 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3386 | if (no_hyperlinks): |
| 3387 | return self.id_serializer_class |
| 3388 | else: |
| 3389 | return self.serializer_class |
| 3390 | |
| 3391 | def get_queryset(self): |
| 3392 | return Slice.select_by_user(self.request.user) |
| 3393 | |
| 3394 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3395 | |
| 3396 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3397 | |
| 3398 | |
| 3399 | |
| 3400 | class NetworkList(generics.ListCreateAPIView): |
| 3401 | queryset = Network.objects.select_related().all() |
| 3402 | serializer_class = NetworkSerializer |
| 3403 | id_serializer_class = NetworkIdSerializer |
| 3404 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | d188c01 | 2015-01-03 12:32:45 -0800 | [diff] [blame] | 3405 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3406 | |
| 3407 | def get_serializer_class(self): |
| 3408 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3409 | if (no_hyperlinks): |
| 3410 | return self.id_serializer_class |
| 3411 | else: |
| 3412 | return self.serializer_class |
| 3413 | |
| 3414 | def get_queryset(self): |
| 3415 | return Network.select_by_user(self.request.user) |
| 3416 | |
| 3417 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3418 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3419 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3420 | response = {"error": "validation", |
| 3421 | "specific_error": "not serializer.is_valid()",
|
| 3422 | "reasons": serializer.errors}
|
| 3423 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3424 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3425 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3426 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3427 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3428 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3429 | raise Exception("failed obj.can_update") |
| 3430 | |
| 3431 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3432 | if (ret.status_code%100 != 200): |
| 3433 | raise Exception(ret.data) |
| 3434 | |
| 3435 | return ret |
| 3436 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3437 | |
| 3438 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3439 | queryset = Network.objects.select_related().all() |
| 3440 | serializer_class = NetworkSerializer |
| 3441 | id_serializer_class = NetworkIdSerializer |
| 3442 | |
| 3443 | def get_serializer_class(self): |
| 3444 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3445 | if (no_hyperlinks): |
| 3446 | return self.id_serializer_class |
| 3447 | else: |
| 3448 | return self.serializer_class |
| 3449 | |
| 3450 | def get_queryset(self): |
| 3451 | return Network.select_by_user(self.request.user) |
| 3452 | |
| 3453 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3454 | |
| 3455 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3456 | |
| 3457 | |
| 3458 | |
| 3459 | class ServiceList(generics.ListCreateAPIView): |
| 3460 | queryset = Service.objects.select_related().all() |
| 3461 | serializer_class = ServiceSerializer |
| 3462 | id_serializer_class = ServiceIdSerializer |
| 3463 | filter_backends = (filters.DjangoFilterBackend,) |
| 3464 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 3465 | |
| 3466 | def get_serializer_class(self): |
| 3467 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3468 | if (no_hyperlinks): |
| 3469 | return self.id_serializer_class |
| 3470 | else: |
| 3471 | return self.serializer_class |
| 3472 | |
| 3473 | def get_queryset(self): |
| 3474 | return Service.select_by_user(self.request.user) |
| 3475 | |
| 3476 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3477 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3478 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3479 | response = {"error": "validation", |
| 3480 | "specific_error": "not serializer.is_valid()",
|
| 3481 | "reasons": serializer.errors}
|
| 3482 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3483 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3484 | obj.caller = request.user |
| 3485 | if obj.can_update(request.user): |
| 3486 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3487 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3488 | raise Exception("failed obj.can_update") |
| 3489 | |
| 3490 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3491 | if (ret.status_code%100 != 200): |
| 3492 | raise Exception(ret.data) |
| 3493 | |
| 3494 | return ret |
| 3495 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3496 | |
| 3497 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3498 | queryset = Service.objects.select_related().all() |
| 3499 | serializer_class = ServiceSerializer |
| 3500 | id_serializer_class = ServiceIdSerializer |
| 3501 | |
| 3502 | def get_serializer_class(self): |
| 3503 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3504 | if (no_hyperlinks): |
| 3505 | return self.id_serializer_class |
| 3506 | else: |
| 3507 | return self.serializer_class |
| 3508 | |
| 3509 | def get_queryset(self): |
| 3510 | return Service.select_by_user(self.request.user) |
| 3511 | |
| 3512 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3513 | |
| 3514 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3515 | |
| 3516 | |
| 3517 | |
| 3518 | class ServiceClassList(generics.ListCreateAPIView): |
| 3519 | queryset = ServiceClass.objects.select_related().all() |
| 3520 | serializer_class = ServiceClassSerializer |
| 3521 | id_serializer_class = ServiceClassIdSerializer |
| 3522 | filter_backends = (filters.DjangoFilterBackend,) |
| 3523 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 3524 | |
| 3525 | def get_serializer_class(self): |
| 3526 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3527 | if (no_hyperlinks): |
| 3528 | return self.id_serializer_class |
| 3529 | else: |
| 3530 | return self.serializer_class |
| 3531 | |
| 3532 | def get_queryset(self): |
| 3533 | return ServiceClass.select_by_user(self.request.user) |
| 3534 | |
| 3535 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3536 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3537 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3538 | response = {"error": "validation", |
| 3539 | "specific_error": "not serializer.is_valid()",
|
| 3540 | "reasons": serializer.errors}
|
| 3541 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3542 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3543 | obj.caller = request.user |
| 3544 | if obj.can_update(request.user): |
| 3545 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3546 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3547 | raise Exception("failed obj.can_update") |
| 3548 | |
| 3549 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3550 | if (ret.status_code%100 != 200): |
| 3551 | raise Exception(ret.data) |
| 3552 | |
| 3553 | return ret |
| 3554 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3555 | |
| 3556 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3557 | queryset = ServiceClass.objects.select_related().all() |
| 3558 | serializer_class = ServiceClassSerializer |
| 3559 | id_serializer_class = ServiceClassIdSerializer |
| 3560 | |
| 3561 | def get_serializer_class(self): |
| 3562 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3563 | if (no_hyperlinks): |
| 3564 | return self.id_serializer_class |
| 3565 | else: |
| 3566 | return self.serializer_class |
| 3567 | |
| 3568 | def get_queryset(self): |
| 3569 | return ServiceClass.select_by_user(self.request.user) |
| 3570 | |
| 3571 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3572 | |
| 3573 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3574 | |
| 3575 | |
| 3576 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3577 | class ControllerNetworkList(generics.ListCreateAPIView): |
| 3578 | queryset = ControllerNetwork.objects.select_related().all() |
| 3579 | serializer_class = ControllerNetworkSerializer |
| 3580 | id_serializer_class = ControllerNetworkIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3581 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3582 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3583 | |
| 3584 | def get_serializer_class(self): |
| 3585 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3586 | if (no_hyperlinks): |
| 3587 | return self.id_serializer_class |
| 3588 | else: |
| 3589 | return self.serializer_class |
| 3590 | |
| 3591 | def get_queryset(self): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3592 | return ControllerNetwork.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3593 | |
| 3594 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3595 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3596 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3597 | response = {"error": "validation", |
| 3598 | "specific_error": "not serializer.is_valid()",
|
| 3599 | "reasons": serializer.errors}
|
| 3600 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3601 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3602 | obj.caller = request.user |
| 3603 | if obj.can_update(request.user): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3604 | return super(ControllerNetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3605 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3606 | raise Exception("failed obj.can_update") |
| 3607 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3608 | ret = super(ControllerNetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3609 | if (ret.status_code%100 != 200): |
| 3610 | raise Exception(ret.data) |
| 3611 | |
| 3612 | return ret |
| 3613 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3614 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3615 | class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3616 | queryset = ControllerNetwork.objects.select_related().all() |
| 3617 | serializer_class = ControllerNetworkSerializer |
| 3618 | id_serializer_class = ControllerNetworkIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3619 | |
| 3620 | def get_serializer_class(self): |
| 3621 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3622 | if (no_hyperlinks): |
| 3623 | return self.id_serializer_class |
| 3624 | else: |
| 3625 | return self.serializer_class |
| 3626 | |
| 3627 | def get_queryset(self): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 3628 | return ControllerNetwork.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3629 | |
| 3630 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3631 | |
| 3632 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3633 | |
| 3634 | |
| 3635 | |
| 3636 | class ChargeList(generics.ListCreateAPIView): |
| 3637 | queryset = Charge.objects.select_related().all() |
| 3638 | serializer_class = ChargeSerializer |
| 3639 | id_serializer_class = ChargeIdSerializer |
| 3640 | filter_backends = (filters.DjangoFilterBackend,) |
| 3641 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 3642 | |
| 3643 | def get_serializer_class(self): |
| 3644 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3645 | if (no_hyperlinks): |
| 3646 | return self.id_serializer_class |
| 3647 | else: |
| 3648 | return self.serializer_class |
| 3649 | |
| 3650 | def get_queryset(self): |
| 3651 | return Charge.select_by_user(self.request.user) |
| 3652 | |
| 3653 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3654 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3655 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3656 | response = {"error": "validation", |
| 3657 | "specific_error": "not serializer.is_valid()",
|
| 3658 | "reasons": serializer.errors}
|
| 3659 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3660 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3661 | obj.caller = request.user |
| 3662 | if obj.can_update(request.user): |
| 3663 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3664 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3665 | raise Exception("failed obj.can_update") |
| 3666 | |
| 3667 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3668 | if (ret.status_code%100 != 200): |
| 3669 | raise Exception(ret.data) |
| 3670 | |
| 3671 | return ret |
| 3672 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3673 | |
| 3674 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3675 | queryset = Charge.objects.select_related().all() |
| 3676 | serializer_class = ChargeSerializer |
| 3677 | id_serializer_class = ChargeIdSerializer |
| 3678 | |
| 3679 | def get_serializer_class(self): |
| 3680 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3681 | if (no_hyperlinks): |
| 3682 | return self.id_serializer_class |
| 3683 | else: |
| 3684 | return self.serializer_class |
| 3685 | |
| 3686 | def get_queryset(self): |
| 3687 | return Charge.select_by_user(self.request.user) |
| 3688 | |
| 3689 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3690 | |
| 3691 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3692 | |
| 3693 | |
| 3694 | |
| 3695 | class RoleList(generics.ListCreateAPIView): |
| 3696 | queryset = Role.objects.select_related().all() |
| 3697 | serializer_class = RoleSerializer |
| 3698 | id_serializer_class = RoleIdSerializer |
| 3699 | filter_backends = (filters.DjangoFilterBackend,) |
| 3700 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 3701 | |
| 3702 | def get_serializer_class(self): |
| 3703 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3704 | if (no_hyperlinks): |
| 3705 | return self.id_serializer_class |
| 3706 | else: |
| 3707 | return self.serializer_class |
| 3708 | |
| 3709 | def get_queryset(self): |
| 3710 | return Role.select_by_user(self.request.user) |
| 3711 | |
| 3712 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3713 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3714 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3715 | response = {"error": "validation", |
| 3716 | "specific_error": "not serializer.is_valid()",
|
| 3717 | "reasons": serializer.errors}
|
| 3718 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3719 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3720 | obj.caller = request.user |
| 3721 | if obj.can_update(request.user): |
| 3722 | return super(RoleList, self).create(request, *args, **kwargs) |
| 3723 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3724 | raise Exception("failed obj.can_update") |
| 3725 | |
| 3726 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 3727 | if (ret.status_code%100 != 200): |
| 3728 | raise Exception(ret.data) |
| 3729 | |
| 3730 | return ret |
| 3731 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3732 | |
| 3733 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3734 | queryset = Role.objects.select_related().all() |
| 3735 | serializer_class = RoleSerializer |
| 3736 | id_serializer_class = RoleIdSerializer |
| 3737 | |
| 3738 | def get_serializer_class(self): |
| 3739 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3740 | if (no_hyperlinks): |
| 3741 | return self.id_serializer_class |
| 3742 | else: |
| 3743 | return self.serializer_class |
| 3744 | |
| 3745 | def get_queryset(self): |
| 3746 | return Role.select_by_user(self.request.user) |
| 3747 | |
| 3748 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3749 | |
| 3750 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3751 | |
| 3752 | |
| 3753 | |
| 3754 | class UsableObjectList(generics.ListCreateAPIView): |
| 3755 | queryset = UsableObject.objects.select_related().all() |
| 3756 | serializer_class = UsableObjectSerializer |
| 3757 | id_serializer_class = UsableObjectIdSerializer |
| 3758 | filter_backends = (filters.DjangoFilterBackend,) |
| 3759 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3760 | |
| 3761 | def get_serializer_class(self): |
| 3762 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3763 | if (no_hyperlinks): |
| 3764 | return self.id_serializer_class |
| 3765 | else: |
| 3766 | return self.serializer_class |
| 3767 | |
| 3768 | def get_queryset(self): |
| 3769 | return UsableObject.select_by_user(self.request.user) |
| 3770 | |
| 3771 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3772 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3773 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3774 | response = {"error": "validation", |
| 3775 | "specific_error": "not serializer.is_valid()",
|
| 3776 | "reasons": serializer.errors}
|
| 3777 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3778 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3779 | obj.caller = request.user |
| 3780 | if obj.can_update(request.user): |
| 3781 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3782 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3783 | raise Exception("failed obj.can_update") |
| 3784 | |
| 3785 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3786 | if (ret.status_code%100 != 200): |
| 3787 | raise Exception(ret.data) |
| 3788 | |
| 3789 | return ret |
| 3790 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3791 | |
| 3792 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3793 | queryset = UsableObject.objects.select_related().all() |
| 3794 | serializer_class = UsableObjectSerializer |
| 3795 | id_serializer_class = UsableObjectIdSerializer |
| 3796 | |
| 3797 | def get_serializer_class(self): |
| 3798 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3799 | if (no_hyperlinks): |
| 3800 | return self.id_serializer_class |
| 3801 | else: |
| 3802 | return self.serializer_class |
| 3803 | |
| 3804 | def get_queryset(self): |
| 3805 | return UsableObject.select_by_user(self.request.user) |
| 3806 | |
| 3807 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3808 | |
| 3809 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3810 | |
| 3811 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3812 | class SiteRoleList(generics.ListCreateAPIView): |
| 3813 | queryset = SiteRole.objects.select_related().all() |
| 3814 | serializer_class = SiteRoleSerializer |
| 3815 | id_serializer_class = SiteRoleIdSerializer |
| 3816 | filter_backends = (filters.DjangoFilterBackend,) |
| 3817 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3818 | |
| 3819 | def get_serializer_class(self): |
| 3820 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3821 | if (no_hyperlinks): |
| 3822 | return self.id_serializer_class |
| 3823 | else: |
| 3824 | return self.serializer_class |
| 3825 | |
| 3826 | def get_queryset(self): |
| 3827 | return SiteRole.select_by_user(self.request.user) |
| 3828 | |
| 3829 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3830 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3831 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3832 | response = {"error": "validation", |
| 3833 | "specific_error": "not serializer.is_valid()",
|
| 3834 | "reasons": serializer.errors}
|
| 3835 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3836 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3837 | obj.caller = request.user |
| 3838 | if obj.can_update(request.user): |
| 3839 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3840 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3841 | raise Exception("failed obj.can_update") |
| 3842 | |
| 3843 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3844 | if (ret.status_code%100 != 200): |
| 3845 | raise Exception(ret.data) |
| 3846 | |
| 3847 | return ret |
| 3848 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3849 | |
| 3850 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3851 | queryset = SiteRole.objects.select_related().all() |
| 3852 | serializer_class = SiteRoleSerializer |
| 3853 | id_serializer_class = SiteRoleIdSerializer |
| 3854 | |
| 3855 | def get_serializer_class(self): |
| 3856 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3857 | if (no_hyperlinks): |
| 3858 | return self.id_serializer_class |
| 3859 | else: |
| 3860 | return self.serializer_class |
| 3861 | |
| 3862 | def get_queryset(self): |
| 3863 | return SiteRole.select_by_user(self.request.user) |
| 3864 | |
| 3865 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3866 | |
| 3867 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3868 | |
| 3869 | |
| 3870 | |
| 3871 | class SliceCredentialList(generics.ListCreateAPIView): |
| 3872 | queryset = SliceCredential.objects.select_related().all() |
| 3873 | serializer_class = SliceCredentialSerializer |
| 3874 | id_serializer_class = SliceCredentialIdSerializer |
| 3875 | filter_backends = (filters.DjangoFilterBackend,) |
| 3876 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 3877 | |
| 3878 | def get_serializer_class(self): |
| 3879 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3880 | if (no_hyperlinks): |
| 3881 | return self.id_serializer_class |
| 3882 | else: |
| 3883 | return self.serializer_class |
| 3884 | |
| 3885 | def get_queryset(self): |
| 3886 | return SliceCredential.select_by_user(self.request.user) |
| 3887 | |
| 3888 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3889 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3890 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3891 | response = {"error": "validation", |
| 3892 | "specific_error": "not serializer.is_valid()",
|
| 3893 | "reasons": serializer.errors}
|
| 3894 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3895 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3896 | obj.caller = request.user |
| 3897 | if obj.can_update(request.user): |
| 3898 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3899 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3900 | raise Exception("failed obj.can_update") |
| 3901 | |
| 3902 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3903 | if (ret.status_code%100 != 200): |
| 3904 | raise Exception(ret.data) |
| 3905 | |
| 3906 | return ret |
| 3907 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3908 | |
| 3909 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3910 | queryset = SliceCredential.objects.select_related().all() |
| 3911 | serializer_class = SliceCredentialSerializer |
| 3912 | id_serializer_class = SliceCredentialIdSerializer |
| 3913 | |
| 3914 | def get_serializer_class(self): |
| 3915 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3916 | if (no_hyperlinks): |
| 3917 | return self.id_serializer_class |
| 3918 | else: |
| 3919 | return self.serializer_class |
| 3920 | |
| 3921 | def get_queryset(self): |
| 3922 | return SliceCredential.select_by_user(self.request.user) |
| 3923 | |
| 3924 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3925 | |
| 3926 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3927 | |
| 3928 | |
| 3929 | |
| 3930 | class SliverList(generics.ListCreateAPIView): |
| 3931 | queryset = Sliver.objects.select_related().all() |
| 3932 | serializer_class = SliverSerializer |
| 3933 | id_serializer_class = SliverIdSerializer |
| 3934 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 3935 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3936 | |
| 3937 | def get_serializer_class(self): |
| 3938 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3939 | if (no_hyperlinks): |
| 3940 | return self.id_serializer_class |
| 3941 | else: |
| 3942 | return self.serializer_class |
| 3943 | |
| 3944 | def get_queryset(self): |
| 3945 | return Sliver.select_by_user(self.request.user) |
| 3946 | |
| 3947 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3948 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3949 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3950 | response = {"error": "validation", |
| 3951 | "specific_error": "not serializer.is_valid()",
|
| 3952 | "reasons": serializer.errors}
|
| 3953 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3954 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3955 | obj.caller = request.user |
| 3956 | if obj.can_update(request.user): |
| 3957 | return super(SliverList, self).create(request, *args, **kwargs) |
| 3958 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3959 | raise Exception("failed obj.can_update") |
| 3960 | |
| 3961 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 3962 | if (ret.status_code%100 != 200): |
| 3963 | raise Exception(ret.data) |
| 3964 | |
| 3965 | return ret |
| 3966 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3967 | |
| 3968 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3969 | queryset = Sliver.objects.select_related().all() |
| 3970 | serializer_class = SliverSerializer |
| 3971 | id_serializer_class = SliverIdSerializer |
| 3972 | |
| 3973 | def get_serializer_class(self): |
| 3974 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3975 | if (no_hyperlinks): |
| 3976 | return self.id_serializer_class |
| 3977 | else: |
| 3978 | return self.serializer_class |
| 3979 | |
| 3980 | def get_queryset(self): |
| 3981 | return Sliver.select_by_user(self.request.user) |
| 3982 | |
| 3983 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3984 | |
| 3985 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3986 | |
| 3987 | |
| 3988 | |
| 3989 | class NodeList(generics.ListCreateAPIView): |
| 3990 | queryset = Node.objects.select_related().all() |
| 3991 | serializer_class = NodeSerializer |
| 3992 | id_serializer_class = NodeIdSerializer |
| 3993 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3994 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3995 | |
| 3996 | def get_serializer_class(self): |
| 3997 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3998 | if (no_hyperlinks): |
| 3999 | return self.id_serializer_class |
| 4000 | else: |
| 4001 | return self.serializer_class |
| 4002 | |
| 4003 | def get_queryset(self): |
| 4004 | return Node.select_by_user(self.request.user) |
| 4005 | |
| 4006 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4007 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4008 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4009 | response = {"error": "validation", |
| 4010 | "specific_error": "not serializer.is_valid()",
|
| 4011 | "reasons": serializer.errors}
|
| 4012 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4013 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4014 | obj.caller = request.user |
| 4015 | if obj.can_update(request.user): |
| 4016 | return super(NodeList, self).create(request, *args, **kwargs) |
| 4017 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4018 | raise Exception("failed obj.can_update") |
| 4019 | |
| 4020 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 4021 | if (ret.status_code%100 != 200): |
| 4022 | raise Exception(ret.data) |
| 4023 | |
| 4024 | return ret |
| 4025 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4026 | |
| 4027 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4028 | queryset = Node.objects.select_related().all() |
| 4029 | serializer_class = NodeSerializer |
| 4030 | id_serializer_class = NodeIdSerializer |
| 4031 | |
| 4032 | def get_serializer_class(self): |
| 4033 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4034 | if (no_hyperlinks): |
| 4035 | return self.id_serializer_class |
| 4036 | else: |
| 4037 | return self.serializer_class |
| 4038 | |
| 4039 | def get_queryset(self): |
| 4040 | return Node.select_by_user(self.request.user) |
| 4041 | |
| 4042 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4043 | |
| 4044 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4045 | |
| 4046 | |
| 4047 | |
| 4048 | class DashboardViewList(generics.ListCreateAPIView): |
| 4049 | queryset = DashboardView.objects.select_related().all() |
| 4050 | serializer_class = DashboardViewSerializer |
| 4051 | id_serializer_class = DashboardViewIdSerializer |
| 4052 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4053 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4054 | |
| 4055 | def get_serializer_class(self): |
| 4056 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4057 | if (no_hyperlinks): |
| 4058 | return self.id_serializer_class |
| 4059 | else: |
| 4060 | return self.serializer_class |
| 4061 | |
| 4062 | def get_queryset(self): |
| 4063 | return DashboardView.select_by_user(self.request.user) |
| 4064 | |
| 4065 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4066 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4067 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4068 | response = {"error": "validation", |
| 4069 | "specific_error": "not serializer.is_valid()",
|
| 4070 | "reasons": serializer.errors}
|
| 4071 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4072 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4073 | obj.caller = request.user |
| 4074 | if obj.can_update(request.user): |
| 4075 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4076 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4077 | raise Exception("failed obj.can_update") |
| 4078 | |
| 4079 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4080 | if (ret.status_code%100 != 200): |
| 4081 | raise Exception(ret.data) |
| 4082 | |
| 4083 | return ret |
| 4084 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4085 | |
| 4086 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4087 | queryset = DashboardView.objects.select_related().all() |
| 4088 | serializer_class = DashboardViewSerializer |
| 4089 | id_serializer_class = DashboardViewIdSerializer |
| 4090 | |
| 4091 | def get_serializer_class(self): |
| 4092 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4093 | if (no_hyperlinks): |
| 4094 | return self.id_serializer_class |
| 4095 | else: |
| 4096 | return self.serializer_class |
| 4097 | |
| 4098 | def get_queryset(self): |
| 4099 | return DashboardView.select_by_user(self.request.user) |
| 4100 | |
| 4101 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4102 | |
| 4103 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4104 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4105 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4106 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4107 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 4108 | queryset = ImageDeployments.objects.select_related().all() |
| 4109 | serializer_class = ImageDeploymentsSerializer |
| 4110 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4111 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4112 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4113 | |
| 4114 | def get_serializer_class(self): |
| 4115 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4116 | if (no_hyperlinks): |
| 4117 | return self.id_serializer_class |
| 4118 | else: |
| 4119 | return self.serializer_class |
| 4120 | |
| 4121 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4122 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4123 | |
| 4124 | def create(self, request, *args, **kwargs): |
| 4125 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4126 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4127 | response = {"error": "validation", |
| 4128 | "specific_error": "not serializer.is_valid()",
|
| 4129 | "reasons": serializer.errors}
|
| 4130 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4131 | obj = serializer.object |
| 4132 | obj.caller = request.user |
| 4133 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4134 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4135 | else: |
| 4136 | raise Exception("failed obj.can_update") |
| 4137 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4138 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4139 | if (ret.status_code%100 != 200): |
| 4140 | raise Exception(ret.data) |
| 4141 | |
| 4142 | return ret |
| 4143 | |
| 4144 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4145 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4146 | queryset = ImageDeployments.objects.select_related().all() |
| 4147 | serializer_class = ImageDeploymentsSerializer |
| 4148 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4149 | |
| 4150 | def get_serializer_class(self): |
| 4151 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4152 | if (no_hyperlinks): |
| 4153 | return self.id_serializer_class |
| 4154 | else: |
| 4155 | return self.serializer_class |
| 4156 | |
| 4157 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4158 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4159 | |
| 4160 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4161 | |
| 4162 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4163 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4164 | |
| 4165 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4166 | class ReservedResourceList(generics.ListCreateAPIView): |
| 4167 | queryset = ReservedResource.objects.select_related().all() |
| 4168 | serializer_class = ReservedResourceSerializer |
| 4169 | id_serializer_class = ReservedResourceIdSerializer |
| 4170 | filter_backends = (filters.DjangoFilterBackend,) |
| 4171 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 4172 | |
| 4173 | def get_serializer_class(self): |
| 4174 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4175 | if (no_hyperlinks): |
| 4176 | return self.id_serializer_class |
| 4177 | else: |
| 4178 | return self.serializer_class |
| 4179 | |
| 4180 | def get_queryset(self): |
| 4181 | return ReservedResource.select_by_user(self.request.user) |
| 4182 | |
| 4183 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4184 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4185 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4186 | response = {"error": "validation", |
| 4187 | "specific_error": "not serializer.is_valid()",
|
| 4188 | "reasons": serializer.errors}
|
| 4189 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4190 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4191 | obj.caller = request.user |
| 4192 | if obj.can_update(request.user): |
| 4193 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4194 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4195 | raise Exception("failed obj.can_update") |
| 4196 | |
| 4197 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4198 | if (ret.status_code%100 != 200): |
| 4199 | raise Exception(ret.data) |
| 4200 | |
| 4201 | return ret |
| 4202 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4203 | |
| 4204 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4205 | queryset = ReservedResource.objects.select_related().all() |
| 4206 | serializer_class = ReservedResourceSerializer |
| 4207 | id_serializer_class = ReservedResourceIdSerializer |
| 4208 | |
| 4209 | def get_serializer_class(self): |
| 4210 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4211 | if (no_hyperlinks): |
| 4212 | return self.id_serializer_class |
| 4213 | else: |
| 4214 | return self.serializer_class |
| 4215 | |
| 4216 | def get_queryset(self): |
| 4217 | return ReservedResource.select_by_user(self.request.user) |
| 4218 | |
| 4219 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4220 | |
| 4221 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4222 | |
| 4223 | |
| 4224 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4225 | class PaymentList(generics.ListCreateAPIView): |
| 4226 | queryset = Payment.objects.select_related().all() |
| 4227 | serializer_class = PaymentSerializer |
| 4228 | id_serializer_class = PaymentIdSerializer |
| 4229 | filter_backends = (filters.DjangoFilterBackend,) |
| 4230 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 4231 | |
| 4232 | def get_serializer_class(self): |
| 4233 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4234 | if (no_hyperlinks): |
| 4235 | return self.id_serializer_class |
| 4236 | else: |
| 4237 | return self.serializer_class |
| 4238 | |
| 4239 | def get_queryset(self): |
| 4240 | return Payment.select_by_user(self.request.user) |
| 4241 | |
| 4242 | def create(self, request, *args, **kwargs): |
| 4243 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4244 | if not (serializer.is_valid()): |
| 4245 | response = {"error": "validation", |
| 4246 | "specific_error": "not serializer.is_valid()",
|
| 4247 | "reasons": serializer.errors}
|
| 4248 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4249 | obj = serializer.object |
| 4250 | obj.caller = request.user |
| 4251 | if obj.can_update(request.user): |
| 4252 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 4253 | else: |
| 4254 | raise Exception("failed obj.can_update") |
| 4255 | |
| 4256 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 4257 | if (ret.status_code%100 != 200): |
| 4258 | raise Exception(ret.data) |
| 4259 | |
| 4260 | return ret |
| 4261 | |
| 4262 | |
| 4263 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4264 | queryset = Payment.objects.select_related().all() |
| 4265 | serializer_class = PaymentSerializer |
| 4266 | id_serializer_class = PaymentIdSerializer |
| 4267 | |
| 4268 | def get_serializer_class(self): |
| 4269 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4270 | if (no_hyperlinks): |
| 4271 | return self.id_serializer_class |
| 4272 | else: |
| 4273 | return self.serializer_class |
| 4274 | |
| 4275 | def get_queryset(self): |
| 4276 | return Payment.select_by_user(self.request.user) |
| 4277 | |
| 4278 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4279 | |
| 4280 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4281 | |
| 4282 | |
| 4283 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4284 | class NetworkSliceList(generics.ListCreateAPIView): |
| 4285 | queryset = NetworkSlice.objects.select_related().all() |
| 4286 | serializer_class = NetworkSliceSerializer |
| 4287 | id_serializer_class = NetworkSliceIdSerializer |
| 4288 | filter_backends = (filters.DjangoFilterBackend,) |
| 4289 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 4290 | |
| 4291 | def get_serializer_class(self): |
| 4292 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4293 | if (no_hyperlinks): |
| 4294 | return self.id_serializer_class |
| 4295 | else: |
| 4296 | return self.serializer_class |
| 4297 | |
| 4298 | def get_queryset(self): |
| 4299 | return NetworkSlice.select_by_user(self.request.user) |
| 4300 | |
| 4301 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4302 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4303 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4304 | response = {"error": "validation", |
| 4305 | "specific_error": "not serializer.is_valid()",
|
| 4306 | "reasons": serializer.errors}
|
| 4307 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4308 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4309 | obj.caller = request.user |
| 4310 | if obj.can_update(request.user): |
| 4311 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4312 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4313 | raise Exception("failed obj.can_update") |
| 4314 | |
| 4315 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4316 | if (ret.status_code%100 != 200): |
| 4317 | raise Exception(ret.data) |
| 4318 | |
| 4319 | return ret |
| 4320 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4321 | |
| 4322 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4323 | queryset = NetworkSlice.objects.select_related().all() |
| 4324 | serializer_class = NetworkSliceSerializer |
| 4325 | id_serializer_class = NetworkSliceIdSerializer |
| 4326 | |
| 4327 | def get_serializer_class(self): |
| 4328 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4329 | if (no_hyperlinks): |
| 4330 | return self.id_serializer_class |
| 4331 | else: |
| 4332 | return self.serializer_class |
| 4333 | |
| 4334 | def get_queryset(self): |
| 4335 | return NetworkSlice.select_by_user(self.request.user) |
| 4336 | |
| 4337 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4338 | |
| 4339 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4340 | |
| 4341 | |
| 4342 | |
| 4343 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 4344 | queryset = UserDashboardView.objects.select_related().all() |
| 4345 | serializer_class = UserDashboardViewSerializer |
| 4346 | id_serializer_class = UserDashboardViewIdSerializer |
| 4347 | filter_backends = (filters.DjangoFilterBackend,) |
| 4348 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 4349 | |
| 4350 | def get_serializer_class(self): |
| 4351 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4352 | if (no_hyperlinks): |
| 4353 | return self.id_serializer_class |
| 4354 | else: |
| 4355 | return self.serializer_class |
| 4356 | |
| 4357 | def get_queryset(self): |
| 4358 | return UserDashboardView.select_by_user(self.request.user) |
| 4359 | |
| 4360 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4361 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4362 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4363 | response = {"error": "validation", |
| 4364 | "specific_error": "not serializer.is_valid()",
|
| 4365 | "reasons": serializer.errors}
|
| 4366 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4367 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4368 | obj.caller = request.user |
| 4369 | if obj.can_update(request.user): |
| 4370 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4371 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4372 | raise Exception("failed obj.can_update") |
| 4373 | |
| 4374 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4375 | if (ret.status_code%100 != 200): |
| 4376 | raise Exception(ret.data) |
| 4377 | |
| 4378 | return ret |
| 4379 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4380 | |
| 4381 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4382 | queryset = UserDashboardView.objects.select_related().all() |
| 4383 | serializer_class = UserDashboardViewSerializer |
| 4384 | id_serializer_class = UserDashboardViewIdSerializer |
| 4385 | |
| 4386 | def get_serializer_class(self): |
| 4387 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4388 | if (no_hyperlinks): |
| 4389 | return self.id_serializer_class |
| 4390 | else: |
| 4391 | return self.serializer_class |
| 4392 | |
| 4393 | def get_queryset(self): |
| 4394 | return UserDashboardView.select_by_user(self.request.user) |
| 4395 | |
| 4396 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4397 | |
| 4398 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4399 | |
| 4400 | |
| 4401 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4402 | class ControllerList(generics.ListCreateAPIView): |
| 4403 | queryset = Controller.objects.select_related().all() |
| 4404 | serializer_class = ControllerSerializer |
| 4405 | id_serializer_class = ControllerIdSerializer |
| 4406 | filter_backends = (filters.DjangoFilterBackend,) |
| 4407 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 4408 | |
| 4409 | def get_serializer_class(self): |
| 4410 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4411 | if (no_hyperlinks): |
| 4412 | return self.id_serializer_class |
| 4413 | else: |
| 4414 | return self.serializer_class |
| 4415 | |
| 4416 | def get_queryset(self): |
| 4417 | return Controller.select_by_user(self.request.user) |
| 4418 | |
| 4419 | def create(self, request, *args, **kwargs): |
| 4420 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4421 | if not (serializer.is_valid()): |
| 4422 | response = {"error": "validation", |
| 4423 | "specific_error": "not serializer.is_valid()",
|
| 4424 | "reasons": serializer.errors}
|
| 4425 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4426 | obj = serializer.object |
| 4427 | obj.caller = request.user |
| 4428 | if obj.can_update(request.user): |
| 4429 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4430 | else: |
| 4431 | raise Exception("failed obj.can_update") |
| 4432 | |
| 4433 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 4434 | if (ret.status_code%100 != 200): |
| 4435 | raise Exception(ret.data) |
| 4436 | |
| 4437 | return ret |
| 4438 | |
| 4439 | |
| 4440 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4441 | queryset = Controller.objects.select_related().all() |
| 4442 | serializer_class = ControllerSerializer |
| 4443 | id_serializer_class = ControllerIdSerializer |
| 4444 | |
| 4445 | def get_serializer_class(self): |
| 4446 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4447 | if (no_hyperlinks): |
| 4448 | return self.id_serializer_class |
| 4449 | else: |
| 4450 | return self.serializer_class |
| 4451 | |
| 4452 | def get_queryset(self): |
| 4453 | return Controller.select_by_user(self.request.user) |
| 4454 | |
| 4455 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4456 | |
| 4457 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4458 | |
| 4459 | |
| 4460 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4461 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 4462 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4463 | serializer_class = PlanetStackPrivilegeSerializer |
| 4464 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4465 | filter_backends = (filters.DjangoFilterBackend,) |
| 4466 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 4467 | |
| 4468 | def get_serializer_class(self): |
| 4469 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4470 | if (no_hyperlinks): |
| 4471 | return self.id_serializer_class |
| 4472 | else: |
| 4473 | return self.serializer_class |
| 4474 | |
| 4475 | def get_queryset(self): |
| 4476 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4477 | |
| 4478 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4479 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4480 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4481 | response = {"error": "validation", |
| 4482 | "specific_error": "not serializer.is_valid()",
|
| 4483 | "reasons": serializer.errors}
|
| 4484 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4485 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4486 | obj.caller = request.user |
| 4487 | if obj.can_update(request.user): |
| 4488 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4489 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4490 | raise Exception("failed obj.can_update") |
| 4491 | |
| 4492 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4493 | if (ret.status_code%100 != 200): |
| 4494 | raise Exception(ret.data) |
| 4495 | |
| 4496 | return ret |
| 4497 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4498 | |
| 4499 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4500 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4501 | serializer_class = PlanetStackPrivilegeSerializer |
| 4502 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4503 | |
| 4504 | def get_serializer_class(self): |
| 4505 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4506 | if (no_hyperlinks): |
| 4507 | return self.id_serializer_class |
| 4508 | else: |
| 4509 | return self.serializer_class |
| 4510 | |
| 4511 | def get_queryset(self): |
| 4512 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4513 | |
| 4514 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4515 | |
| 4516 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4517 | |
| 4518 | |
| 4519 | |
| 4520 | class UserList(generics.ListCreateAPIView): |
| 4521 | queryset = User.objects.select_related().all() |
| 4522 | serializer_class = UserSerializer |
| 4523 | id_serializer_class = UserIdSerializer |
| 4524 | filter_backends = (filters.DjangoFilterBackend,) |
| 4525 | 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',) |
| 4526 | |
| 4527 | def get_serializer_class(self): |
| 4528 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4529 | if (no_hyperlinks): |
| 4530 | return self.id_serializer_class |
| 4531 | else: |
| 4532 | return self.serializer_class |
| 4533 | |
| 4534 | def get_queryset(self): |
| 4535 | return User.select_by_user(self.request.user) |
| 4536 | |
| 4537 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4538 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4539 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4540 | response = {"error": "validation", |
| 4541 | "specific_error": "not serializer.is_valid()",
|
| 4542 | "reasons": serializer.errors}
|
| 4543 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4544 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4545 | obj.caller = request.user |
| 4546 | if obj.can_update(request.user): |
| 4547 | return super(UserList, self).create(request, *args, **kwargs) |
| 4548 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4549 | raise Exception("failed obj.can_update") |
| 4550 | |
| 4551 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 4552 | if (ret.status_code%100 != 200): |
| 4553 | raise Exception(ret.data) |
| 4554 | |
| 4555 | return ret |
| 4556 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4557 | |
| 4558 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4559 | queryset = User.objects.select_related().all() |
| 4560 | serializer_class = UserSerializer |
| 4561 | id_serializer_class = UserIdSerializer |
| 4562 | |
| 4563 | def get_serializer_class(self): |
| 4564 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4565 | if (no_hyperlinks): |
| 4566 | return self.id_serializer_class |
| 4567 | else: |
| 4568 | return self.serializer_class |
| 4569 | |
| 4570 | def get_queryset(self): |
| 4571 | return User.select_by_user(self.request.user) |
| 4572 | |
| 4573 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4574 | |
| 4575 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4576 | |
| 4577 | |
| 4578 | |
| 4579 | class DeploymentList(generics.ListCreateAPIView): |
| 4580 | queryset = Deployment.objects.select_related().all() |
| 4581 | serializer_class = DeploymentSerializer |
| 4582 | id_serializer_class = DeploymentIdSerializer |
| 4583 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | bf4ef6d | 2014-12-22 15:59:33 -0800 | [diff] [blame] | 4584 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4585 | |
| 4586 | def get_serializer_class(self): |
| 4587 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4588 | if (no_hyperlinks): |
| 4589 | return self.id_serializer_class |
| 4590 | else: |
| 4591 | return self.serializer_class |
| 4592 | |
| 4593 | def get_queryset(self): |
| 4594 | return Deployment.select_by_user(self.request.user) |
| 4595 | |
| 4596 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4597 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4598 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4599 | response = {"error": "validation", |
| 4600 | "specific_error": "not serializer.is_valid()",
|
| 4601 | "reasons": serializer.errors}
|
| 4602 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4603 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4604 | obj.caller = request.user |
| 4605 | if obj.can_update(request.user): |
| 4606 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 4607 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4608 | raise Exception("failed obj.can_update") |
| 4609 | |
| 4610 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 4611 | if (ret.status_code%100 != 200): |
| 4612 | raise Exception(ret.data) |
| 4613 | |
| 4614 | return ret |
| 4615 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4616 | |
| 4617 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4618 | queryset = Deployment.objects.select_related().all() |
| 4619 | serializer_class = DeploymentSerializer |
| 4620 | id_serializer_class = DeploymentIdSerializer |
| 4621 | |
| 4622 | def get_serializer_class(self): |
| 4623 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4624 | if (no_hyperlinks): |
| 4625 | return self.id_serializer_class |
| 4626 | else: |
| 4627 | return self.serializer_class |
| 4628 | |
| 4629 | def get_queryset(self): |
| 4630 | return Deployment.select_by_user(self.request.user) |
| 4631 | |
| 4632 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4633 | |
| 4634 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4635 | |
| 4636 | |
| 4637 | |
| 4638 | class ReservationList(generics.ListCreateAPIView): |
| 4639 | queryset = Reservation.objects.select_related().all() |
| 4640 | serializer_class = ReservationSerializer |
| 4641 | id_serializer_class = ReservationIdSerializer |
| 4642 | filter_backends = (filters.DjangoFilterBackend,) |
| 4643 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 4644 | |
| 4645 | def get_serializer_class(self): |
| 4646 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4647 | if (no_hyperlinks): |
| 4648 | return self.id_serializer_class |
| 4649 | else: |
| 4650 | return self.serializer_class |
| 4651 | |
| 4652 | def get_queryset(self): |
| 4653 | return Reservation.select_by_user(self.request.user) |
| 4654 | |
| 4655 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4656 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4657 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4658 | response = {"error": "validation", |
| 4659 | "specific_error": "not serializer.is_valid()",
|
| 4660 | "reasons": serializer.errors}
|
| 4661 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4662 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4663 | obj.caller = request.user |
| 4664 | if obj.can_update(request.user): |
| 4665 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 4666 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4667 | raise Exception("failed obj.can_update") |
| 4668 | |
| 4669 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 4670 | if (ret.status_code%100 != 200): |
| 4671 | raise Exception(ret.data) |
| 4672 | |
| 4673 | return ret |
| 4674 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4675 | |
| 4676 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4677 | queryset = Reservation.objects.select_related().all() |
| 4678 | serializer_class = ReservationSerializer |
| 4679 | id_serializer_class = ReservationIdSerializer |
| 4680 | |
| 4681 | def get_serializer_class(self): |
| 4682 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4683 | if (no_hyperlinks): |
| 4684 | return self.id_serializer_class |
| 4685 | else: |
| 4686 | return self.serializer_class |
| 4687 | |
| 4688 | def get_queryset(self): |
| 4689 | return Reservation.select_by_user(self.request.user) |
| 4690 | |
| 4691 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4692 | |
| 4693 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4694 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4695 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4696 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4697 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 4698 | queryset = SitePrivilege.objects.select_related().all() |
| 4699 | serializer_class = SitePrivilegeSerializer |
| 4700 | id_serializer_class = SitePrivilegeIdSerializer |
| 4701 | filter_backends = (filters.DjangoFilterBackend,) |
| 4702 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 4703 | |
| 4704 | def get_serializer_class(self): |
| 4705 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4706 | if (no_hyperlinks): |
| 4707 | return self.id_serializer_class |
| 4708 | else: |
| 4709 | return self.serializer_class |
| 4710 | |
| 4711 | def get_queryset(self): |
| 4712 | return SitePrivilege.select_by_user(self.request.user) |
| 4713 | |
| 4714 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4715 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4716 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4717 | response = {"error": "validation", |
| 4718 | "specific_error": "not serializer.is_valid()",
|
| 4719 | "reasons": serializer.errors}
|
| 4720 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4721 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4722 | obj.caller = request.user |
| 4723 | if obj.can_update(request.user): |
| 4724 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4725 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4726 | raise Exception("failed obj.can_update") |
| 4727 | |
| 4728 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4729 | if (ret.status_code%100 != 200): |
| 4730 | raise Exception(ret.data) |
| 4731 | |
| 4732 | return ret |
| 4733 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4734 | |
| 4735 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4736 | queryset = SitePrivilege.objects.select_related().all() |
| 4737 | serializer_class = SitePrivilegeSerializer |
| 4738 | id_serializer_class = SitePrivilegeIdSerializer |
| 4739 | |
| 4740 | def get_serializer_class(self): |
| 4741 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4742 | if (no_hyperlinks): |
| 4743 | return self.id_serializer_class |
| 4744 | else: |
| 4745 | return self.serializer_class |
| 4746 | |
| 4747 | def get_queryset(self): |
| 4748 | return SitePrivilege.select_by_user(self.request.user) |
| 4749 | |
| 4750 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4751 | |
| 4752 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4753 | |
| 4754 | |
| 4755 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4756 | class PlanetStackList(generics.ListCreateAPIView): |
| 4757 | queryset = PlanetStack.objects.select_related().all() |
| 4758 | serializer_class = PlanetStackSerializer |
| 4759 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4760 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4761 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4762 | |
| 4763 | def get_serializer_class(self): |
| 4764 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4765 | if (no_hyperlinks): |
| 4766 | return self.id_serializer_class |
| 4767 | else: |
| 4768 | return self.serializer_class |
| 4769 | |
| 4770 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4771 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4772 | |
| 4773 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4774 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4775 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4776 | response = {"error": "validation", |
| 4777 | "specific_error": "not serializer.is_valid()",
|
| 4778 | "reasons": serializer.errors}
|
| 4779 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4780 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4781 | obj.caller = request.user |
| 4782 | if obj.can_update(request.user): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4783 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4784 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4785 | raise Exception("failed obj.can_update") |
| 4786 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4787 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4788 | if (ret.status_code%100 != 200): |
| 4789 | raise Exception(ret.data) |
| 4790 | |
| 4791 | return ret |
| 4792 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4793 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4794 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4795 | queryset = PlanetStack.objects.select_related().all() |
| 4796 | serializer_class = PlanetStackSerializer |
| 4797 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4798 | |
| 4799 | def get_serializer_class(self): |
| 4800 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4801 | if (no_hyperlinks): |
| 4802 | return self.id_serializer_class |
| 4803 | else: |
| 4804 | return self.serializer_class |
| 4805 | |
| 4806 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4807 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4808 | |
| 4809 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4810 | |
| 4811 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4812 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4813 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4814 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 4815 | class ControllerDashboardViewList(generics.ListCreateAPIView): |
| 4816 | queryset = ControllerDashboardView.objects.select_related().all() |
| 4817 | serializer_class = ControllerDashboardViewSerializer |
| 4818 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 4819 | filter_backends = (filters.DjangoFilterBackend,) |
| 4820 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
| 4821 | |
| 4822 | def get_serializer_class(self): |
| 4823 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4824 | if (no_hyperlinks): |
| 4825 | return self.id_serializer_class |
| 4826 | else: |
| 4827 | return self.serializer_class |
| 4828 | |
| 4829 | def get_queryset(self): |
| 4830 | return ControllerDashboardView.select_by_user(self.request.user) |
| 4831 | |
| 4832 | def create(self, request, *args, **kwargs): |
| 4833 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4834 | if not (serializer.is_valid()): |
| 4835 | response = {"error": "validation", |
| 4836 | "specific_error": "not serializer.is_valid()",
|
| 4837 | "reasons": serializer.errors}
|
| 4838 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4839 | obj = serializer.object |
| 4840 | obj.caller = request.user |
| 4841 | if obj.can_update(request.user): |
| 4842 | return super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 4843 | else: |
| 4844 | raise Exception("failed obj.can_update") |
| 4845 | |
| 4846 | ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs) |
| 4847 | if (ret.status_code%100 != 200): |
| 4848 | raise Exception(ret.data) |
| 4849 | |
| 4850 | return ret |
| 4851 | |
| 4852 | |
| 4853 | class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4854 | queryset = ControllerDashboardView.objects.select_related().all() |
| 4855 | serializer_class = ControllerDashboardViewSerializer |
| 4856 | id_serializer_class = ControllerDashboardViewIdSerializer |
| 4857 | |
| 4858 | def get_serializer_class(self): |
| 4859 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4860 | if (no_hyperlinks): |
| 4861 | return self.id_serializer_class |
| 4862 | else: |
| 4863 | return self.serializer_class |
| 4864 | |
| 4865 | def get_queryset(self): |
| 4866 | return ControllerDashboardView.select_by_user(self.request.user) |
| 4867 | |
| 4868 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4869 | |
| 4870 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4871 | |
| 4872 | |
| 4873 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4874 | class AccountList(generics.ListCreateAPIView): |
| 4875 | queryset = Account.objects.select_related().all() |
| 4876 | serializer_class = AccountSerializer |
| 4877 | id_serializer_class = AccountIdSerializer |
| 4878 | filter_backends = (filters.DjangoFilterBackend,) |
| 4879 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 4880 | |
| 4881 | def get_serializer_class(self): |
| 4882 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4883 | if (no_hyperlinks): |
| 4884 | return self.id_serializer_class |
| 4885 | else: |
| 4886 | return self.serializer_class |
| 4887 | |
| 4888 | def get_queryset(self): |
| 4889 | return Account.select_by_user(self.request.user) |
| 4890 | |
| 4891 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4892 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4893 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4894 | response = {"error": "validation", |
| 4895 | "specific_error": "not serializer.is_valid()",
|
| 4896 | "reasons": serializer.errors}
|
| 4897 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4898 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4899 | obj.caller = request.user |
| 4900 | if obj.can_update(request.user): |
| 4901 | return super(AccountList, self).create(request, *args, **kwargs) |
| 4902 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4903 | raise Exception("failed obj.can_update") |
| 4904 | |
| 4905 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 4906 | if (ret.status_code%100 != 200): |
| 4907 | raise Exception(ret.data) |
| 4908 | |
| 4909 | return ret |
| 4910 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4911 | |
| 4912 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4913 | queryset = Account.objects.select_related().all() |
| 4914 | serializer_class = AccountSerializer |
| 4915 | id_serializer_class = AccountIdSerializer |
| 4916 | |
| 4917 | def get_serializer_class(self): |
| 4918 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4919 | if (no_hyperlinks): |
| 4920 | return self.id_serializer_class |
| 4921 | else: |
| 4922 | return self.serializer_class |
| 4923 | |
| 4924 | def get_queryset(self): |
| 4925 | return Account.select_by_user(self.request.user) |
| 4926 | |
| 4927 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4928 | |
| 4929 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4930 | |
| 4931 | |
| 4932 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4933 | class ControllerRoleList(generics.ListCreateAPIView): |
| 4934 | queryset = ControllerRole.objects.select_related().all() |
| 4935 | serializer_class = ControllerRoleSerializer |
| 4936 | id_serializer_class = ControllerRoleIdSerializer |
| 4937 | filter_backends = (filters.DjangoFilterBackend,) |
| 4938 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 4939 | |
| 4940 | def get_serializer_class(self): |
| 4941 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4942 | if (no_hyperlinks): |
| 4943 | return self.id_serializer_class |
| 4944 | else: |
| 4945 | return self.serializer_class |
| 4946 | |
| 4947 | def get_queryset(self): |
| 4948 | return ControllerRole.select_by_user(self.request.user) |
| 4949 | |
| 4950 | def create(self, request, *args, **kwargs): |
| 4951 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4952 | if not (serializer.is_valid()): |
| 4953 | response = {"error": "validation", |
| 4954 | "specific_error": "not serializer.is_valid()",
|
| 4955 | "reasons": serializer.errors}
|
| 4956 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4957 | obj = serializer.object |
| 4958 | obj.caller = request.user |
| 4959 | if obj.can_update(request.user): |
| 4960 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 4961 | else: |
| 4962 | raise Exception("failed obj.can_update") |
| 4963 | |
| 4964 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 4965 | if (ret.status_code%100 != 200): |
| 4966 | raise Exception(ret.data) |
| 4967 | |
| 4968 | return ret |
| 4969 | |
| 4970 | |
| 4971 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4972 | queryset = ControllerRole.objects.select_related().all() |
| 4973 | serializer_class = ControllerRoleSerializer |
| 4974 | id_serializer_class = ControllerRoleIdSerializer |
| 4975 | |
| 4976 | def get_serializer_class(self): |
| 4977 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4978 | if (no_hyperlinks): |
| 4979 | return self.id_serializer_class |
| 4980 | else: |
| 4981 | return self.serializer_class |
| 4982 | |
| 4983 | def get_queryset(self): |
| 4984 | return ControllerRole.select_by_user(self.request.user) |
| 4985 | |
| 4986 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4987 | |
| 4988 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4989 | |
| 4990 | |
| 4991 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4992 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 4993 | queryset = NetworkParameterType.objects.select_related().all() |
| 4994 | serializer_class = NetworkParameterTypeSerializer |
| 4995 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 4996 | filter_backends = (filters.DjangoFilterBackend,) |
| 4997 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 4998 | |
| 4999 | def get_serializer_class(self): |
| 5000 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5001 | if (no_hyperlinks): |
| 5002 | return self.id_serializer_class |
| 5003 | else: |
| 5004 | return self.serializer_class |
| 5005 | |
| 5006 | def get_queryset(self): |
| 5007 | return NetworkParameterType.select_by_user(self.request.user) |
| 5008 | |
| 5009 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5010 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5011 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5012 | response = {"error": "validation", |
| 5013 | "specific_error": "not serializer.is_valid()",
|
| 5014 | "reasons": serializer.errors}
|
| 5015 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5016 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5017 | obj.caller = request.user |
| 5018 | if obj.can_update(request.user): |
| 5019 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5020 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5021 | raise Exception("failed obj.can_update") |
| 5022 | |
| 5023 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5024 | if (ret.status_code%100 != 200): |
| 5025 | raise Exception(ret.data) |
| 5026 | |
| 5027 | return ret |
| 5028 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5029 | |
| 5030 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5031 | queryset = NetworkParameterType.objects.select_related().all() |
| 5032 | serializer_class = NetworkParameterTypeSerializer |
| 5033 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5034 | |
| 5035 | def get_serializer_class(self): |
| 5036 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5037 | if (no_hyperlinks): |
| 5038 | return self.id_serializer_class |
| 5039 | else: |
| 5040 | return self.serializer_class |
| 5041 | |
| 5042 | def get_queryset(self): |
| 5043 | return NetworkParameterType.select_by_user(self.request.user) |
| 5044 | |
| 5045 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5046 | |
| 5047 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5048 | |
| 5049 | |
| 5050 | |
| 5051 | class SiteCredentialList(generics.ListCreateAPIView): |
| 5052 | queryset = SiteCredential.objects.select_related().all() |
| 5053 | serializer_class = SiteCredentialSerializer |
| 5054 | id_serializer_class = SiteCredentialIdSerializer |
| 5055 | filter_backends = (filters.DjangoFilterBackend,) |
| 5056 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 5057 | |
| 5058 | def get_serializer_class(self): |
| 5059 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5060 | if (no_hyperlinks): |
| 5061 | return self.id_serializer_class |
| 5062 | else: |
| 5063 | return self.serializer_class |
| 5064 | |
| 5065 | def get_queryset(self): |
| 5066 | return SiteCredential.select_by_user(self.request.user) |
| 5067 | |
| 5068 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5069 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5070 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5071 | response = {"error": "validation", |
| 5072 | "specific_error": "not serializer.is_valid()",
|
| 5073 | "reasons": serializer.errors}
|
| 5074 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5075 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5076 | obj.caller = request.user |
| 5077 | if obj.can_update(request.user): |
| 5078 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5079 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5080 | raise Exception("failed obj.can_update") |
| 5081 | |
| 5082 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5083 | if (ret.status_code%100 != 200): |
| 5084 | raise Exception(ret.data) |
| 5085 | |
| 5086 | return ret |
| 5087 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5088 | |
| 5089 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5090 | queryset = SiteCredential.objects.select_related().all() |
| 5091 | serializer_class = SiteCredentialSerializer |
| 5092 | id_serializer_class = SiteCredentialIdSerializer |
| 5093 | |
| 5094 | def get_serializer_class(self): |
| 5095 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5096 | if (no_hyperlinks): |
| 5097 | return self.id_serializer_class |
| 5098 | else: |
| 5099 | return self.serializer_class |
| 5100 | |
| 5101 | def get_queryset(self): |
| 5102 | return SiteCredential.select_by_user(self.request.user) |
| 5103 | |
| 5104 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5105 | |
| 5106 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5107 | |
| 5108 | |
| 5109 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5110 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 5111 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5112 | serializer_class = DeploymentPrivilegeSerializer |
| 5113 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5114 | filter_backends = (filters.DjangoFilterBackend,) |
| 5115 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 5116 | |
| 5117 | def get_serializer_class(self): |
| 5118 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5119 | if (no_hyperlinks): |
| 5120 | return self.id_serializer_class |
| 5121 | else: |
| 5122 | return self.serializer_class |
| 5123 | |
| 5124 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5125 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5126 | |
| 5127 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5128 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5129 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5130 | response = {"error": "validation", |
| 5131 | "specific_error": "not serializer.is_valid()",
|
| 5132 | "reasons": serializer.errors}
|
| 5133 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5134 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5135 | obj.caller = request.user |
| 5136 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5137 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5138 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5139 | raise Exception("failed obj.can_update") |
| 5140 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5141 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5142 | if (ret.status_code%100 != 200): |
| 5143 | raise Exception(ret.data) |
| 5144 | |
| 5145 | return ret |
| 5146 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5147 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5148 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5149 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5150 | serializer_class = DeploymentPrivilegeSerializer |
| 5151 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5152 | |
| 5153 | def get_serializer_class(self): |
| 5154 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5155 | if (no_hyperlinks): |
| 5156 | return self.id_serializer_class |
| 5157 | else: |
| 5158 | return self.serializer_class |
| 5159 | |
| 5160 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5161 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5162 | |
| 5163 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5164 | |
| 5165 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5166 | |
| 5167 | |
| 5168 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5169 | class ControllerUserList(generics.ListCreateAPIView): |
| 5170 | queryset = ControllerUser.objects.select_related().all() |
| 5171 | serializer_class = ControllerUserSerializer |
| 5172 | id_serializer_class = ControllerUserIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5173 | filter_backends = (filters.DjangoFilterBackend,) |
| 5174 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 5175 | |
| 5176 | def get_serializer_class(self): |
| 5177 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5178 | if (no_hyperlinks): |
| 5179 | return self.id_serializer_class |
| 5180 | else: |
| 5181 | return self.serializer_class |
| 5182 | |
| 5183 | def get_queryset(self): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5184 | return ControllerUser.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5185 | |
| 5186 | def create(self, request, *args, **kwargs): |
| 5187 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5188 | if not (serializer.is_valid()): |
| 5189 | response = {"error": "validation", |
| 5190 | "specific_error": "not serializer.is_valid()",
|
| 5191 | "reasons": serializer.errors}
|
| 5192 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5193 | obj = serializer.object |
| 5194 | obj.caller = request.user |
| 5195 | if obj.can_update(request.user): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5196 | return super(ControllerUserList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5197 | else: |
| 5198 | raise Exception("failed obj.can_update") |
| 5199 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5200 | ret = super(ControllerUserList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5201 | if (ret.status_code%100 != 200): |
| 5202 | raise Exception(ret.data) |
| 5203 | |
| 5204 | return ret |
| 5205 | |
| 5206 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5207 | class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5208 | queryset = ControllerUser.objects.select_related().all() |
| 5209 | serializer_class = ControllerUserSerializer |
| 5210 | id_serializer_class = ControllerUserIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5211 | |
| 5212 | def get_serializer_class(self): |
| 5213 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5214 | if (no_hyperlinks): |
| 5215 | return self.id_serializer_class |
| 5216 | else: |
| 5217 | return self.serializer_class |
| 5218 | |
| 5219 | def get_queryset(self): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5220 | return ControllerUser.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5221 | |
| 5222 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5223 | |
| 5224 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5225 | |
| 5226 | |
| 5227 | |
| 5228 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 5229 | queryset = DeploymentRole.objects.select_related().all() |
| 5230 | serializer_class = DeploymentRoleSerializer |
| 5231 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5232 | filter_backends = (filters.DjangoFilterBackend,) |
| 5233 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5234 | |
| 5235 | def get_serializer_class(self): |
| 5236 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5237 | if (no_hyperlinks): |
| 5238 | return self.id_serializer_class |
| 5239 | else: |
| 5240 | return self.serializer_class |
| 5241 | |
| 5242 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5243 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5244 | |
| 5245 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5246 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5247 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5248 | response = {"error": "validation", |
| 5249 | "specific_error": "not serializer.is_valid()",
|
| 5250 | "reasons": serializer.errors}
|
| 5251 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5252 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5253 | obj.caller = request.user |
| 5254 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5255 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5256 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5257 | raise Exception("failed obj.can_update") |
| 5258 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5259 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5260 | if (ret.status_code%100 != 200): |
| 5261 | raise Exception(ret.data) |
| 5262 | |
| 5263 | return ret |
| 5264 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5265 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5266 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5267 | queryset = DeploymentRole.objects.select_related().all() |
| 5268 | serializer_class = DeploymentRoleSerializer |
| 5269 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5270 | |
| 5271 | def get_serializer_class(self): |
| 5272 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5273 | if (no_hyperlinks): |
| 5274 | return self.id_serializer_class |
| 5275 | else: |
| 5276 | return self.serializer_class |
| 5277 | |
| 5278 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5279 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5280 | |
| 5281 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5282 | |
| 5283 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5284 | |
| 5285 | |
| 5286 | |
| 5287 | class UserCredentialList(generics.ListCreateAPIView): |
| 5288 | queryset = UserCredential.objects.select_related().all() |
| 5289 | serializer_class = UserCredentialSerializer |
| 5290 | id_serializer_class = UserCredentialIdSerializer |
| 5291 | filter_backends = (filters.DjangoFilterBackend,) |
| 5292 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 5293 | |
| 5294 | def get_serializer_class(self): |
| 5295 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5296 | if (no_hyperlinks): |
| 5297 | return self.id_serializer_class |
| 5298 | else: |
| 5299 | return self.serializer_class |
| 5300 | |
| 5301 | def get_queryset(self): |
| 5302 | return UserCredential.select_by_user(self.request.user) |
| 5303 | |
| 5304 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5305 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5306 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5307 | response = {"error": "validation", |
| 5308 | "specific_error": "not serializer.is_valid()",
|
| 5309 | "reasons": serializer.errors}
|
| 5310 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5311 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5312 | obj.caller = request.user |
| 5313 | if obj.can_update(request.user): |
| 5314 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5315 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5316 | raise Exception("failed obj.can_update") |
| 5317 | |
| 5318 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5319 | if (ret.status_code%100 != 200): |
| 5320 | raise Exception(ret.data) |
| 5321 | |
| 5322 | return ret |
| 5323 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5324 | |
| 5325 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5326 | queryset = UserCredential.objects.select_related().all() |
| 5327 | serializer_class = UserCredentialSerializer |
| 5328 | id_serializer_class = UserCredentialIdSerializer |
| 5329 | |
| 5330 | def get_serializer_class(self): |
| 5331 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5332 | if (no_hyperlinks): |
| 5333 | return self.id_serializer_class |
| 5334 | else: |
| 5335 | return self.serializer_class |
| 5336 | |
| 5337 | def get_queryset(self): |
| 5338 | return UserCredential.select_by_user(self.request.user) |
| 5339 | |
| 5340 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5341 | |
| 5342 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5343 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5344 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5345 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5346 | class SiteDeploymentList(generics.ListCreateAPIView): |
| 5347 | queryset = SiteDeployment.objects.select_related().all() |
| 5348 | serializer_class = SiteDeploymentSerializer |
| 5349 | id_serializer_class = SiteDeploymentIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5350 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5351 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5352 | |
| 5353 | def get_serializer_class(self): |
| 5354 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5355 | if (no_hyperlinks): |
| 5356 | return self.id_serializer_class |
| 5357 | else: |
| 5358 | return self.serializer_class |
| 5359 | |
| 5360 | def get_queryset(self): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5361 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5362 | |
| 5363 | def create(self, request, *args, **kwargs): |
| 5364 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5365 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5366 | response = {"error": "validation", |
| 5367 | "specific_error": "not serializer.is_valid()",
|
| 5368 | "reasons": serializer.errors}
|
| 5369 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5370 | obj = serializer.object |
| 5371 | obj.caller = request.user |
| 5372 | if obj.can_update(request.user): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5373 | return super(SiteDeploymentList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5374 | else: |
| 5375 | raise Exception("failed obj.can_update") |
| 5376 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5377 | ret = super(SiteDeploymentList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5378 | if (ret.status_code%100 != 200): |
| 5379 | raise Exception(ret.data) |
| 5380 | |
| 5381 | return ret |
| 5382 | |
| 5383 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5384 | class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5385 | queryset = SiteDeployment.objects.select_related().all() |
| 5386 | serializer_class = SiteDeploymentSerializer |
| 5387 | id_serializer_class = SiteDeploymentIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5388 | |
| 5389 | def get_serializer_class(self): |
| 5390 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5391 | if (no_hyperlinks): |
| 5392 | return self.id_serializer_class |
| 5393 | else: |
| 5394 | return self.serializer_class |
| 5395 | |
| 5396 | def get_queryset(self): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5397 | return SiteDeployment.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5398 | |
| 5399 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5400 | |
| 5401 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5402 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5403 | |
| 5404 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5405 | class SliceTagList(generics.ListCreateAPIView): |
| 5406 | queryset = SliceTag.objects.select_related().all() |
| 5407 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5408 | id_serializer_class = SliceTagIdSerializer |
| 5409 | filter_backends = (filters.DjangoFilterBackend,) |
| 5410 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 5411 | |
| 5412 | def get_serializer_class(self): |
| 5413 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5414 | if (no_hyperlinks): |
| 5415 | return self.id_serializer_class |
| 5416 | else: |
| 5417 | return self.serializer_class |
| 5418 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5419 | def get_queryset(self): |
| 5420 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5421 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5422 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5423 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5424 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5425 | response = {"error": "validation", |
| 5426 | "specific_error": "not serializer.is_valid()",
|
| 5427 | "reasons": serializer.errors}
|
| 5428 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5429 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5430 | obj.caller = request.user |
| 5431 | if obj.can_update(request.user): |
| 5432 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 5433 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5434 | raise Exception("failed obj.can_update") |
| 5435 | |
| 5436 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 5437 | if (ret.status_code%100 != 200): |
| 5438 | raise Exception(ret.data) |
| 5439 | |
| 5440 | return ret |
| 5441 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5442 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5443 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5444 | queryset = SliceTag.objects.select_related().all() |
| 5445 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5446 | id_serializer_class = SliceTagIdSerializer |
| 5447 | |
| 5448 | def get_serializer_class(self): |
| 5449 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5450 | if (no_hyperlinks): |
| 5451 | return self.id_serializer_class |
| 5452 | else: |
| 5453 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5454 | |
| 5455 | def get_queryset(self): |
| 5456 | return SliceTag.select_by_user(self.request.user) |
| 5457 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5458 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5459 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5460 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5461 | |
| 5462 | |
| 5463 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5464 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 5465 | queryset = NetworkTemplate.objects.select_related().all() |
| 5466 | serializer_class = NetworkTemplateSerializer |
| 5467 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5468 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 16fce9c | 2015-01-03 12:05:21 -0800 | [diff] [blame] | 5469 | 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] | 5470 | |
| 5471 | def get_serializer_class(self): |
| 5472 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5473 | if (no_hyperlinks): |
| 5474 | return self.id_serializer_class |
| 5475 | else: |
| 5476 | return self.serializer_class |
| 5477 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5478 | def get_queryset(self): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5479 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5480 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5481 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5482 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5483 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5484 | response = {"error": "validation", |
| 5485 | "specific_error": "not serializer.is_valid()",
|
| 5486 | "reasons": serializer.errors}
|
| 5487 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5488 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5489 | obj.caller = request.user |
| 5490 | if obj.can_update(request.user): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5491 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5492 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5493 | raise Exception("failed obj.can_update") |
| 5494 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5495 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5496 | if (ret.status_code%100 != 200): |
| 5497 | raise Exception(ret.data) |
| 5498 | |
| 5499 | return ret |
| 5500 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5501 | |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5502 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5503 | queryset = NetworkTemplate.objects.select_related().all() |
| 5504 | serializer_class = NetworkTemplateSerializer |
| 5505 | id_serializer_class = NetworkTemplateIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5506 | |
| 5507 | def get_serializer_class(self): |
| 5508 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5509 | if (no_hyperlinks): |
| 5510 | return self.id_serializer_class |
| 5511 | else: |
| 5512 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5513 | |
| 5514 | def get_queryset(self): |
Scott Baker | f2c0c51 | 2014-12-22 17:35:34 -0800 | [diff] [blame] | 5515 | return NetworkTemplate.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5516 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5517 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5518 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5519 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5520 | |
| 5521 | |
| 5522 | |
| 5523 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5524 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5525 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5526 | id_serializer_class = RouterIdSerializer |
| 5527 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5528 | 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] | 5529 | |
| 5530 | def get_serializer_class(self): |
| 5531 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5532 | if (no_hyperlinks): |
| 5533 | return self.id_serializer_class |
| 5534 | else: |
| 5535 | return self.serializer_class |
| 5536 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5537 | def get_queryset(self): |
| 5538 | return Router.select_by_user(self.request.user) |
| 5539 | |
| 5540 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5541 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5542 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5543 | response = {"error": "validation", |
| 5544 | "specific_error": "not serializer.is_valid()",
|
| 5545 | "reasons": serializer.errors}
|
| 5546 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5547 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5548 | obj.caller = request.user |
| 5549 | if obj.can_update(request.user): |
| 5550 | return super(RouterList, self).create(request, *args, **kwargs) |
| 5551 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5552 | raise Exception("failed obj.can_update") |
| 5553 | |
| 5554 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 5555 | if (ret.status_code%100 != 200): |
| 5556 | raise Exception(ret.data) |
| 5557 | |
| 5558 | return ret |
| 5559 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5560 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5561 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5562 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5563 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5564 | id_serializer_class = RouterIdSerializer |
| 5565 | |
| 5566 | def get_serializer_class(self): |
| 5567 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5568 | if (no_hyperlinks): |
| 5569 | return self.id_serializer_class |
| 5570 | else: |
| 5571 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5572 | |
| 5573 | def get_queryset(self): |
| 5574 | return Router.select_by_user(self.request.user) |
| 5575 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5576 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5577 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5578 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5579 | |
| 5580 | |
| 5581 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5582 | class ServiceResourceList(generics.ListCreateAPIView): |
| 5583 | queryset = ServiceResource.objects.select_related().all() |
| 5584 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5585 | id_serializer_class = ServiceResourceIdSerializer |
| 5586 | filter_backends = (filters.DjangoFilterBackend,) |
| 5587 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 5588 | |
| 5589 | def get_serializer_class(self): |
| 5590 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5591 | if (no_hyperlinks): |
| 5592 | return self.id_serializer_class |
| 5593 | else: |
| 5594 | return self.serializer_class |
| 5595 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5596 | def get_queryset(self): |
| 5597 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5598 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5599 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5600 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5601 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5602 | response = {"error": "validation", |
| 5603 | "specific_error": "not serializer.is_valid()",
|
| 5604 | "reasons": serializer.errors}
|
| 5605 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5606 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5607 | obj.caller = request.user |
| 5608 | if obj.can_update(request.user): |
| 5609 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5610 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5611 | raise Exception("failed obj.can_update") |
| 5612 | |
| 5613 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5614 | if (ret.status_code%100 != 200): |
| 5615 | raise Exception(ret.data) |
| 5616 | |
| 5617 | return ret |
| 5618 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5619 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5620 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5621 | queryset = ServiceResource.objects.select_related().all() |
| 5622 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5623 | id_serializer_class = ServiceResourceIdSerializer |
| 5624 | |
| 5625 | def get_serializer_class(self): |
| 5626 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5627 | if (no_hyperlinks): |
| 5628 | return self.id_serializer_class |
| 5629 | else: |
| 5630 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5631 | |
| 5632 | def get_queryset(self): |
| 5633 | return ServiceResource.select_by_user(self.request.user) |
| 5634 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5635 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5636 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5637 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5638 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5639 | |
| 5640 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5641 | class ControllerSliceList(generics.ListCreateAPIView): |
| 5642 | queryset = ControllerSlice.objects.select_related().all() |
| 5643 | serializer_class = ControllerSliceSerializer |
| 5644 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5645 | filter_backends = (filters.DjangoFilterBackend,) |
| 5646 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 5647 | |
| 5648 | def get_serializer_class(self): |
| 5649 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5650 | if (no_hyperlinks): |
| 5651 | return self.id_serializer_class |
| 5652 | else: |
| 5653 | return self.serializer_class |
| 5654 | |
| 5655 | def get_queryset(self): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5656 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5657 | |
| 5658 | def create(self, request, *args, **kwargs): |
| 5659 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5660 | if not (serializer.is_valid()): |
| 5661 | response = {"error": "validation", |
| 5662 | "specific_error": "not serializer.is_valid()",
|
| 5663 | "reasons": serializer.errors}
|
| 5664 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5665 | obj = serializer.object |
| 5666 | obj.caller = request.user |
| 5667 | if obj.can_update(request.user): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5668 | return super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5669 | else: |
| 5670 | raise Exception("failed obj.can_update") |
| 5671 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5672 | ret = super(ControllerSliceList, self).create(request, *args, **kwargs) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5673 | if (ret.status_code%100 != 200): |
| 5674 | raise Exception(ret.data) |
| 5675 | |
| 5676 | return ret |
| 5677 | |
| 5678 | |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5679 | class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5680 | queryset = ControllerSlice.objects.select_related().all() |
| 5681 | serializer_class = ControllerSliceSerializer |
| 5682 | id_serializer_class = ControllerSliceIdSerializer |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5683 | |
| 5684 | def get_serializer_class(self): |
| 5685 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5686 | if (no_hyperlinks): |
| 5687 | return self.id_serializer_class |
| 5688 | else: |
| 5689 | return self.serializer_class |
| 5690 | |
| 5691 | def get_queryset(self): |
Tony Mack | 3066a95 | 2015-01-05 22:48:11 -0500 | [diff] [blame] | 5692 | return ControllerSlice.select_by_user(self.request.user) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5693 | |
| 5694 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5695 | |
| 5696 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5697 | |
| 5698 | |
| 5699 | |