Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1 | from rest_framework.decorators import api_view |
| 2 | from rest_framework.response import Response |
| 3 | from rest_framework.reverse import reverse |
| 4 | from rest_framework import serializers |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5 | from rest_framework import generics |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 7 | from rest_framework.generics import GenericAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 8 | from core.models import * |
| 9 | from django.forms import widgets |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 10 | from rest_framework import filters |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 11 | from django.conf.urls import patterns, url |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 12 | |
| 13 | """ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 14 | Schema of the generator object: |
| 15 | all: Set of all Model objects |
| 16 | all_if(regex): Set of Model objects that match regex |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 17 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 18 | Model object: |
| 19 | plural: English plural of object name |
| 20 | camel: CamelCase version of object name |
| 21 | refs: list of references to other Model objects |
| 22 | props: list of properties minus refs |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 23 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 24 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 25 | """ |
| 26 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 27 | def get_REST_patterns(): |
| 28 | return patterns('', |
| 29 | url(r'^plstackapi/$', api_root), |
| 30 | |
| 31 | url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 32 | url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 33 | # url(r'plstackapi/serviceattributes/!new/$', ServiceAttributeNew.as_view(), name ='serviceattribute-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 34 | |
| 35 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 36 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 37 | # url(r'plstackapi/images/!new/$', ImageNew.as_view(), name ='image-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 38 | |
| 39 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 40 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 41 | # url(r'plstackapi/networkparameters/!new/$', NetworkParameterNew.as_view(), name ='networkparameter-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 42 | |
| 43 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 44 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 45 | # url(r'plstackapi/sites/!new/$', SiteNew.as_view(), name ='site-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 46 | |
| 47 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 48 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 49 | # url(r'plstackapi/slice_roles/!new/$', SliceRoleNew.as_view(), name ='slicerole-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 50 | |
| 51 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 52 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 53 | # url(r'plstackapi/tags/!new/$', TagNew.as_view(), name ='tag-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 54 | |
| 55 | url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'), |
| 56 | url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 57 | # url(r'plstackapi/invoices/!new/$', InvoiceNew.as_view(), name ='invoice-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 58 | |
| 59 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 60 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 61 | # url(r'plstackapi/slice_privileges/!new/$', SlicePrivilegeNew.as_view(), name ='sliceprivilege-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 62 | |
| 63 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 64 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 65 | # url(r'plstackapi/planetstackroles/!new/$', PlanetStackRoleNew.as_view(), name ='planetstackrole-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 66 | |
| 67 | url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'), |
| 68 | url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 69 | # url(r'plstackapi/networkslivers/!new/$', NetworkSliverNew.as_view(), name ='networksliver-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 70 | |
| 71 | url(r'plstackapi/networkdeployments/$', NetworkDeploymentsList.as_view(), name='networkdeployments-list'), |
| 72 | url(r'plstackapi/networkdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDeploymentsDetail.as_view(), name ='networkdeployments-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 73 | # url(r'plstackapi/networkdeployments/!new/$', NetworkDeploymentsNew.as_view(), name ='networkdeployments-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 74 | |
| 75 | url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 76 | url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 77 | # url(r'plstackapi/flavors/!new/$', FlavorNew.as_view(), name ='flavor-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 78 | |
| 79 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 80 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 81 | # url(r'plstackapi/projects/!new/$', ProjectNew.as_view(), name ='project-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 82 | |
| 83 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 84 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 85 | # url(r'plstackapi/slices/!new/$', SliceNew.as_view(), name ='slice-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 86 | |
| 87 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 88 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 89 | # url(r'plstackapi/networks/!new/$', NetworkNew.as_view(), name ='network-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 90 | |
| 91 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 92 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 93 | # url(r'plstackapi/services/!new/$', ServiceNew.as_view(), name ='service-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 94 | |
| 95 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 96 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 97 | # url(r'plstackapi/serviceclasses/!new/$', ServiceClassNew.as_view(), name ='serviceclass-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 98 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 99 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 100 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 101 | # url(r'plstackapi/payments/!new/$', PaymentNew.as_view(), name ='payment-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 102 | |
| 103 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 104 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 105 | # url(r'plstackapi/charges/!new/$', ChargeNew.as_view(), name ='charge-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 106 | |
| 107 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 108 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 109 | # url(r'plstackapi/roles/!new/$', RoleNew.as_view(), name ='role-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 110 | |
| 111 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 112 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 113 | # url(r'plstackapi/usableobjects/!new/$', UsableObjectNew.as_view(), name ='usableobject-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 114 | |
| 115 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 116 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 117 | # url(r'plstackapi/site_roles/!new/$', SiteRoleNew.as_view(), name ='siterole-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 118 | |
| 119 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 120 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 121 | # url(r'plstackapi/slicecredentials/!new/$', SliceCredentialNew.as_view(), name ='slicecredential-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 122 | |
| 123 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 124 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 125 | # url(r'plstackapi/slivers/!new/$', SliverNew.as_view(), name ='sliver-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 126 | |
| 127 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 128 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 129 | # url(r'plstackapi/nodes/!new/$', NodeNew.as_view(), name ='node-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 130 | |
| 131 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 132 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 133 | # url(r'plstackapi/dashboardviews/!new/$', DashboardViewNew.as_view(), name ='dashboardview-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 134 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 135 | url(r'plstackapi/imagedeployments/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 136 | url(r'plstackapi/imagedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'), |
| 137 | # url(r'plstackapi/imagedeployments/!new/$', ImageDeploymentsNew.as_view(), name ='imagedeployments-new'), |
| 138 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 139 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 140 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 141 | # url(r'plstackapi/reservedresources/!new/$', ReservedResourceNew.as_view(), name ='reservedresource-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 142 | |
| 143 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 144 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 145 | # url(r'plstackapi/networkslices/!new/$', NetworkSliceNew.as_view(), name ='networkslice-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 146 | |
| 147 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 148 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 149 | # url(r'plstackapi/userdashboardviews/!new/$', UserDashboardViewNew.as_view(), name ='userdashboardview-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 150 | |
| 151 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 152 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 153 | # url(r'plstackapi/planetstackprivileges/!new/$', PlanetStackPrivilegeNew.as_view(), name ='planetstackprivilege-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 154 | |
| 155 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 156 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 157 | # url(r'plstackapi/users/!new/$', UserNew.as_view(), name ='user-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 158 | |
| 159 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 160 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 161 | # url(r'plstackapi/deployments/!new/$', DeploymentNew.as_view(), name ='deployment-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 162 | |
| 163 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 164 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 165 | # url(r'plstackapi/reservations/!new/$', ReservationNew.as_view(), name ='reservation-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 166 | |
Scott Baker | 0f7a1c2 | 2014-11-21 11:36:19 -0800 | [diff] [blame] | 167 | url(r'plstackapi/slicedeployments/$', SliceDeploymentsList.as_view(), name='slicedeployments-list'), |
| 168 | url(r'plstackapi/slicedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDeploymentsDetail.as_view(), name ='slicedeployments-detail'), |
| 169 | # url(r'plstackapi/slicedeployments/!new/$', SliceDeploymentsNew.as_view(), name ='slicedeployments-new'), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 170 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 171 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 172 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 173 | # url(r'plstackapi/siteprivileges/!new/$', SitePrivilegeNew.as_view(), name ='siteprivilege-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 174 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 175 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 176 | url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'), |
| 177 | # url(r'plstackapi/planetstacks/!new/$', PlanetStackNew.as_view(), name ='planetstack-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 178 | |
Scott Baker | 0f7a1c2 | 2014-11-21 11:36:19 -0800 | [diff] [blame] | 179 | url(r'plstackapi/userdeployments/$', UserDeploymentsList.as_view(), name='userdeployments-list'), |
| 180 | url(r'plstackapi/userdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentsDetail.as_view(), name ='userdeployments-detail'), |
| 181 | # url(r'plstackapi/userdeployments/!new/$', UserDeploymentsNew.as_view(), name ='userdeployments-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 182 | |
| 183 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 184 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 185 | # url(r'plstackapi/accounts/!new/$', AccountNew.as_view(), name ='account-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 186 | |
| 187 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 188 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 189 | # url(r'plstackapi/networkparametertypes/!new/$', NetworkParameterTypeNew.as_view(), name ='networkparametertype-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 190 | |
| 191 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 192 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 193 | # url(r'plstackapi/sitecredentials/!new/$', SiteCredentialNew.as_view(), name ='sitecredential-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 194 | |
| 195 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 196 | url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 197 | # url(r'plstackapi/deploymentprivileges/!new/$', DeploymentPrivilegeNew.as_view(), name ='deploymentprivilege-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 198 | |
| 199 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 200 | url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 201 | # url(r'plstackapi/deploymentroles/!new/$', DeploymentRoleNew.as_view(), name ='deploymentrole-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 202 | |
| 203 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 204 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 205 | # url(r'plstackapi/usercredentials/!new/$', UserCredentialNew.as_view(), name ='usercredential-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 206 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 207 | url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'), |
| 208 | url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'), |
| 209 | # url(r'plstackapi/sitedeployments/!new/$', SiteDeploymentsNew.as_view(), name ='sitedeployments-new'), |
| 210 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 211 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 212 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 213 | # url(r'plstackapi/slicetags/!new/$', SliceTagNew.as_view(), name ='slicetag-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 214 | |
| 215 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 216 | url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 217 | # url(r'plstackapi/networktemplates/!new/$', NetworkTemplateNew.as_view(), name ='networktemplate-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 218 | |
| 219 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 220 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 221 | # url(r'plstackapi/routers/!new/$', RouterNew.as_view(), name ='router-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 222 | |
| 223 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 224 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 225 | # url(r'plstackapi/serviceresources/!new/$', ServiceResourceNew.as_view(), name ='serviceresource-new'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 226 | |
| 227 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 228 | |
| 229 | @api_view(['GET']) |
| 230 | def api_root(request, format=None): |
| 231 | return Response({ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 232 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
| 233 | 'images': reverse('image-list', request=request, format=format), |
| 234 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 235 | 'sites': reverse('site-list', request=request, format=format), |
| 236 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 237 | 'tags': reverse('tag-list', request=request, format=format), |
| 238 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 239 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 240 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
| 241 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
| 242 | 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format), |
| 243 | 'flavors': reverse('flavor-list', request=request, format=format), |
| 244 | 'projects': reverse('project-list', request=request, format=format), |
| 245 | 'slices': reverse('slice-list', request=request, format=format), |
| 246 | 'networks': reverse('network-list', request=request, format=format), |
| 247 | 'services': reverse('service-list', request=request, format=format), |
| 248 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 249 | 'payments': reverse('payment-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 250 | 'charges': reverse('charge-list', request=request, format=format), |
| 251 | 'roles': reverse('role-list', request=request, format=format), |
| 252 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
| 253 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 254 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 255 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 256 | 'nodes': reverse('node-list', request=request, format=format), |
| 257 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 258 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 259 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
| 260 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 261 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
| 262 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 263 | 'users': reverse('user-list', request=request, format=format), |
| 264 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 265 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 266 | 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 267 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 268 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
| 269 | 'userdeploymentses': reverse('userdeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 270 | 'accounts': reverse('account-list', request=request, format=format), |
| 271 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 272 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
| 273 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 274 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
| 275 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 276 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 277 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
| 278 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
| 279 | 'routers': reverse('router-list', request=request, format=format), |
| 280 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
| 281 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 282 | }) |
| 283 | |
| 284 | # Based on serializers.py |
| 285 | |
| 286 | |
| 287 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 288 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 289 | id = serializers.Field() |
| 290 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 291 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 292 | def getHumanReadableName(self, obj):
|
| 293 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 294 | class Meta: |
| 295 | model = ServiceAttribute |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 296 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 297 | |
| 298 | class ServiceAttributeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 299 | id = serializers.Field() |
| 300 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 301 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 302 | def getHumanReadableName(self, obj):
|
| 303 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 304 | class Meta: |
| 305 | model = ServiceAttribute |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 306 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 307 | |
| 308 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 309 | |
| 310 | |
| 311 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 312 | id = serializers.Field() |
| 313 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 314 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 315 | def getHumanReadableName(self, obj):
|
| 316 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 317 | class Meta: |
| 318 | model = Image |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 319 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 320 | |
| 321 | class ImageIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 322 | id = serializers.Field() |
| 323 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 324 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 325 | def getHumanReadableName(self, obj):
|
| 326 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 327 | class Meta: |
| 328 | model = Image |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 329 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 330 | |
| 331 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 332 | |
| 333 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 334 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 335 | id = serializers.Field() |
| 336 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 337 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 338 | def getHumanReadableName(self, obj):
|
| 339 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 340 | class Meta: |
| 341 | model = NetworkParameter |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 342 | fields = ('humanReadableName', '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] | 343 | |
| 344 | class NetworkParameterIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 345 | id = serializers.Field() |
| 346 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 347 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 348 | def getHumanReadableName(self, obj):
|
| 349 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 350 | class Meta: |
| 351 | model = NetworkParameter |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 352 | fields = ('humanReadableName', '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] | 353 | |
| 354 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 355 | |
| 356 | |
| 357 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 358 | id = serializers.Field() |
| 359 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 360 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 361 | def getHumanReadableName(self, obj):
|
| 362 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 363 | class Meta: |
| 364 | model = Site |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 365 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 366 | |
| 367 | class SiteIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 368 | id = serializers.Field() |
| 369 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 370 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 371 | def getHumanReadableName(self, obj):
|
| 372 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 373 | class Meta: |
| 374 | model = Site |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 375 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 376 | |
| 377 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 378 | |
| 379 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 380 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 381 | id = serializers.Field() |
| 382 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 383 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 384 | def getHumanReadableName(self, obj):
|
| 385 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 386 | class Meta: |
| 387 | model = SliceRole |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 388 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 389 | |
| 390 | class SliceRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 391 | id = serializers.Field() |
| 392 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 393 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 394 | def getHumanReadableName(self, obj):
|
| 395 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 396 | class Meta: |
| 397 | model = SliceRole |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 398 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 399 | |
| 400 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 401 | |
| 402 | |
| 403 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 404 | id = serializers.Field() |
| 405 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 406 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 407 | def getHumanReadableName(self, obj):
|
| 408 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 409 | class Meta: |
| 410 | model = Tag |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 411 | fields = ('humanReadableName', '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] | 412 | |
| 413 | class TagIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 414 | id = serializers.Field() |
| 415 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 416 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 417 | def getHumanReadableName(self, obj):
|
| 418 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 419 | class Meta: |
| 420 | model = Tag |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 421 | fields = ('humanReadableName', '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] | 422 | |
| 423 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 424 | |
| 425 | |
| 426 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 427 | id = serializers.Field() |
| 428 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 429 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 430 | def getHumanReadableName(self, obj):
|
| 431 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 432 | class Meta: |
| 433 | model = Invoice |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 434 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 435 | |
| 436 | class InvoiceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 437 | id = serializers.Field() |
| 438 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 439 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 440 | def getHumanReadableName(self, obj):
|
| 441 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 442 | class Meta: |
| 443 | model = Invoice |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 444 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 445 | |
| 446 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 447 | |
| 448 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 449 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 450 | id = serializers.Field() |
| 451 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 452 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 453 | def getHumanReadableName(self, obj):
|
| 454 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 455 | class Meta: |
| 456 | model = SlicePrivilege |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 457 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 458 | |
| 459 | class SlicePrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 460 | id = serializers.Field() |
| 461 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 462 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 463 | def getHumanReadableName(self, obj):
|
| 464 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 465 | class Meta: |
| 466 | model = SlicePrivilege |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 467 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 468 | |
| 469 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 470 | |
| 471 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 472 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 473 | id = serializers.Field() |
| 474 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 475 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 476 | def getHumanReadableName(self, obj):
|
| 477 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 478 | class Meta: |
| 479 | model = PlanetStackRole |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 480 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 481 | |
| 482 | class PlanetStackRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 483 | id = serializers.Field() |
| 484 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 485 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 486 | def getHumanReadableName(self, obj):
|
| 487 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 488 | class Meta: |
| 489 | model = PlanetStackRole |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 490 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 491 | |
| 492 | |
| 493 | |
| 494 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 495 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 496 | id = serializers.Field() |
| 497 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 498 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 499 | def getHumanReadableName(self, obj):
|
| 500 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 501 | class Meta: |
| 502 | model = NetworkSliver |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 503 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 504 | |
| 505 | class NetworkSliverIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 506 | id = serializers.Field() |
| 507 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 508 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 509 | def getHumanReadableName(self, obj):
|
| 510 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 511 | class Meta: |
| 512 | model = NetworkSliver |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 513 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 514 | |
| 515 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 516 | |
| 517 | |
| 518 | class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 519 | id = serializers.Field() |
| 520 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 521 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 522 | def getHumanReadableName(self, obj):
|
| 523 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 524 | class Meta: |
| 525 | model = NetworkDeployments |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 526 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 527 | |
| 528 | class NetworkDeploymentsIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 529 | id = serializers.Field() |
| 530 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 531 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 532 | def getHumanReadableName(self, obj):
|
| 533 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 534 | class Meta: |
| 535 | model = NetworkDeployments |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 536 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 537 | |
| 538 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 539 | |
| 540 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 541 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 542 | id = serializers.Field() |
| 543 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 544 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 545 | def getHumanReadableName(self, obj):
|
| 546 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 547 | class Meta: |
| 548 | model = Flavor |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 549 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 550 | |
| 551 | class FlavorIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 552 | id = serializers.Field() |
| 553 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 554 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 555 | def getHumanReadableName(self, obj):
|
| 556 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 557 | class Meta: |
| 558 | model = Flavor |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 559 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 565 | id = serializers.Field() |
| 566 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 567 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 568 | def getHumanReadableName(self, obj):
|
| 569 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 570 | class Meta: |
| 571 | model = Project |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 572 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 573 | |
| 574 | class ProjectIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 575 | id = serializers.Field() |
| 576 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 577 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 578 | def getHumanReadableName(self, obj):
|
| 579 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 580 | class Meta: |
| 581 | model = Project |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 582 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 583 | |
| 584 | |
| 585 | |
| 586 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 587 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 588 | id = serializers.Field() |
| 589 | |
| 590 | |
| 591 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 592 | |
| 593 | |
| 594 | |
| 595 | availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 596 | |
| 597 | |
| 598 | |
| 599 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 600 | |
| 601 | |
| 602 | |
| 603 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 604 | |
| 605 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 606 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 607 | def getHumanReadableName(self, obj):
|
| 608 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 609 | class Meta: |
| 610 | model = Slice |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 611 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 612 | |
| 613 | class SliceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 614 | id = serializers.Field() |
| 615 | |
| 616 | |
| 617 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 618 | |
| 619 | |
| 620 | |
| 621 | availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 622 | |
| 623 | |
| 624 | |
| 625 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 626 | |
| 627 | |
| 628 | |
| 629 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 630 | |
| 631 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 632 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 633 | def getHumanReadableName(self, obj):
|
| 634 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 635 | class Meta: |
| 636 | model = Slice |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 637 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 638 | |
| 639 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 640 | |
| 641 | |
| 642 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 643 | id = serializers.Field() |
| 644 | |
| 645 | |
| 646 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 647 | |
| 648 | |
| 649 | |
| 650 | availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 651 | |
| 652 | |
| 653 | |
| 654 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 655 | |
| 656 | |
| 657 | |
| 658 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 659 | |
| 660 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 661 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 662 | def getHumanReadableName(self, obj):
|
| 663 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 664 | class Meta: |
| 665 | model = Network |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 666 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 667 | |
| 668 | class NetworkIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 669 | id = serializers.Field() |
| 670 | |
| 671 | |
| 672 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 673 | |
| 674 | |
| 675 | |
| 676 | availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 677 | |
| 678 | |
| 679 | |
| 680 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 681 | |
| 682 | |
| 683 | |
| 684 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 685 | |
| 686 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 687 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 688 | def getHumanReadableName(self, obj):
|
| 689 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 690 | class Meta: |
| 691 | model = Network |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 692 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 693 | |
| 694 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 695 | |
| 696 | |
| 697 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 698 | id = serializers.Field() |
| 699 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 700 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 701 | def getHumanReadableName(self, obj):
|
| 702 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 703 | class Meta: |
| 704 | model = Service |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 705 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 706 | |
| 707 | class ServiceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 708 | id = serializers.Field() |
| 709 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 710 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 711 | def getHumanReadableName(self, obj):
|
| 712 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 713 | class Meta: |
| 714 | model = Service |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 715 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 716 | |
| 717 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 718 | |
| 719 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 720 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 721 | id = serializers.Field() |
| 722 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 723 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 724 | def getHumanReadableName(self, obj):
|
| 725 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 726 | class Meta: |
| 727 | model = ServiceClass |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 728 | fields = ('humanReadableName', '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] | 729 | |
| 730 | class ServiceClassIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 731 | id = serializers.Field() |
| 732 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 733 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 734 | def getHumanReadableName(self, obj):
|
| 735 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 736 | class Meta: |
| 737 | model = ServiceClass |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 738 | fields = ('humanReadableName', '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] | 739 | |
| 740 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 741 | |
| 742 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 743 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 744 | id = serializers.Field() |
| 745 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 746 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 747 | def getHumanReadableName(self, obj):
|
| 748 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 749 | class Meta: |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 750 | model = Payment |
| 751 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 752 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 753 | class PaymentIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 754 | id = serializers.Field() |
| 755 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 756 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 757 | def getHumanReadableName(self, obj):
|
| 758 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 759 | class Meta: |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 760 | model = Payment |
| 761 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 762 | |
| 763 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 764 | |
| 765 | |
| 766 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 767 | id = serializers.Field() |
| 768 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 769 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 770 | def getHumanReadableName(self, obj):
|
| 771 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 772 | class Meta: |
| 773 | model = Charge |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 774 | fields = ('humanReadableName', '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] | 775 | |
| 776 | class ChargeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 777 | id = serializers.Field() |
| 778 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 779 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 780 | def getHumanReadableName(self, obj):
|
| 781 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 782 | class Meta: |
| 783 | model = Charge |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 784 | fields = ('humanReadableName', '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] | 785 | |
| 786 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 787 | |
| 788 | |
| 789 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 790 | id = serializers.Field() |
| 791 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 792 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 793 | def getHumanReadableName(self, obj):
|
| 794 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 795 | class Meta: |
| 796 | model = Role |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 797 | fields = ('humanReadableName', '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] | 798 | |
| 799 | class RoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 800 | id = serializers.Field() |
| 801 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 802 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 803 | def getHumanReadableName(self, obj):
|
| 804 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 805 | class Meta: |
| 806 | model = Role |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 807 | fields = ('humanReadableName', '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] | 808 | |
| 809 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 810 | |
| 811 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 812 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 813 | id = serializers.Field() |
| 814 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 815 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 816 | def getHumanReadableName(self, obj):
|
| 817 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 818 | class Meta: |
| 819 | model = UsableObject |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 820 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 821 | |
| 822 | class UsableObjectIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 823 | id = serializers.Field() |
| 824 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 825 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 826 | def getHumanReadableName(self, obj):
|
| 827 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 828 | class Meta: |
| 829 | model = UsableObject |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 830 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 831 | |
| 832 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 833 | |
| 834 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 835 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 836 | id = serializers.Field() |
| 837 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 838 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 839 | def getHumanReadableName(self, obj):
|
| 840 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 841 | class Meta: |
| 842 | model = SiteRole |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 843 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 844 | |
| 845 | class SiteRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 846 | id = serializers.Field() |
| 847 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 848 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 849 | def getHumanReadableName(self, obj):
|
| 850 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 851 | class Meta: |
| 852 | model = SiteRole |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 853 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 854 | |
| 855 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 856 | |
| 857 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 858 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 859 | id = serializers.Field() |
| 860 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 861 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 862 | def getHumanReadableName(self, obj):
|
| 863 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 864 | class Meta: |
| 865 | model = SliceCredential |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 866 | fields = ('humanReadableName', '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] | 867 | |
| 868 | class SliceCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 869 | id = serializers.Field() |
| 870 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 871 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 872 | def getHumanReadableName(self, obj):
|
| 873 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 874 | class Meta: |
| 875 | model = SliceCredential |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 876 | fields = ('humanReadableName', '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] | 877 | |
| 878 | |
| 879 | |
| 880 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 881 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 882 | id = serializers.Field() |
| 883 | |
| 884 | |
| 885 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 886 | |
| 887 | |
| 888 | |
| 889 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 890 | |
| 891 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 892 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 893 | def getHumanReadableName(self, obj):
|
| 894 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 895 | class Meta: |
| 896 | model = Sliver |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 897 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 898 | |
| 899 | class SliverIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 900 | id = serializers.Field() |
| 901 | |
| 902 | |
| 903 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 904 | |
| 905 | |
| 906 | |
| 907 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 908 | |
| 909 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 910 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 911 | def getHumanReadableName(self, obj):
|
| 912 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 913 | class Meta: |
| 914 | model = Sliver |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 915 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 916 | |
| 917 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 918 | |
| 919 | |
| 920 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 921 | id = serializers.Field() |
| 922 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 923 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 924 | def getHumanReadableName(self, obj):
|
| 925 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 926 | class Meta: |
| 927 | model = Node |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 928 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 929 | |
| 930 | class NodeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 931 | id = serializers.Field() |
| 932 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 933 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 934 | def getHumanReadableName(self, obj):
|
| 935 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 936 | class Meta: |
| 937 | model = Node |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 938 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 939 | |
| 940 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 941 | |
| 942 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 943 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 944 | id = serializers.Field() |
| 945 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 946 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 947 | def getHumanReadableName(self, obj):
|
| 948 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 949 | class Meta: |
| 950 | model = DashboardView |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 951 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','url',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 952 | |
| 953 | class DashboardViewIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 954 | id = serializers.Field() |
| 955 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 956 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 957 | def getHumanReadableName(self, obj):
|
| 958 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 959 | class Meta: |
| 960 | model = DashboardView |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 961 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','url',) |
| 962 | |
| 963 | |
| 964 | |
| 965 | |
| 966 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 967 | id = serializers.Field() |
| 968 | |
| 969 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 970 | def getHumanReadableName(self, obj):
|
| 971 | return str(obj) |
| 972 | class Meta: |
| 973 | model = ImageDeployments |
| 974 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
| 975 | |
| 976 | class ImageDeploymentsIdSerializer(serializers.ModelSerializer): |
| 977 | id = serializers.Field() |
| 978 | |
| 979 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 980 | def getHumanReadableName(self, obj):
|
| 981 | return str(obj)
|
| 982 | class Meta: |
| 983 | model = ImageDeployments |
| 984 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 985 | |
| 986 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 987 | |
| 988 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 989 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 990 | id = serializers.Field() |
| 991 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 992 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 993 | def getHumanReadableName(self, obj):
|
| 994 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 995 | class Meta: |
| 996 | model = ReservedResource |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 997 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 998 | |
| 999 | class ReservedResourceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1000 | id = serializers.Field() |
| 1001 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1002 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1003 | def getHumanReadableName(self, obj):
|
| 1004 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1005 | class Meta: |
| 1006 | model = ReservedResource |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1007 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1008 | |
| 1009 | |
| 1010 | |
| 1011 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1012 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1013 | id = serializers.Field() |
| 1014 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1015 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1016 | def getHumanReadableName(self, obj):
|
| 1017 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1018 | class Meta: |
| 1019 | model = NetworkSlice |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1020 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1021 | |
| 1022 | class NetworkSliceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1023 | id = serializers.Field() |
| 1024 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1025 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1026 | def getHumanReadableName(self, obj):
|
| 1027 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1028 | class Meta: |
| 1029 | model = NetworkSlice |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1030 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1031 | |
| 1032 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1033 | |
| 1034 | |
| 1035 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1036 | id = serializers.Field() |
| 1037 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1038 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1039 | def getHumanReadableName(self, obj):
|
| 1040 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1041 | class Meta: |
| 1042 | model = UserDashboardView |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1043 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1044 | |
| 1045 | class UserDashboardViewIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1046 | id = serializers.Field() |
| 1047 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1048 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1049 | def getHumanReadableName(self, obj):
|
| 1050 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1051 | class Meta: |
| 1052 | model = UserDashboardView |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1053 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1058 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1059 | id = serializers.Field() |
| 1060 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1061 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1062 | def getHumanReadableName(self, obj):
|
| 1063 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1064 | class Meta: |
| 1065 | model = PlanetStackPrivilege |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1066 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1067 | |
| 1068 | class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1069 | id = serializers.Field() |
| 1070 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1071 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1072 | def getHumanReadableName(self, obj):
|
| 1073 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1074 | class Meta: |
| 1075 | model = PlanetStackPrivilege |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1076 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1077 | |
| 1078 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1079 | |
| 1080 | |
| 1081 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1082 | id = serializers.Field() |
| 1083 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1084 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1085 | def getHumanReadableName(self, obj):
|
| 1086 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1087 | class Meta: |
| 1088 | model = User |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1089 | fields = ('humanReadableName', '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',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1090 | |
| 1091 | class UserIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1092 | id = serializers.Field() |
| 1093 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1094 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1095 | def getHumanReadableName(self, obj):
|
| 1096 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1097 | class Meta: |
| 1098 | model = User |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1099 | fields = ('humanReadableName', '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',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1100 | |
| 1101 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1102 | |
| 1103 | |
| 1104 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1105 | id = serializers.Field() |
| 1106 | |
| 1107 | |
| 1108 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1109 | |
| 1110 | |
| 1111 | |
| 1112 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1113 | |
| 1114 | |
| 1115 | |
| 1116 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1117 | |
| 1118 | |
| 1119 | |
| 1120 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1121 | |
| 1122 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1123 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1124 | def getHumanReadableName(self, obj):
|
| 1125 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1126 | class Meta: |
| 1127 | model = Deployment |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1128 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1129 | |
| 1130 | class DeploymentIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1131 | id = serializers.Field() |
| 1132 | |
| 1133 | |
| 1134 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1135 | |
| 1136 | |
| 1137 | |
| 1138 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1143 | |
| 1144 | |
| 1145 | |
| 1146 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1147 | |
| 1148 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1149 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1150 | def getHumanReadableName(self, obj):
|
| 1151 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1152 | class Meta: |
| 1153 | model = Deployment |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1154 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1155 | |
| 1156 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1157 | |
| 1158 | |
| 1159 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1160 | id = serializers.Field() |
| 1161 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1162 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1163 | def getHumanReadableName(self, obj):
|
| 1164 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1165 | class Meta: |
| 1166 | model = Reservation |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1167 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1168 | |
| 1169 | class ReservationIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1170 | id = serializers.Field() |
| 1171 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1172 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1173 | def getHumanReadableName(self, obj):
|
| 1174 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1175 | class Meta: |
| 1176 | model = Reservation |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1177 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1178 | |
| 1179 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1180 | |
| 1181 | |
Sapan Bhatia | 85e0908 | 2014-11-19 15:09:38 -0500 | [diff] [blame] | 1182 | class SliceDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1183 | id = serializers.Field() |
| 1184 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1185 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1186 | def getHumanReadableName(self, obj):
|
| 1187 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1188 | class Meta: |
Sapan Bhatia | 85e0908 | 2014-11-19 15:09:38 -0500 | [diff] [blame] | 1189 | model = SliceDeployments |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1190 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1191 | |
Sapan Bhatia | 85e0908 | 2014-11-19 15:09:38 -0500 | [diff] [blame] | 1192 | class SliceDeploymentsIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1193 | id = serializers.Field() |
| 1194 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1195 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1196 | def getHumanReadableName(self, obj):
|
| 1197 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1198 | class Meta: |
Sapan Bhatia | 85e0908 | 2014-11-19 15:09:38 -0500 | [diff] [blame] | 1199 | model = SliceDeployments |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1200 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
| 1201 | |
| 1202 | |
| 1203 | |
| 1204 | |
| 1205 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 1206 | id = serializers.Field() |
| 1207 | |
| 1208 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1209 | def getHumanReadableName(self, obj):
|
| 1210 | return str(obj) |
| 1211 | class Meta: |
| 1212 | model = SitePrivilege |
| 1213 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 1214 | |
| 1215 | class SitePrivilegeIdSerializer(serializers.ModelSerializer): |
| 1216 | id = serializers.Field() |
| 1217 | |
| 1218 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1219 | def getHumanReadableName(self, obj):
|
| 1220 | return str(obj)
|
| 1221 | class Meta: |
| 1222 | model = SitePrivilege |
| 1223 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 1224 | |
| 1225 | |
| 1226 | |
| 1227 | |
| 1228 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
| 1229 | id = serializers.Field() |
| 1230 | |
| 1231 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1232 | def getHumanReadableName(self, obj):
|
| 1233 | return str(obj) |
| 1234 | class Meta: |
| 1235 | model = PlanetStack |
| 1236 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','description',) |
| 1237 | |
| 1238 | class PlanetStackIdSerializer(serializers.ModelSerializer): |
| 1239 | id = serializers.Field() |
| 1240 | |
| 1241 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1242 | def getHumanReadableName(self, obj):
|
| 1243 | return str(obj)
|
| 1244 | class Meta: |
| 1245 | model = PlanetStack |
| 1246 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1247 | |
| 1248 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1249 | |
| 1250 | |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 1251 | class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1252 | id = serializers.Field() |
| 1253 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1254 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1255 | def getHumanReadableName(self, obj):
|
| 1256 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1257 | class Meta: |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 1258 | model = UserDeployments |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1259 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1260 | |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 1261 | class UserDeploymentsIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1262 | id = serializers.Field() |
| 1263 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1264 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1265 | def getHumanReadableName(self, obj):
|
| 1266 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1267 | class Meta: |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 1268 | model = UserDeployments |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1269 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1270 | |
| 1271 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1272 | |
| 1273 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1274 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1275 | id = serializers.Field() |
| 1276 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1277 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1278 | def getHumanReadableName(self, obj):
|
| 1279 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1280 | class Meta: |
| 1281 | model = Account |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1282 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1283 | |
| 1284 | class AccountIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1285 | id = serializers.Field() |
| 1286 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1287 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1288 | def getHumanReadableName(self, obj):
|
| 1289 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1290 | class Meta: |
| 1291 | model = Account |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1292 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1293 | |
| 1294 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1295 | |
| 1296 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1297 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1298 | id = serializers.Field() |
| 1299 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1300 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1301 | def getHumanReadableName(self, obj):
|
| 1302 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1303 | class Meta: |
| 1304 | model = NetworkParameterType |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1305 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1306 | |
| 1307 | class NetworkParameterTypeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1308 | id = serializers.Field() |
| 1309 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1310 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1311 | def getHumanReadableName(self, obj):
|
| 1312 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1313 | class Meta: |
| 1314 | model = NetworkParameterType |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1315 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1316 | |
| 1317 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1318 | |
| 1319 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1320 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1321 | id = serializers.Field() |
| 1322 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1323 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1324 | def getHumanReadableName(self, obj):
|
| 1325 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1326 | class Meta: |
| 1327 | model = SiteCredential |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1328 | fields = ('humanReadableName', '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] | 1329 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1330 | class SiteCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1331 | id = serializers.Field() |
| 1332 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1333 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1334 | def getHumanReadableName(self, obj):
|
| 1335 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1336 | class Meta: |
| 1337 | model = SiteCredential |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1338 | fields = ('humanReadableName', '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] | 1339 | |
| 1340 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1341 | |
| 1342 | |
| 1343 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1344 | id = serializers.Field() |
| 1345 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1346 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1347 | def getHumanReadableName(self, obj):
|
| 1348 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1349 | class Meta: |
| 1350 | model = DeploymentPrivilege |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1351 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1352 | |
| 1353 | class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1354 | id = serializers.Field() |
| 1355 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1356 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1357 | def getHumanReadableName(self, obj):
|
| 1358 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1359 | class Meta: |
| 1360 | model = DeploymentPrivilege |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1361 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1362 | |
| 1363 | |
| 1364 | |
| 1365 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1366 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1367 | id = serializers.Field() |
| 1368 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1369 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1370 | def getHumanReadableName(self, obj):
|
| 1371 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1372 | class Meta: |
| 1373 | model = DeploymentRole |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1374 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1375 | |
| 1376 | class DeploymentRoleIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1377 | id = serializers.Field() |
| 1378 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1379 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1380 | def getHumanReadableName(self, obj):
|
| 1381 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1382 | class Meta: |
| 1383 | model = DeploymentRole |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1384 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1385 | |
| 1386 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1387 | |
| 1388 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1389 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1390 | id = serializers.Field() |
| 1391 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1392 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1393 | def getHumanReadableName(self, obj):
|
| 1394 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1395 | class Meta: |
| 1396 | model = UserCredential |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1397 | fields = ('humanReadableName', '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] | 1398 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1399 | class UserCredentialIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1400 | id = serializers.Field() |
| 1401 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1402 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1403 | def getHumanReadableName(self, obj):
|
| 1404 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1405 | class Meta: |
| 1406 | model = UserCredential |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1407 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 1408 | |
| 1409 | |
| 1410 | |
| 1411 | |
| 1412 | class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 1413 | id = serializers.Field() |
| 1414 | |
| 1415 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1416 | def getHumanReadableName(self, obj):
|
| 1417 | return str(obj) |
| 1418 | class Meta: |
| 1419 | model = SiteDeployments |
| 1420 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
| 1421 | |
| 1422 | class SiteDeploymentsIdSerializer(serializers.ModelSerializer): |
| 1423 | id = serializers.Field() |
| 1424 | |
| 1425 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1426 | def getHumanReadableName(self, obj):
|
| 1427 | return str(obj)
|
| 1428 | class Meta: |
| 1429 | model = SiteDeployments |
| 1430 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1431 | |
| 1432 | |
| 1433 | |
| 1434 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1435 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1436 | id = serializers.Field() |
| 1437 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1438 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1439 | def getHumanReadableName(self, obj):
|
| 1440 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1441 | class Meta: |
| 1442 | model = SliceTag |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1443 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1444 | |
| 1445 | class SliceTagIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1446 | id = serializers.Field() |
| 1447 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1448 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1449 | def getHumanReadableName(self, obj):
|
| 1450 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1451 | class Meta: |
| 1452 | model = SliceTag |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1453 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1454 | |
| 1455 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1456 | |
| 1457 | |
| 1458 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1459 | id = serializers.Field() |
| 1460 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1461 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1462 | def getHumanReadableName(self, obj):
|
| 1463 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1464 | class Meta: |
| 1465 | model = NetworkTemplate |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1466 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1467 | |
| 1468 | class NetworkTemplateIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1469 | id = serializers.Field() |
| 1470 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1471 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1472 | def getHumanReadableName(self, obj):
|
| 1473 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1474 | class Meta: |
| 1475 | model = NetworkTemplate |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1476 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1477 | |
| 1478 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1479 | |
| 1480 | |
| 1481 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1482 | id = serializers.Field() |
| 1483 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1484 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1485 | def getHumanReadableName(self, obj):
|
| 1486 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1487 | class Meta: |
| 1488 | model = Router |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1489 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','owner',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1490 | |
| 1491 | class RouterIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1492 | id = serializers.Field() |
| 1493 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1494 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1495 | def getHumanReadableName(self, obj):
|
| 1496 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1497 | class Meta: |
| 1498 | model = Router |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1499 | fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','owner',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1500 | |
| 1501 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1502 | |
| 1503 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1504 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1505 | id = serializers.Field() |
| 1506 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1507 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1508 | def getHumanReadableName(self, obj):
|
| 1509 | return str(obj) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1510 | class Meta: |
| 1511 | model = ServiceResource |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1512 | fields = ('humanReadableName', '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] | 1513 | |
| 1514 | class ServiceResourceIdSerializer(serializers.ModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1515 | id = serializers.Field() |
| 1516 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1517 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1518 | def getHumanReadableName(self, obj):
|
| 1519 | return str(obj)
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1520 | class Meta: |
| 1521 | model = ServiceResource |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1522 | fields = ('humanReadableName', '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] | 1523 | |
| 1524 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1525 | |
| 1526 | |
| 1527 | serializerLookUp = { |
| 1528 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1529 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1530 | |
| 1531 | Image: ImageSerializer, |
| 1532 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1533 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1534 | |
| 1535 | Site: SiteSerializer, |
| 1536 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1537 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1538 | |
| 1539 | Tag: TagSerializer, |
| 1540 | |
| 1541 | Invoice: InvoiceSerializer, |
| 1542 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1543 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1544 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1545 | PlanetStackRole: PlanetStackRoleSerializer, |
| 1546 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1547 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1548 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1549 | NetworkDeployments: NetworkDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1550 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1551 | Flavor: FlavorSerializer, |
| 1552 | |
| 1553 | Project: ProjectSerializer, |
| 1554 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1555 | Slice: SliceSerializer, |
| 1556 | |
| 1557 | Network: NetworkSerializer, |
| 1558 | |
| 1559 | Service: ServiceSerializer, |
| 1560 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1561 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1562 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1563 | Payment: PaymentSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1564 | |
| 1565 | Charge: ChargeSerializer, |
| 1566 | |
| 1567 | Role: RoleSerializer, |
| 1568 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1569 | UsableObject: UsableObjectSerializer, |
| 1570 | |
| 1571 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1572 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1573 | SliceCredential: SliceCredentialSerializer, |
| 1574 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1575 | Sliver: SliverSerializer, |
| 1576 | |
| 1577 | Node: NodeSerializer, |
| 1578 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1579 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1580 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1581 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1582 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1583 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1584 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1585 | NetworkSlice: NetworkSliceSerializer, |
| 1586 | |
| 1587 | UserDashboardView: UserDashboardViewSerializer, |
| 1588 | |
| 1589 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1590 | |
| 1591 | User: UserSerializer, |
| 1592 | |
| 1593 | Deployment: DeploymentSerializer, |
| 1594 | |
| 1595 | Reservation: ReservationSerializer, |
| 1596 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1597 | SliceDeployments: SliceDeploymentsSerializer, |
| 1598 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1599 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1600 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1601 | PlanetStack: PlanetStackSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1602 | |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 1603 | UserDeployments: UserDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1604 | |
| 1605 | Account: AccountSerializer, |
| 1606 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1607 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1608 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1609 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1610 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1611 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1612 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1613 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1614 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1615 | UserCredential: UserCredentialSerializer, |
| 1616 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1617 | SiteDeployments: SiteDeploymentsSerializer, |
| 1618 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1619 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1620 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1621 | NetworkTemplate: NetworkTemplateSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1622 | |
| 1623 | Router: RouterSerializer, |
| 1624 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1625 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1626 | |
| 1627 | None: None, |
| 1628 | } |
| 1629 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1630 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 1631 | |
| 1632 | # To handle fine-grained field permissions, we have to check can_update |
| 1633 | # the object has been updated but before it has been saved. |
| 1634 | |
| 1635 | def update(self, request, *args, **kwargs):
|
| 1636 | partial = kwargs.pop('partial', False)
|
| 1637 | self.object = self.get_object_or_none()
|
| 1638 |
|
| 1639 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 1640 | files=request.FILES, partial=partial)
|
| 1641 |
|
| 1642 | if not serializer.is_valid():
|
| 1643 | print "UpdateModelMixin: not serializer.is_valid"
|
| 1644 | print serializer.errors
|
| 1645 | return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
| 1646 |
|
| 1647 | try:
|
| 1648 | self.pre_save(serializer.object)
|
| 1649 | except ValidationError as err:
|
| 1650 | # full_clean on model instance may be called in pre_save,
|
| 1651 | # so we have to handle eventual errors.
|
| 1652 | return Response(err.message_dict, status=status.HTTP_400_BAD_REQUEST)
|
| 1653 |
|
| 1654 | if serializer.object is not None:
|
| 1655 | if not serializer.object.can_update(request.user):
|
| 1656 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 1657 |
|
| 1658 | if self.object is None:
|
| 1659 | self.object = serializer.save(force_insert=True)
|
| 1660 | self.post_save(self.object, created=True)
|
| 1661 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 1662 |
|
| 1663 | self.object = serializer.save(force_update=True)
|
| 1664 | self.post_save(self.object, created=False)
|
| 1665 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 1666 | |
| 1667 | def destroy(self, request, *args, **kwargs): |
| 1668 | obj = self.get_object() |
| 1669 | if obj.can_update(request.user): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1670 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1671 | else: |
| 1672 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 1673 | |
| 1674 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1675 | # Based on core/views/*.py |
| 1676 | |
| 1677 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1678 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 1679 | queryset = ServiceAttribute.objects.select_related().all() |
| 1680 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1681 | id_serializer_class = ServiceAttributeIdSerializer |
| 1682 | filter_backends = (filters.DjangoFilterBackend,) |
| 1683 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 1684 | |
| 1685 | def get_serializer_class(self): |
| 1686 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1687 | if (no_hyperlinks): |
| 1688 | return self.id_serializer_class |
| 1689 | else: |
| 1690 | return self.serializer_class |
| 1691 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1692 | def get_queryset(self): |
| 1693 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1694 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1695 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 1696 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 1697 | if not (serializer.is_valid()): |
| 1698 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 1699 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1700 | obj.caller = request.user |
| 1701 | if obj.can_update(request.user): |
| 1702 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 1703 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1704 | raise Exception("failed obj.can_update") |
| 1705 | |
| 1706 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 1707 | if (ret.status_code%100 != 200): |
| 1708 | raise Exception(ret.data) |
| 1709 | |
| 1710 | return ret |
| 1711 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1712 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1713 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1714 | queryset = ServiceAttribute.objects.select_related().all() |
| 1715 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1716 | id_serializer_class = ServiceAttributeIdSerializer |
| 1717 | |
| 1718 | def get_serializer_class(self): |
| 1719 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1720 | if (no_hyperlinks): |
| 1721 | return self.id_serializer_class |
| 1722 | else: |
| 1723 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1724 | |
| 1725 | def get_queryset(self): |
| 1726 | return ServiceAttribute.select_by_user(self.request.user) |
| 1727 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1728 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1729 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1730 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1731 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 1732 | """ |
| 1733 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 1734 | filled with defaults. I solved it another way, so this code may soon be |
| 1735 | abandoned. |
| 1736 | |
| 1737 | class ServiceAttributeNew(GenericAPIView): |
| 1738 | serializer_class = ServiceAttributeSerializer |
| 1739 | id_serializer_class = ServiceAttributeIdSerializer |
| 1740 | |
| 1741 | def get(self, request, *args, **kwargs): |
| 1742 | return self.makenew(request, *args, **kwargs) |
| 1743 | |
| 1744 | def get_serializer_class(self): |
| 1745 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1746 | if (no_hyperlinks): |
| 1747 | return self.id_serializer_class |
| 1748 | else: |
| 1749 | return self.serializer_class |
| 1750 | |
| 1751 | def makenew(self, request, *args, **kwargs): |
| 1752 | obj = ServiceAttribute() |
| 1753 | serializer = self.get_serializer(obj) |
| 1754 | return Response(serializer.data) |
| 1755 | """ |
| 1756 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1757 | |
| 1758 | |
| 1759 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1760 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1761 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1762 | id_serializer_class = ImageIdSerializer |
| 1763 | filter_backends = (filters.DjangoFilterBackend,) |
| 1764 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
| 1765 | |
| 1766 | def get_serializer_class(self): |
| 1767 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1768 | if (no_hyperlinks): |
| 1769 | return self.id_serializer_class |
| 1770 | else: |
| 1771 | return self.serializer_class |
| 1772 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1773 | def get_queryset(self): |
| 1774 | return Image.select_by_user(self.request.user) |
| 1775 | |
| 1776 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 1777 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 1778 | if not (serializer.is_valid()): |
| 1779 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 1780 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1781 | obj.caller = request.user |
| 1782 | if obj.can_update(request.user): |
| 1783 | return super(ImageList, self).create(request, *args, **kwargs) |
| 1784 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1785 | raise Exception("failed obj.can_update") |
| 1786 | |
| 1787 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 1788 | if (ret.status_code%100 != 200): |
| 1789 | raise Exception(ret.data) |
| 1790 | |
| 1791 | return ret |
| 1792 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1793 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1794 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1795 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1796 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1797 | id_serializer_class = ImageIdSerializer |
| 1798 | |
| 1799 | def get_serializer_class(self): |
| 1800 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1801 | if (no_hyperlinks): |
| 1802 | return self.id_serializer_class |
| 1803 | else: |
| 1804 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1805 | |
| 1806 | def get_queryset(self): |
| 1807 | return Image.select_by_user(self.request.user) |
| 1808 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1809 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1810 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1811 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1812 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 1813 | """ |
| 1814 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 1815 | filled with defaults. I solved it another way, so this code may soon be |
| 1816 | abandoned. |
| 1817 | |
| 1818 | class ImageNew(GenericAPIView): |
| 1819 | serializer_class = ImageSerializer |
| 1820 | id_serializer_class = ImageIdSerializer |
| 1821 | |
| 1822 | def get(self, request, *args, **kwargs): |
| 1823 | return self.makenew(request, *args, **kwargs) |
| 1824 | |
| 1825 | def get_serializer_class(self): |
| 1826 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1827 | if (no_hyperlinks): |
| 1828 | return self.id_serializer_class |
| 1829 | else: |
| 1830 | return self.serializer_class |
| 1831 | |
| 1832 | def makenew(self, request, *args, **kwargs): |
| 1833 | obj = Image() |
| 1834 | serializer = self.get_serializer(obj) |
| 1835 | return Response(serializer.data) |
| 1836 | """ |
| 1837 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1838 | |
| 1839 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1840 | class NetworkParameterList(generics.ListCreateAPIView): |
| 1841 | queryset = NetworkParameter.objects.select_related().all() |
| 1842 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1843 | id_serializer_class = NetworkParameterIdSerializer |
| 1844 | filter_backends = (filters.DjangoFilterBackend,) |
| 1845 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 1846 | |
| 1847 | def get_serializer_class(self): |
| 1848 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1849 | if (no_hyperlinks): |
| 1850 | return self.id_serializer_class |
| 1851 | else: |
| 1852 | return self.serializer_class |
| 1853 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1854 | def get_queryset(self): |
| 1855 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1856 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1857 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 1858 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 1859 | if not (serializer.is_valid()): |
| 1860 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 1861 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1862 | obj.caller = request.user |
| 1863 | if obj.can_update(request.user): |
| 1864 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 1865 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1866 | raise Exception("failed obj.can_update") |
| 1867 | |
| 1868 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 1869 | if (ret.status_code%100 != 200): |
| 1870 | raise Exception(ret.data) |
| 1871 | |
| 1872 | return ret |
| 1873 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1874 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1875 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1876 | queryset = NetworkParameter.objects.select_related().all() |
| 1877 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1878 | id_serializer_class = NetworkParameterIdSerializer |
| 1879 | |
| 1880 | def get_serializer_class(self): |
| 1881 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1882 | if (no_hyperlinks): |
| 1883 | return self.id_serializer_class |
| 1884 | else: |
| 1885 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1886 | |
| 1887 | def get_queryset(self): |
| 1888 | return NetworkParameter.select_by_user(self.request.user) |
| 1889 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1890 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1891 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1892 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1893 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 1894 | """ |
| 1895 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 1896 | filled with defaults. I solved it another way, so this code may soon be |
| 1897 | abandoned. |
| 1898 | |
| 1899 | class NetworkParameterNew(GenericAPIView): |
| 1900 | serializer_class = NetworkParameterSerializer |
| 1901 | id_serializer_class = NetworkParameterIdSerializer |
| 1902 | |
| 1903 | def get(self, request, *args, **kwargs): |
| 1904 | return self.makenew(request, *args, **kwargs) |
| 1905 | |
| 1906 | def get_serializer_class(self): |
| 1907 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1908 | if (no_hyperlinks): |
| 1909 | return self.id_serializer_class |
| 1910 | else: |
| 1911 | return self.serializer_class |
| 1912 | |
| 1913 | def makenew(self, request, *args, **kwargs): |
| 1914 | obj = NetworkParameter() |
| 1915 | serializer = self.get_serializer(obj) |
| 1916 | return Response(serializer.data) |
| 1917 | """ |
| 1918 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1919 | |
| 1920 | |
| 1921 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1922 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1923 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1924 | id_serializer_class = SiteIdSerializer |
| 1925 | filter_backends = (filters.DjangoFilterBackend,) |
| 1926 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',) |
| 1927 | |
| 1928 | def get_serializer_class(self): |
| 1929 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1930 | if (no_hyperlinks): |
| 1931 | return self.id_serializer_class |
| 1932 | else: |
| 1933 | return self.serializer_class |
| 1934 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1935 | def get_queryset(self): |
| 1936 | return Site.select_by_user(self.request.user) |
| 1937 | |
| 1938 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 1939 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 1940 | if not (serializer.is_valid()): |
| 1941 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 1942 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1943 | obj.caller = request.user |
| 1944 | if obj.can_update(request.user): |
| 1945 | return super(SiteList, self).create(request, *args, **kwargs) |
| 1946 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1947 | raise Exception("failed obj.can_update") |
| 1948 | |
| 1949 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 1950 | if (ret.status_code%100 != 200): |
| 1951 | raise Exception(ret.data) |
| 1952 | |
| 1953 | return ret |
| 1954 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1955 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1956 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1957 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1958 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1959 | id_serializer_class = SiteIdSerializer |
| 1960 | |
| 1961 | def get_serializer_class(self): |
| 1962 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1963 | if (no_hyperlinks): |
| 1964 | return self.id_serializer_class |
| 1965 | else: |
| 1966 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1967 | |
| 1968 | def get_queryset(self): |
| 1969 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1970 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1971 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1972 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1973 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1974 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 1975 | """ |
| 1976 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 1977 | filled with defaults. I solved it another way, so this code may soon be |
| 1978 | abandoned. |
| 1979 | |
| 1980 | class SiteNew(GenericAPIView): |
| 1981 | serializer_class = SiteSerializer |
| 1982 | id_serializer_class = SiteIdSerializer |
| 1983 | |
| 1984 | def get(self, request, *args, **kwargs): |
| 1985 | return self.makenew(request, *args, **kwargs) |
| 1986 | |
| 1987 | def get_serializer_class(self): |
| 1988 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 1989 | if (no_hyperlinks): |
| 1990 | return self.id_serializer_class |
| 1991 | else: |
| 1992 | return self.serializer_class |
| 1993 | |
| 1994 | def makenew(self, request, *args, **kwargs): |
| 1995 | obj = Site() |
| 1996 | serializer = self.get_serializer(obj) |
| 1997 | return Response(serializer.data) |
| 1998 | """ |
| 1999 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2000 | |
| 2001 | |
| 2002 | class SliceRoleList(generics.ListCreateAPIView): |
| 2003 | queryset = SliceRole.objects.select_related().all() |
| 2004 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2005 | id_serializer_class = SliceRoleIdSerializer |
| 2006 | filter_backends = (filters.DjangoFilterBackend,) |
| 2007 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2008 | |
| 2009 | def get_serializer_class(self): |
| 2010 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2011 | if (no_hyperlinks): |
| 2012 | return self.id_serializer_class |
| 2013 | else: |
| 2014 | return self.serializer_class |
| 2015 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2016 | def get_queryset(self): |
| 2017 | return SliceRole.select_by_user(self.request.user) |
| 2018 | |
| 2019 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2020 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2021 | if not (serializer.is_valid()): |
| 2022 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2023 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2024 | obj.caller = request.user |
| 2025 | if obj.can_update(request.user): |
| 2026 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2027 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2028 | raise Exception("failed obj.can_update") |
| 2029 | |
| 2030 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2031 | if (ret.status_code%100 != 200): |
| 2032 | raise Exception(ret.data) |
| 2033 | |
| 2034 | return ret |
| 2035 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2036 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2037 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2038 | queryset = SliceRole.objects.select_related().all() |
| 2039 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2040 | id_serializer_class = SliceRoleIdSerializer |
| 2041 | |
| 2042 | def get_serializer_class(self): |
| 2043 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2044 | if (no_hyperlinks): |
| 2045 | return self.id_serializer_class |
| 2046 | else: |
| 2047 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2048 | |
| 2049 | def get_queryset(self): |
| 2050 | return SliceRole.select_by_user(self.request.user) |
| 2051 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2052 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2053 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2054 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2055 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2056 | """ |
| 2057 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2058 | filled with defaults. I solved it another way, so this code may soon be |
| 2059 | abandoned. |
| 2060 | |
| 2061 | class SliceRoleNew(GenericAPIView): |
| 2062 | serializer_class = SliceRoleSerializer |
| 2063 | id_serializer_class = SliceRoleIdSerializer |
| 2064 | |
| 2065 | def get(self, request, *args, **kwargs): |
| 2066 | return self.makenew(request, *args, **kwargs) |
| 2067 | |
| 2068 | def get_serializer_class(self): |
| 2069 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2070 | if (no_hyperlinks): |
| 2071 | return self.id_serializer_class |
| 2072 | else: |
| 2073 | return self.serializer_class |
| 2074 | |
| 2075 | def makenew(self, request, *args, **kwargs): |
| 2076 | obj = SliceRole() |
| 2077 | serializer = self.get_serializer(obj) |
| 2078 | return Response(serializer.data) |
| 2079 | """ |
| 2080 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2081 | |
| 2082 | |
| 2083 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2084 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2085 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2086 | id_serializer_class = TagIdSerializer |
| 2087 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2088 | 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] | 2089 | |
| 2090 | def get_serializer_class(self): |
| 2091 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2092 | if (no_hyperlinks): |
| 2093 | return self.id_serializer_class |
| 2094 | else: |
| 2095 | return self.serializer_class |
| 2096 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2097 | def get_queryset(self): |
| 2098 | return Tag.select_by_user(self.request.user) |
| 2099 | |
| 2100 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2101 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2102 | if not (serializer.is_valid()): |
| 2103 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2104 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2105 | obj.caller = request.user |
| 2106 | if obj.can_update(request.user): |
| 2107 | return super(TagList, self).create(request, *args, **kwargs) |
| 2108 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2109 | raise Exception("failed obj.can_update") |
| 2110 | |
| 2111 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 2112 | if (ret.status_code%100 != 200): |
| 2113 | raise Exception(ret.data) |
| 2114 | |
| 2115 | return ret |
| 2116 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2117 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2118 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2119 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2120 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2121 | id_serializer_class = TagIdSerializer |
| 2122 | |
| 2123 | def get_serializer_class(self): |
| 2124 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2125 | if (no_hyperlinks): |
| 2126 | return self.id_serializer_class |
| 2127 | else: |
| 2128 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2129 | |
| 2130 | def get_queryset(self): |
| 2131 | return Tag.select_by_user(self.request.user) |
| 2132 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2133 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2134 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2135 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2136 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2137 | """ |
| 2138 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2139 | filled with defaults. I solved it another way, so this code may soon be |
| 2140 | abandoned. |
| 2141 | |
| 2142 | class TagNew(GenericAPIView): |
| 2143 | serializer_class = TagSerializer |
| 2144 | id_serializer_class = TagIdSerializer |
| 2145 | |
| 2146 | def get(self, request, *args, **kwargs): |
| 2147 | return self.makenew(request, *args, **kwargs) |
| 2148 | |
| 2149 | def get_serializer_class(self): |
| 2150 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2151 | if (no_hyperlinks): |
| 2152 | return self.id_serializer_class |
| 2153 | else: |
| 2154 | return self.serializer_class |
| 2155 | |
| 2156 | def makenew(self, request, *args, **kwargs): |
| 2157 | obj = Tag() |
| 2158 | serializer = self.get_serializer(obj) |
| 2159 | return Response(serializer.data) |
| 2160 | """ |
| 2161 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2162 | |
| 2163 | |
| 2164 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2165 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2166 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2167 | id_serializer_class = InvoiceIdSerializer |
| 2168 | filter_backends = (filters.DjangoFilterBackend,) |
| 2169 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 2170 | |
| 2171 | def get_serializer_class(self): |
| 2172 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2173 | if (no_hyperlinks): |
| 2174 | return self.id_serializer_class |
| 2175 | else: |
| 2176 | return self.serializer_class |
| 2177 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2178 | def get_queryset(self): |
| 2179 | return Invoice.select_by_user(self.request.user) |
| 2180 | |
| 2181 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2182 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2183 | if not (serializer.is_valid()): |
| 2184 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2185 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2186 | obj.caller = request.user |
| 2187 | if obj.can_update(request.user): |
| 2188 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 2189 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2190 | raise Exception("failed obj.can_update") |
| 2191 | |
| 2192 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 2193 | if (ret.status_code%100 != 200): |
| 2194 | raise Exception(ret.data) |
| 2195 | |
| 2196 | return ret |
| 2197 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2198 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2199 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2200 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2201 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2202 | id_serializer_class = InvoiceIdSerializer |
| 2203 | |
| 2204 | def get_serializer_class(self): |
| 2205 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2206 | if (no_hyperlinks): |
| 2207 | return self.id_serializer_class |
| 2208 | else: |
| 2209 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2210 | |
| 2211 | def get_queryset(self): |
| 2212 | return Invoice.select_by_user(self.request.user) |
| 2213 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2214 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2215 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2216 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2217 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2218 | """ |
| 2219 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2220 | filled with defaults. I solved it another way, so this code may soon be |
| 2221 | abandoned. |
| 2222 | |
| 2223 | class InvoiceNew(GenericAPIView): |
| 2224 | serializer_class = InvoiceSerializer |
| 2225 | id_serializer_class = InvoiceIdSerializer |
| 2226 | |
| 2227 | def get(self, request, *args, **kwargs): |
| 2228 | return self.makenew(request, *args, **kwargs) |
| 2229 | |
| 2230 | def get_serializer_class(self): |
| 2231 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2232 | if (no_hyperlinks): |
| 2233 | return self.id_serializer_class |
| 2234 | else: |
| 2235 | return self.serializer_class |
| 2236 | |
| 2237 | def makenew(self, request, *args, **kwargs): |
| 2238 | obj = Invoice() |
| 2239 | serializer = self.get_serializer(obj) |
| 2240 | return Response(serializer.data) |
| 2241 | """ |
| 2242 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2243 | |
| 2244 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2245 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 2246 | queryset = SlicePrivilege.objects.select_related().all() |
| 2247 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2248 | id_serializer_class = SlicePrivilegeIdSerializer |
| 2249 | filter_backends = (filters.DjangoFilterBackend,) |
| 2250 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 2251 | |
| 2252 | def get_serializer_class(self): |
| 2253 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2254 | if (no_hyperlinks): |
| 2255 | return self.id_serializer_class |
| 2256 | else: |
| 2257 | return self.serializer_class |
| 2258 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2259 | def get_queryset(self): |
| 2260 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2261 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2262 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2263 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2264 | if not (serializer.is_valid()): |
| 2265 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2266 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2267 | obj.caller = request.user |
| 2268 | if obj.can_update(request.user): |
| 2269 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 2270 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2271 | raise Exception("failed obj.can_update") |
| 2272 | |
| 2273 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 2274 | if (ret.status_code%100 != 200): |
| 2275 | raise Exception(ret.data) |
| 2276 | |
| 2277 | return ret |
| 2278 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2279 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2280 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2281 | queryset = SlicePrivilege.objects.select_related().all() |
| 2282 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2283 | id_serializer_class = SlicePrivilegeIdSerializer |
| 2284 | |
| 2285 | def get_serializer_class(self): |
| 2286 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2287 | if (no_hyperlinks): |
| 2288 | return self.id_serializer_class |
| 2289 | else: |
| 2290 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2291 | |
| 2292 | def get_queryset(self): |
| 2293 | return SlicePrivilege.select_by_user(self.request.user) |
| 2294 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2295 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2296 | |
| 2297 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2298 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2299 | """ |
| 2300 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2301 | filled with defaults. I solved it another way, so this code may soon be |
| 2302 | abandoned. |
| 2303 | |
| 2304 | class SlicePrivilegeNew(GenericAPIView): |
| 2305 | serializer_class = SlicePrivilegeSerializer |
| 2306 | id_serializer_class = SlicePrivilegeIdSerializer |
| 2307 | |
| 2308 | def get(self, request, *args, **kwargs): |
| 2309 | return self.makenew(request, *args, **kwargs) |
| 2310 | |
| 2311 | def get_serializer_class(self): |
| 2312 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2313 | if (no_hyperlinks): |
| 2314 | return self.id_serializer_class |
| 2315 | else: |
| 2316 | return self.serializer_class |
| 2317 | |
| 2318 | def makenew(self, request, *args, **kwargs): |
| 2319 | obj = SlicePrivilege() |
| 2320 | serializer = self.get_serializer(obj) |
| 2321 | return Response(serializer.data) |
| 2322 | """ |
| 2323 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2324 | |
| 2325 | |
| 2326 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 2327 | queryset = PlanetStackRole.objects.select_related().all() |
| 2328 | serializer_class = PlanetStackRoleSerializer |
| 2329 | id_serializer_class = PlanetStackRoleIdSerializer |
| 2330 | filter_backends = (filters.DjangoFilterBackend,) |
| 2331 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2332 | |
| 2333 | def get_serializer_class(self): |
| 2334 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2335 | if (no_hyperlinks): |
| 2336 | return self.id_serializer_class |
| 2337 | else: |
| 2338 | return self.serializer_class |
| 2339 | |
| 2340 | def get_queryset(self): |
| 2341 | return PlanetStackRole.select_by_user(self.request.user) |
| 2342 | |
| 2343 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2344 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2345 | if not (serializer.is_valid()): |
| 2346 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2347 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2348 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2349 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2350 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2351 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2352 | raise Exception("failed obj.can_update") |
| 2353 | |
| 2354 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 2355 | if (ret.status_code%100 != 200): |
| 2356 | raise Exception(ret.data) |
| 2357 | |
| 2358 | return ret |
| 2359 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2360 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2361 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2362 | queryset = PlanetStackRole.objects.select_related().all() |
| 2363 | serializer_class = PlanetStackRoleSerializer |
| 2364 | id_serializer_class = PlanetStackRoleIdSerializer |
| 2365 | |
| 2366 | def get_serializer_class(self): |
| 2367 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2368 | if (no_hyperlinks): |
| 2369 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2370 | else: |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2371 | return self.serializer_class |
| 2372 | |
| 2373 | def get_queryset(self): |
| 2374 | return PlanetStackRole.select_by_user(self.request.user) |
| 2375 | |
| 2376 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2377 | |
| 2378 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2379 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2380 | """ |
| 2381 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2382 | filled with defaults. I solved it another way, so this code may soon be |
| 2383 | abandoned. |
| 2384 | |
| 2385 | class PlanetStackRoleNew(GenericAPIView): |
| 2386 | serializer_class = PlanetStackRoleSerializer |
| 2387 | id_serializer_class = PlanetStackRoleIdSerializer |
| 2388 | |
| 2389 | def get(self, request, *args, **kwargs): |
| 2390 | return self.makenew(request, *args, **kwargs) |
| 2391 | |
| 2392 | def get_serializer_class(self): |
| 2393 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2394 | if (no_hyperlinks): |
| 2395 | return self.id_serializer_class |
| 2396 | else: |
| 2397 | return self.serializer_class |
| 2398 | |
| 2399 | def makenew(self, request, *args, **kwargs): |
| 2400 | obj = PlanetStackRole() |
| 2401 | serializer = self.get_serializer(obj) |
| 2402 | return Response(serializer.data) |
| 2403 | """ |
| 2404 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2405 | |
| 2406 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2407 | class NetworkSliverList(generics.ListCreateAPIView): |
| 2408 | queryset = NetworkSliver.objects.select_related().all() |
| 2409 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2410 | id_serializer_class = NetworkSliverIdSerializer |
| 2411 | filter_backends = (filters.DjangoFilterBackend,) |
| 2412 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 2413 | |
| 2414 | def get_serializer_class(self): |
| 2415 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2416 | if (no_hyperlinks): |
| 2417 | return self.id_serializer_class |
| 2418 | else: |
| 2419 | return self.serializer_class |
| 2420 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2421 | def get_queryset(self): |
| 2422 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2423 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2424 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2425 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2426 | if not (serializer.is_valid()): |
| 2427 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2428 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2429 | obj.caller = request.user |
| 2430 | if obj.can_update(request.user): |
| 2431 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 2432 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2433 | raise Exception("failed obj.can_update") |
| 2434 | |
| 2435 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 2436 | if (ret.status_code%100 != 200): |
| 2437 | raise Exception(ret.data) |
| 2438 | |
| 2439 | return ret |
| 2440 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2441 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2442 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2443 | queryset = NetworkSliver.objects.select_related().all() |
| 2444 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2445 | id_serializer_class = NetworkSliverIdSerializer |
| 2446 | |
| 2447 | def get_serializer_class(self): |
| 2448 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2449 | if (no_hyperlinks): |
| 2450 | return self.id_serializer_class |
| 2451 | else: |
| 2452 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2453 | |
| 2454 | def get_queryset(self): |
| 2455 | return NetworkSliver.select_by_user(self.request.user) |
| 2456 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2457 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2458 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2459 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2460 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2461 | """ |
| 2462 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2463 | filled with defaults. I solved it another way, so this code may soon be |
| 2464 | abandoned. |
| 2465 | |
| 2466 | class NetworkSliverNew(GenericAPIView): |
| 2467 | serializer_class = NetworkSliverSerializer |
| 2468 | id_serializer_class = NetworkSliverIdSerializer |
| 2469 | |
| 2470 | def get(self, request, *args, **kwargs): |
| 2471 | return self.makenew(request, *args, **kwargs) |
| 2472 | |
| 2473 | def get_serializer_class(self): |
| 2474 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2475 | if (no_hyperlinks): |
| 2476 | return self.id_serializer_class |
| 2477 | else: |
| 2478 | return self.serializer_class |
| 2479 | |
| 2480 | def makenew(self, request, *args, **kwargs): |
| 2481 | obj = NetworkSliver() |
| 2482 | serializer = self.get_serializer(obj) |
| 2483 | return Response(serializer.data) |
| 2484 | """ |
| 2485 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2486 | |
| 2487 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2488 | class NetworkDeploymentsList(generics.ListCreateAPIView): |
| 2489 | queryset = NetworkDeployments.objects.select_related().all() |
| 2490 | serializer_class = NetworkDeploymentsSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2491 | id_serializer_class = NetworkDeploymentsIdSerializer |
| 2492 | filter_backends = (filters.DjangoFilterBackend,) |
| 2493 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',) |
| 2494 | |
| 2495 | def get_serializer_class(self): |
| 2496 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2497 | if (no_hyperlinks): |
| 2498 | return self.id_serializer_class |
| 2499 | else: |
| 2500 | return self.serializer_class |
| 2501 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2502 | def get_queryset(self): |
| 2503 | return NetworkDeployments.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2504 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2505 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2506 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2507 | if not (serializer.is_valid()): |
| 2508 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2509 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2510 | obj.caller = request.user |
| 2511 | if obj.can_update(request.user): |
| 2512 | return super(NetworkDeploymentsList, self).create(request, *args, **kwargs) |
| 2513 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2514 | raise Exception("failed obj.can_update") |
| 2515 | |
| 2516 | ret = super(NetworkDeploymentsList, self).create(request, *args, **kwargs) |
| 2517 | if (ret.status_code%100 != 200): |
| 2518 | raise Exception(ret.data) |
| 2519 | |
| 2520 | return ret |
| 2521 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2522 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2523 | class NetworkDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2524 | queryset = NetworkDeployments.objects.select_related().all() |
| 2525 | serializer_class = NetworkDeploymentsSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2526 | id_serializer_class = NetworkDeploymentsIdSerializer |
| 2527 | |
| 2528 | def get_serializer_class(self): |
| 2529 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2530 | if (no_hyperlinks): |
| 2531 | return self.id_serializer_class |
| 2532 | else: |
| 2533 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2534 | |
| 2535 | def get_queryset(self): |
| 2536 | return NetworkDeployments.select_by_user(self.request.user) |
| 2537 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2538 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2539 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2540 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2541 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2542 | """ |
| 2543 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2544 | filled with defaults. I solved it another way, so this code may soon be |
| 2545 | abandoned. |
| 2546 | |
| 2547 | class NetworkDeploymentsNew(GenericAPIView): |
| 2548 | serializer_class = NetworkDeploymentsSerializer |
| 2549 | id_serializer_class = NetworkDeploymentsIdSerializer |
| 2550 | |
| 2551 | def get(self, request, *args, **kwargs): |
| 2552 | return self.makenew(request, *args, **kwargs) |
| 2553 | |
| 2554 | def get_serializer_class(self): |
| 2555 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2556 | if (no_hyperlinks): |
| 2557 | return self.id_serializer_class |
| 2558 | else: |
| 2559 | return self.serializer_class |
| 2560 | |
| 2561 | def makenew(self, request, *args, **kwargs): |
| 2562 | obj = NetworkDeployments() |
| 2563 | serializer = self.get_serializer(obj) |
| 2564 | return Response(serializer.data) |
| 2565 | """ |
| 2566 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2567 | |
| 2568 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2569 | class FlavorList(generics.ListCreateAPIView): |
| 2570 | queryset = Flavor.objects.select_related().all() |
| 2571 | serializer_class = FlavorSerializer |
| 2572 | id_serializer_class = FlavorIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2573 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2574 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2575 | |
| 2576 | def get_serializer_class(self): |
| 2577 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2578 | if (no_hyperlinks): |
| 2579 | return self.id_serializer_class |
| 2580 | else: |
| 2581 | return self.serializer_class |
| 2582 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2583 | def get_queryset(self): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2584 | return Flavor.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2585 | |
| 2586 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2587 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2588 | if not (serializer.is_valid()): |
| 2589 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2590 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2591 | obj.caller = request.user |
| 2592 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2593 | return super(FlavorList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2594 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2595 | raise Exception("failed obj.can_update") |
| 2596 | |
| 2597 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 2598 | if (ret.status_code%100 != 200): |
| 2599 | raise Exception(ret.data) |
| 2600 | |
| 2601 | return ret |
| 2602 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2603 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2604 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2605 | queryset = Flavor.objects.select_related().all() |
| 2606 | serializer_class = FlavorSerializer |
| 2607 | id_serializer_class = FlavorIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2608 | |
| 2609 | def get_serializer_class(self): |
| 2610 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2611 | if (no_hyperlinks): |
| 2612 | return self.id_serializer_class |
| 2613 | else: |
| 2614 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2615 | |
| 2616 | def get_queryset(self): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2617 | return Flavor.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2618 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2619 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2620 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2621 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2622 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2623 | """ |
| 2624 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2625 | filled with defaults. I solved it another way, so this code may soon be |
| 2626 | abandoned. |
| 2627 | |
| 2628 | class FlavorNew(GenericAPIView): |
| 2629 | serializer_class = FlavorSerializer |
| 2630 | id_serializer_class = FlavorIdSerializer |
| 2631 | |
| 2632 | def get(self, request, *args, **kwargs): |
| 2633 | return self.makenew(request, *args, **kwargs) |
| 2634 | |
| 2635 | def get_serializer_class(self): |
| 2636 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2637 | if (no_hyperlinks): |
| 2638 | return self.id_serializer_class |
| 2639 | else: |
| 2640 | return self.serializer_class |
| 2641 | |
| 2642 | def makenew(self, request, *args, **kwargs): |
| 2643 | obj = Flavor() |
| 2644 | serializer = self.get_serializer(obj) |
| 2645 | return Response(serializer.data) |
| 2646 | """ |
| 2647 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2648 | |
| 2649 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2650 | class ProjectList(generics.ListCreateAPIView): |
| 2651 | queryset = Project.objects.select_related().all() |
| 2652 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2653 | id_serializer_class = ProjectIdSerializer |
| 2654 | filter_backends = (filters.DjangoFilterBackend,) |
| 2655 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 2656 | |
| 2657 | def get_serializer_class(self): |
| 2658 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2659 | if (no_hyperlinks): |
| 2660 | return self.id_serializer_class |
| 2661 | else: |
| 2662 | return self.serializer_class |
| 2663 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2664 | def get_queryset(self): |
| 2665 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2666 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2667 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2668 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2669 | if not (serializer.is_valid()): |
| 2670 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2671 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2672 | obj.caller = request.user |
| 2673 | if obj.can_update(request.user): |
| 2674 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 2675 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2676 | raise Exception("failed obj.can_update") |
| 2677 | |
| 2678 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 2679 | if (ret.status_code%100 != 200): |
| 2680 | raise Exception(ret.data) |
| 2681 | |
| 2682 | return ret |
| 2683 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2684 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2685 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2686 | queryset = Project.objects.select_related().all() |
| 2687 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2688 | id_serializer_class = ProjectIdSerializer |
| 2689 | |
| 2690 | def get_serializer_class(self): |
| 2691 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2692 | if (no_hyperlinks): |
| 2693 | return self.id_serializer_class |
| 2694 | else: |
| 2695 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2696 | |
| 2697 | def get_queryset(self): |
| 2698 | return Project.select_by_user(self.request.user) |
| 2699 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2700 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2701 | |
| 2702 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2703 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2704 | """ |
| 2705 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2706 | filled with defaults. I solved it another way, so this code may soon be |
| 2707 | abandoned. |
| 2708 | |
| 2709 | class ProjectNew(GenericAPIView): |
| 2710 | serializer_class = ProjectSerializer |
| 2711 | id_serializer_class = ProjectIdSerializer |
| 2712 | |
| 2713 | def get(self, request, *args, **kwargs): |
| 2714 | return self.makenew(request, *args, **kwargs) |
| 2715 | |
| 2716 | def get_serializer_class(self): |
| 2717 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2718 | if (no_hyperlinks): |
| 2719 | return self.id_serializer_class |
| 2720 | else: |
| 2721 | return self.serializer_class |
| 2722 | |
| 2723 | def makenew(self, request, *args, **kwargs): |
| 2724 | obj = Project() |
| 2725 | serializer = self.get_serializer(obj) |
| 2726 | return Response(serializer.data) |
| 2727 | """ |
| 2728 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2729 | |
| 2730 | |
| 2731 | class SliceList(generics.ListCreateAPIView): |
| 2732 | queryset = Slice.objects.select_related().all() |
| 2733 | serializer_class = SliceSerializer |
| 2734 | id_serializer_class = SliceIdSerializer |
| 2735 | filter_backends = (filters.DjangoFilterBackend,) |
| 2736 | 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','availableNetworks','networks','networks',) |
| 2737 | |
| 2738 | def get_serializer_class(self): |
| 2739 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2740 | if (no_hyperlinks): |
| 2741 | return self.id_serializer_class |
| 2742 | else: |
| 2743 | return self.serializer_class |
| 2744 | |
| 2745 | def get_queryset(self): |
| 2746 | return Slice.select_by_user(self.request.user) |
| 2747 | |
| 2748 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2749 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2750 | if not (serializer.is_valid()): |
| 2751 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2752 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2753 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2754 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2755 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2756 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2757 | raise Exception("failed obj.can_update") |
| 2758 | |
| 2759 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 2760 | if (ret.status_code%100 != 200): |
| 2761 | raise Exception(ret.data) |
| 2762 | |
| 2763 | return ret |
| 2764 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2765 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2766 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2767 | queryset = Slice.objects.select_related().all() |
| 2768 | serializer_class = SliceSerializer |
| 2769 | id_serializer_class = SliceIdSerializer |
| 2770 | |
| 2771 | def get_serializer_class(self): |
| 2772 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2773 | if (no_hyperlinks): |
| 2774 | return self.id_serializer_class |
| 2775 | else: |
| 2776 | return self.serializer_class |
| 2777 | |
| 2778 | def get_queryset(self): |
| 2779 | return Slice.select_by_user(self.request.user) |
| 2780 | |
| 2781 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2782 | |
| 2783 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2784 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2785 | """ |
| 2786 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2787 | filled with defaults. I solved it another way, so this code may soon be |
| 2788 | abandoned. |
| 2789 | |
| 2790 | class SliceNew(GenericAPIView): |
| 2791 | serializer_class = SliceSerializer |
| 2792 | id_serializer_class = SliceIdSerializer |
| 2793 | |
| 2794 | def get(self, request, *args, **kwargs): |
| 2795 | return self.makenew(request, *args, **kwargs) |
| 2796 | |
| 2797 | def get_serializer_class(self): |
| 2798 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2799 | if (no_hyperlinks): |
| 2800 | return self.id_serializer_class |
| 2801 | else: |
| 2802 | return self.serializer_class |
| 2803 | |
| 2804 | def makenew(self, request, *args, **kwargs): |
| 2805 | obj = Slice() |
| 2806 | serializer = self.get_serializer(obj) |
| 2807 | return Response(serializer.data) |
| 2808 | """ |
| 2809 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2810 | |
| 2811 | |
| 2812 | class NetworkList(generics.ListCreateAPIView): |
| 2813 | queryset = Network.objects.select_related().all() |
| 2814 | serializer_class = NetworkSerializer |
| 2815 | id_serializer_class = NetworkIdSerializer |
| 2816 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2817 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2818 | |
| 2819 | def get_serializer_class(self): |
| 2820 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2821 | if (no_hyperlinks): |
| 2822 | return self.id_serializer_class |
| 2823 | else: |
| 2824 | return self.serializer_class |
| 2825 | |
| 2826 | def get_queryset(self): |
| 2827 | return Network.select_by_user(self.request.user) |
| 2828 | |
| 2829 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2830 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2831 | if not (serializer.is_valid()): |
| 2832 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2833 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2834 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2835 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2836 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2837 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2838 | raise Exception("failed obj.can_update") |
| 2839 | |
| 2840 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 2841 | if (ret.status_code%100 != 200): |
| 2842 | raise Exception(ret.data) |
| 2843 | |
| 2844 | return ret |
| 2845 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2846 | |
| 2847 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2848 | queryset = Network.objects.select_related().all() |
| 2849 | serializer_class = NetworkSerializer |
| 2850 | id_serializer_class = NetworkIdSerializer |
| 2851 | |
| 2852 | def get_serializer_class(self): |
| 2853 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2854 | if (no_hyperlinks): |
| 2855 | return self.id_serializer_class |
| 2856 | else: |
| 2857 | return self.serializer_class |
| 2858 | |
| 2859 | def get_queryset(self): |
| 2860 | return Network.select_by_user(self.request.user) |
| 2861 | |
| 2862 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2863 | |
| 2864 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2865 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2866 | """ |
| 2867 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2868 | filled with defaults. I solved it another way, so this code may soon be |
| 2869 | abandoned. |
| 2870 | |
| 2871 | class NetworkNew(GenericAPIView): |
| 2872 | serializer_class = NetworkSerializer |
| 2873 | id_serializer_class = NetworkIdSerializer |
| 2874 | |
| 2875 | def get(self, request, *args, **kwargs): |
| 2876 | return self.makenew(request, *args, **kwargs) |
| 2877 | |
| 2878 | def get_serializer_class(self): |
| 2879 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2880 | if (no_hyperlinks): |
| 2881 | return self.id_serializer_class |
| 2882 | else: |
| 2883 | return self.serializer_class |
| 2884 | |
| 2885 | def makenew(self, request, *args, **kwargs): |
| 2886 | obj = Network() |
| 2887 | serializer = self.get_serializer(obj) |
| 2888 | return Response(serializer.data) |
| 2889 | """ |
| 2890 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2891 | |
| 2892 | |
| 2893 | class ServiceList(generics.ListCreateAPIView): |
| 2894 | queryset = Service.objects.select_related().all() |
| 2895 | serializer_class = ServiceSerializer |
| 2896 | id_serializer_class = ServiceIdSerializer |
| 2897 | filter_backends = (filters.DjangoFilterBackend,) |
| 2898 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 2899 | |
| 2900 | def get_serializer_class(self): |
| 2901 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2902 | if (no_hyperlinks): |
| 2903 | return self.id_serializer_class |
| 2904 | else: |
| 2905 | return self.serializer_class |
| 2906 | |
| 2907 | def get_queryset(self): |
| 2908 | return Service.select_by_user(self.request.user) |
| 2909 | |
| 2910 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2911 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2912 | if not (serializer.is_valid()): |
| 2913 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2914 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2915 | obj.caller = request.user |
| 2916 | if obj.can_update(request.user): |
| 2917 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 2918 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2919 | raise Exception("failed obj.can_update") |
| 2920 | |
| 2921 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 2922 | if (ret.status_code%100 != 200): |
| 2923 | raise Exception(ret.data) |
| 2924 | |
| 2925 | return ret |
| 2926 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2927 | |
| 2928 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2929 | queryset = Service.objects.select_related().all() |
| 2930 | serializer_class = ServiceSerializer |
| 2931 | id_serializer_class = ServiceIdSerializer |
| 2932 | |
| 2933 | def get_serializer_class(self): |
| 2934 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2935 | if (no_hyperlinks): |
| 2936 | return self.id_serializer_class |
| 2937 | else: |
| 2938 | return self.serializer_class |
| 2939 | |
| 2940 | def get_queryset(self): |
| 2941 | return Service.select_by_user(self.request.user) |
| 2942 | |
| 2943 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2944 | |
| 2945 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2946 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2947 | """ |
| 2948 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 2949 | filled with defaults. I solved it another way, so this code may soon be |
| 2950 | abandoned. |
| 2951 | |
| 2952 | class ServiceNew(GenericAPIView): |
| 2953 | serializer_class = ServiceSerializer |
| 2954 | id_serializer_class = ServiceIdSerializer |
| 2955 | |
| 2956 | def get(self, request, *args, **kwargs): |
| 2957 | return self.makenew(request, *args, **kwargs) |
| 2958 | |
| 2959 | def get_serializer_class(self): |
| 2960 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2961 | if (no_hyperlinks): |
| 2962 | return self.id_serializer_class |
| 2963 | else: |
| 2964 | return self.serializer_class |
| 2965 | |
| 2966 | def makenew(self, request, *args, **kwargs): |
| 2967 | obj = Service() |
| 2968 | serializer = self.get_serializer(obj) |
| 2969 | return Response(serializer.data) |
| 2970 | """ |
| 2971 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2972 | |
| 2973 | |
| 2974 | class ServiceClassList(generics.ListCreateAPIView): |
| 2975 | queryset = ServiceClass.objects.select_related().all() |
| 2976 | serializer_class = ServiceClassSerializer |
| 2977 | id_serializer_class = ServiceClassIdSerializer |
| 2978 | filter_backends = (filters.DjangoFilterBackend,) |
| 2979 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 2980 | |
| 2981 | def get_serializer_class(self): |
| 2982 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2983 | if (no_hyperlinks): |
| 2984 | return self.id_serializer_class |
| 2985 | else: |
| 2986 | return self.serializer_class |
| 2987 | |
| 2988 | def get_queryset(self): |
| 2989 | return ServiceClass.select_by_user(self.request.user) |
| 2990 | |
| 2991 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2992 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2993 | if not (serializer.is_valid()): |
| 2994 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 2995 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2996 | obj.caller = request.user |
| 2997 | if obj.can_update(request.user): |
| 2998 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 2999 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3000 | raise Exception("failed obj.can_update") |
| 3001 | |
| 3002 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3003 | if (ret.status_code%100 != 200): |
| 3004 | raise Exception(ret.data) |
| 3005 | |
| 3006 | return ret |
| 3007 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3008 | |
| 3009 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3010 | queryset = ServiceClass.objects.select_related().all() |
| 3011 | serializer_class = ServiceClassSerializer |
| 3012 | id_serializer_class = ServiceClassIdSerializer |
| 3013 | |
| 3014 | def get_serializer_class(self): |
| 3015 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3016 | if (no_hyperlinks): |
| 3017 | return self.id_serializer_class |
| 3018 | else: |
| 3019 | return self.serializer_class |
| 3020 | |
| 3021 | def get_queryset(self): |
| 3022 | return ServiceClass.select_by_user(self.request.user) |
| 3023 | |
| 3024 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3025 | |
| 3026 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3027 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3028 | """ |
| 3029 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3030 | filled with defaults. I solved it another way, so this code may soon be |
| 3031 | abandoned. |
| 3032 | |
| 3033 | class ServiceClassNew(GenericAPIView): |
| 3034 | serializer_class = ServiceClassSerializer |
| 3035 | id_serializer_class = ServiceClassIdSerializer |
| 3036 | |
| 3037 | def get(self, request, *args, **kwargs): |
| 3038 | return self.makenew(request, *args, **kwargs) |
| 3039 | |
| 3040 | def get_serializer_class(self): |
| 3041 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3042 | if (no_hyperlinks): |
| 3043 | return self.id_serializer_class |
| 3044 | else: |
| 3045 | return self.serializer_class |
| 3046 | |
| 3047 | def makenew(self, request, *args, **kwargs): |
| 3048 | obj = ServiceClass() |
| 3049 | serializer = self.get_serializer(obj) |
| 3050 | return Response(serializer.data) |
| 3051 | """ |
| 3052 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3053 | |
| 3054 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3055 | class PaymentList(generics.ListCreateAPIView): |
| 3056 | queryset = Payment.objects.select_related().all() |
| 3057 | serializer_class = PaymentSerializer |
| 3058 | id_serializer_class = PaymentIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3059 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3060 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3061 | |
| 3062 | def get_serializer_class(self): |
| 3063 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3064 | if (no_hyperlinks): |
| 3065 | return self.id_serializer_class |
| 3066 | else: |
| 3067 | return self.serializer_class |
| 3068 | |
| 3069 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3070 | return Payment.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3071 | |
| 3072 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3073 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3074 | if not (serializer.is_valid()): |
| 3075 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3076 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3077 | obj.caller = request.user |
| 3078 | if obj.can_update(request.user): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3079 | return super(PaymentList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3080 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3081 | raise Exception("failed obj.can_update") |
| 3082 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3083 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3084 | if (ret.status_code%100 != 200): |
| 3085 | raise Exception(ret.data) |
| 3086 | |
| 3087 | return ret |
| 3088 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3089 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3090 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3091 | queryset = Payment.objects.select_related().all() |
| 3092 | serializer_class = PaymentSerializer |
| 3093 | id_serializer_class = PaymentIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3094 | |
| 3095 | def get_serializer_class(self): |
| 3096 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3097 | if (no_hyperlinks): |
| 3098 | return self.id_serializer_class |
| 3099 | else: |
| 3100 | return self.serializer_class |
| 3101 | |
| 3102 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3103 | return Payment.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3104 | |
| 3105 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3106 | |
| 3107 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3108 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3109 | """ |
| 3110 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3111 | filled with defaults. I solved it another way, so this code may soon be |
| 3112 | abandoned. |
| 3113 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3114 | class PaymentNew(GenericAPIView): |
| 3115 | serializer_class = PaymentSerializer |
| 3116 | id_serializer_class = PaymentIdSerializer |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3117 | |
| 3118 | def get(self, request, *args, **kwargs): |
| 3119 | return self.makenew(request, *args, **kwargs) |
| 3120 | |
| 3121 | def get_serializer_class(self): |
| 3122 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3123 | if (no_hyperlinks): |
| 3124 | return self.id_serializer_class |
| 3125 | else: |
| 3126 | return self.serializer_class |
| 3127 | |
| 3128 | def makenew(self, request, *args, **kwargs): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3129 | obj = Payment() |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3130 | serializer = self.get_serializer(obj) |
| 3131 | return Response(serializer.data) |
| 3132 | """ |
| 3133 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3134 | |
| 3135 | |
| 3136 | class ChargeList(generics.ListCreateAPIView): |
| 3137 | queryset = Charge.objects.select_related().all() |
| 3138 | serializer_class = ChargeSerializer |
| 3139 | id_serializer_class = ChargeIdSerializer |
| 3140 | filter_backends = (filters.DjangoFilterBackend,) |
| 3141 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 3142 | |
| 3143 | def get_serializer_class(self): |
| 3144 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3145 | if (no_hyperlinks): |
| 3146 | return self.id_serializer_class |
| 3147 | else: |
| 3148 | return self.serializer_class |
| 3149 | |
| 3150 | def get_queryset(self): |
| 3151 | return Charge.select_by_user(self.request.user) |
| 3152 | |
| 3153 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3154 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3155 | if not (serializer.is_valid()): |
| 3156 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3157 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3158 | obj.caller = request.user |
| 3159 | if obj.can_update(request.user): |
| 3160 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3161 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3162 | raise Exception("failed obj.can_update") |
| 3163 | |
| 3164 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3165 | if (ret.status_code%100 != 200): |
| 3166 | raise Exception(ret.data) |
| 3167 | |
| 3168 | return ret |
| 3169 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3170 | |
| 3171 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3172 | queryset = Charge.objects.select_related().all() |
| 3173 | serializer_class = ChargeSerializer |
| 3174 | id_serializer_class = ChargeIdSerializer |
| 3175 | |
| 3176 | def get_serializer_class(self): |
| 3177 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3178 | if (no_hyperlinks): |
| 3179 | return self.id_serializer_class |
| 3180 | else: |
| 3181 | return self.serializer_class |
| 3182 | |
| 3183 | def get_queryset(self): |
| 3184 | return Charge.select_by_user(self.request.user) |
| 3185 | |
| 3186 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3187 | |
| 3188 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3189 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3190 | """ |
| 3191 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3192 | filled with defaults. I solved it another way, so this code may soon be |
| 3193 | abandoned. |
| 3194 | |
| 3195 | class ChargeNew(GenericAPIView): |
| 3196 | serializer_class = ChargeSerializer |
| 3197 | id_serializer_class = ChargeIdSerializer |
| 3198 | |
| 3199 | def get(self, request, *args, **kwargs): |
| 3200 | return self.makenew(request, *args, **kwargs) |
| 3201 | |
| 3202 | def get_serializer_class(self): |
| 3203 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3204 | if (no_hyperlinks): |
| 3205 | return self.id_serializer_class |
| 3206 | else: |
| 3207 | return self.serializer_class |
| 3208 | |
| 3209 | def makenew(self, request, *args, **kwargs): |
| 3210 | obj = Charge() |
| 3211 | serializer = self.get_serializer(obj) |
| 3212 | return Response(serializer.data) |
| 3213 | """ |
| 3214 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3215 | |
| 3216 | |
| 3217 | class RoleList(generics.ListCreateAPIView): |
| 3218 | queryset = Role.objects.select_related().all() |
| 3219 | serializer_class = RoleSerializer |
| 3220 | id_serializer_class = RoleIdSerializer |
| 3221 | filter_backends = (filters.DjangoFilterBackend,) |
| 3222 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 3223 | |
| 3224 | def get_serializer_class(self): |
| 3225 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3226 | if (no_hyperlinks): |
| 3227 | return self.id_serializer_class |
| 3228 | else: |
| 3229 | return self.serializer_class |
| 3230 | |
| 3231 | def get_queryset(self): |
| 3232 | return Role.select_by_user(self.request.user) |
| 3233 | |
| 3234 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3235 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3236 | if not (serializer.is_valid()): |
| 3237 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3238 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3239 | obj.caller = request.user |
| 3240 | if obj.can_update(request.user): |
| 3241 | return super(RoleList, self).create(request, *args, **kwargs) |
| 3242 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3243 | raise Exception("failed obj.can_update") |
| 3244 | |
| 3245 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 3246 | if (ret.status_code%100 != 200): |
| 3247 | raise Exception(ret.data) |
| 3248 | |
| 3249 | return ret |
| 3250 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3251 | |
| 3252 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3253 | queryset = Role.objects.select_related().all() |
| 3254 | serializer_class = RoleSerializer |
| 3255 | id_serializer_class = RoleIdSerializer |
| 3256 | |
| 3257 | def get_serializer_class(self): |
| 3258 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3259 | if (no_hyperlinks): |
| 3260 | return self.id_serializer_class |
| 3261 | else: |
| 3262 | return self.serializer_class |
| 3263 | |
| 3264 | def get_queryset(self): |
| 3265 | return Role.select_by_user(self.request.user) |
| 3266 | |
| 3267 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3268 | |
| 3269 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3270 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3271 | """ |
| 3272 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3273 | filled with defaults. I solved it another way, so this code may soon be |
| 3274 | abandoned. |
| 3275 | |
| 3276 | class RoleNew(GenericAPIView): |
| 3277 | serializer_class = RoleSerializer |
| 3278 | id_serializer_class = RoleIdSerializer |
| 3279 | |
| 3280 | def get(self, request, *args, **kwargs): |
| 3281 | return self.makenew(request, *args, **kwargs) |
| 3282 | |
| 3283 | def get_serializer_class(self): |
| 3284 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3285 | if (no_hyperlinks): |
| 3286 | return self.id_serializer_class |
| 3287 | else: |
| 3288 | return self.serializer_class |
| 3289 | |
| 3290 | def makenew(self, request, *args, **kwargs): |
| 3291 | obj = Role() |
| 3292 | serializer = self.get_serializer(obj) |
| 3293 | return Response(serializer.data) |
| 3294 | """ |
| 3295 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3296 | |
| 3297 | |
| 3298 | class UsableObjectList(generics.ListCreateAPIView): |
| 3299 | queryset = UsableObject.objects.select_related().all() |
| 3300 | serializer_class = UsableObjectSerializer |
| 3301 | id_serializer_class = UsableObjectIdSerializer |
| 3302 | filter_backends = (filters.DjangoFilterBackend,) |
| 3303 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3304 | |
| 3305 | def get_serializer_class(self): |
| 3306 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3307 | if (no_hyperlinks): |
| 3308 | return self.id_serializer_class |
| 3309 | else: |
| 3310 | return self.serializer_class |
| 3311 | |
| 3312 | def get_queryset(self): |
| 3313 | return UsableObject.select_by_user(self.request.user) |
| 3314 | |
| 3315 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3316 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3317 | if not (serializer.is_valid()): |
| 3318 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3319 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3320 | obj.caller = request.user |
| 3321 | if obj.can_update(request.user): |
| 3322 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3323 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3324 | raise Exception("failed obj.can_update") |
| 3325 | |
| 3326 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3327 | if (ret.status_code%100 != 200): |
| 3328 | raise Exception(ret.data) |
| 3329 | |
| 3330 | return ret |
| 3331 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3332 | |
| 3333 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3334 | queryset = UsableObject.objects.select_related().all() |
| 3335 | serializer_class = UsableObjectSerializer |
| 3336 | id_serializer_class = UsableObjectIdSerializer |
| 3337 | |
| 3338 | def get_serializer_class(self): |
| 3339 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3340 | if (no_hyperlinks): |
| 3341 | return self.id_serializer_class |
| 3342 | else: |
| 3343 | return self.serializer_class |
| 3344 | |
| 3345 | def get_queryset(self): |
| 3346 | return UsableObject.select_by_user(self.request.user) |
| 3347 | |
| 3348 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3349 | |
| 3350 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3351 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3352 | """ |
| 3353 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3354 | filled with defaults. I solved it another way, so this code may soon be |
| 3355 | abandoned. |
| 3356 | |
| 3357 | class UsableObjectNew(GenericAPIView): |
| 3358 | serializer_class = UsableObjectSerializer |
| 3359 | id_serializer_class = UsableObjectIdSerializer |
| 3360 | |
| 3361 | def get(self, request, *args, **kwargs): |
| 3362 | return self.makenew(request, *args, **kwargs) |
| 3363 | |
| 3364 | def get_serializer_class(self): |
| 3365 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3366 | if (no_hyperlinks): |
| 3367 | return self.id_serializer_class |
| 3368 | else: |
| 3369 | return self.serializer_class |
| 3370 | |
| 3371 | def makenew(self, request, *args, **kwargs): |
| 3372 | obj = UsableObject() |
| 3373 | serializer = self.get_serializer(obj) |
| 3374 | return Response(serializer.data) |
| 3375 | """ |
| 3376 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3377 | |
| 3378 | |
| 3379 | class SiteRoleList(generics.ListCreateAPIView): |
| 3380 | queryset = SiteRole.objects.select_related().all() |
| 3381 | serializer_class = SiteRoleSerializer |
| 3382 | id_serializer_class = SiteRoleIdSerializer |
| 3383 | filter_backends = (filters.DjangoFilterBackend,) |
| 3384 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3385 | |
| 3386 | def get_serializer_class(self): |
| 3387 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3388 | if (no_hyperlinks): |
| 3389 | return self.id_serializer_class |
| 3390 | else: |
| 3391 | return self.serializer_class |
| 3392 | |
| 3393 | def get_queryset(self): |
| 3394 | return SiteRole.select_by_user(self.request.user) |
| 3395 | |
| 3396 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3397 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3398 | if not (serializer.is_valid()): |
| 3399 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3400 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3401 | obj.caller = request.user |
| 3402 | if obj.can_update(request.user): |
| 3403 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3404 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3405 | raise Exception("failed obj.can_update") |
| 3406 | |
| 3407 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3408 | if (ret.status_code%100 != 200): |
| 3409 | raise Exception(ret.data) |
| 3410 | |
| 3411 | return ret |
| 3412 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3413 | |
| 3414 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3415 | queryset = SiteRole.objects.select_related().all() |
| 3416 | serializer_class = SiteRoleSerializer |
| 3417 | id_serializer_class = SiteRoleIdSerializer |
| 3418 | |
| 3419 | def get_serializer_class(self): |
| 3420 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3421 | if (no_hyperlinks): |
| 3422 | return self.id_serializer_class |
| 3423 | else: |
| 3424 | return self.serializer_class |
| 3425 | |
| 3426 | def get_queryset(self): |
| 3427 | return SiteRole.select_by_user(self.request.user) |
| 3428 | |
| 3429 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3430 | |
| 3431 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3432 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3433 | """ |
| 3434 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3435 | filled with defaults. I solved it another way, so this code may soon be |
| 3436 | abandoned. |
| 3437 | |
| 3438 | class SiteRoleNew(GenericAPIView): |
| 3439 | serializer_class = SiteRoleSerializer |
| 3440 | id_serializer_class = SiteRoleIdSerializer |
| 3441 | |
| 3442 | def get(self, request, *args, **kwargs): |
| 3443 | return self.makenew(request, *args, **kwargs) |
| 3444 | |
| 3445 | def get_serializer_class(self): |
| 3446 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3447 | if (no_hyperlinks): |
| 3448 | return self.id_serializer_class |
| 3449 | else: |
| 3450 | return self.serializer_class |
| 3451 | |
| 3452 | def makenew(self, request, *args, **kwargs): |
| 3453 | obj = SiteRole() |
| 3454 | serializer = self.get_serializer(obj) |
| 3455 | return Response(serializer.data) |
| 3456 | """ |
| 3457 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3458 | |
| 3459 | |
| 3460 | class SliceCredentialList(generics.ListCreateAPIView): |
| 3461 | queryset = SliceCredential.objects.select_related().all() |
| 3462 | serializer_class = SliceCredentialSerializer |
| 3463 | id_serializer_class = SliceCredentialIdSerializer |
| 3464 | filter_backends = (filters.DjangoFilterBackend,) |
| 3465 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 3466 | |
| 3467 | def get_serializer_class(self): |
| 3468 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3469 | if (no_hyperlinks): |
| 3470 | return self.id_serializer_class |
| 3471 | else: |
| 3472 | return self.serializer_class |
| 3473 | |
| 3474 | def get_queryset(self): |
| 3475 | return SliceCredential.select_by_user(self.request.user) |
| 3476 | |
| 3477 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3478 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3479 | if not (serializer.is_valid()): |
| 3480 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3481 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3482 | obj.caller = request.user |
| 3483 | if obj.can_update(request.user): |
| 3484 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3485 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3486 | raise Exception("failed obj.can_update") |
| 3487 | |
| 3488 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3489 | if (ret.status_code%100 != 200): |
| 3490 | raise Exception(ret.data) |
| 3491 | |
| 3492 | return ret |
| 3493 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3494 | |
| 3495 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3496 | queryset = SliceCredential.objects.select_related().all() |
| 3497 | serializer_class = SliceCredentialSerializer |
| 3498 | id_serializer_class = SliceCredentialIdSerializer |
| 3499 | |
| 3500 | def get_serializer_class(self): |
| 3501 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3502 | if (no_hyperlinks): |
| 3503 | return self.id_serializer_class |
| 3504 | else: |
| 3505 | return self.serializer_class |
| 3506 | |
| 3507 | def get_queryset(self): |
| 3508 | return SliceCredential.select_by_user(self.request.user) |
| 3509 | |
| 3510 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3511 | |
| 3512 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3513 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3514 | """ |
| 3515 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3516 | filled with defaults. I solved it another way, so this code may soon be |
| 3517 | abandoned. |
| 3518 | |
| 3519 | class SliceCredentialNew(GenericAPIView): |
| 3520 | serializer_class = SliceCredentialSerializer |
| 3521 | id_serializer_class = SliceCredentialIdSerializer |
| 3522 | |
| 3523 | def get(self, request, *args, **kwargs): |
| 3524 | return self.makenew(request, *args, **kwargs) |
| 3525 | |
| 3526 | def get_serializer_class(self): |
| 3527 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3528 | if (no_hyperlinks): |
| 3529 | return self.id_serializer_class |
| 3530 | else: |
| 3531 | return self.serializer_class |
| 3532 | |
| 3533 | def makenew(self, request, *args, **kwargs): |
| 3534 | obj = SliceCredential() |
| 3535 | serializer = self.get_serializer(obj) |
| 3536 | return Response(serializer.data) |
| 3537 | """ |
| 3538 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3539 | |
| 3540 | |
| 3541 | class SliverList(generics.ListCreateAPIView): |
| 3542 | queryset = Sliver.objects.select_related().all() |
| 3543 | serializer_class = SliverSerializer |
| 3544 | id_serializer_class = SliverIdSerializer |
| 3545 | filter_backends = (filters.DjangoFilterBackend,) |
| 3546 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',) |
| 3547 | |
| 3548 | def get_serializer_class(self): |
| 3549 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3550 | if (no_hyperlinks): |
| 3551 | return self.id_serializer_class |
| 3552 | else: |
| 3553 | return self.serializer_class |
| 3554 | |
| 3555 | def get_queryset(self): |
| 3556 | return Sliver.select_by_user(self.request.user) |
| 3557 | |
| 3558 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3559 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3560 | if not (serializer.is_valid()): |
| 3561 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3562 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3563 | obj.caller = request.user |
| 3564 | if obj.can_update(request.user): |
| 3565 | return super(SliverList, self).create(request, *args, **kwargs) |
| 3566 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3567 | raise Exception("failed obj.can_update") |
| 3568 | |
| 3569 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 3570 | if (ret.status_code%100 != 200): |
| 3571 | raise Exception(ret.data) |
| 3572 | |
| 3573 | return ret |
| 3574 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3575 | |
| 3576 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3577 | queryset = Sliver.objects.select_related().all() |
| 3578 | serializer_class = SliverSerializer |
| 3579 | id_serializer_class = SliverIdSerializer |
| 3580 | |
| 3581 | def get_serializer_class(self): |
| 3582 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3583 | if (no_hyperlinks): |
| 3584 | return self.id_serializer_class |
| 3585 | else: |
| 3586 | return self.serializer_class |
| 3587 | |
| 3588 | def get_queryset(self): |
| 3589 | return Sliver.select_by_user(self.request.user) |
| 3590 | |
| 3591 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3592 | |
| 3593 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3594 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3595 | """ |
| 3596 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3597 | filled with defaults. I solved it another way, so this code may soon be |
| 3598 | abandoned. |
| 3599 | |
| 3600 | class SliverNew(GenericAPIView): |
| 3601 | serializer_class = SliverSerializer |
| 3602 | id_serializer_class = SliverIdSerializer |
| 3603 | |
| 3604 | def get(self, request, *args, **kwargs): |
| 3605 | return self.makenew(request, *args, **kwargs) |
| 3606 | |
| 3607 | def get_serializer_class(self): |
| 3608 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3609 | if (no_hyperlinks): |
| 3610 | return self.id_serializer_class |
| 3611 | else: |
| 3612 | return self.serializer_class |
| 3613 | |
| 3614 | def makenew(self, request, *args, **kwargs): |
| 3615 | obj = Sliver() |
| 3616 | serializer = self.get_serializer(obj) |
| 3617 | return Response(serializer.data) |
| 3618 | """ |
| 3619 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3620 | |
| 3621 | |
| 3622 | class NodeList(generics.ListCreateAPIView): |
| 3623 | queryset = Node.objects.select_related().all() |
| 3624 | serializer_class = NodeSerializer |
| 3625 | id_serializer_class = NodeIdSerializer |
| 3626 | filter_backends = (filters.DjangoFilterBackend,) |
| 3627 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',) |
| 3628 | |
| 3629 | def get_serializer_class(self): |
| 3630 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3631 | if (no_hyperlinks): |
| 3632 | return self.id_serializer_class |
| 3633 | else: |
| 3634 | return self.serializer_class |
| 3635 | |
| 3636 | def get_queryset(self): |
| 3637 | return Node.select_by_user(self.request.user) |
| 3638 | |
| 3639 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3640 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3641 | if not (serializer.is_valid()): |
| 3642 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3643 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3644 | obj.caller = request.user |
| 3645 | if obj.can_update(request.user): |
| 3646 | return super(NodeList, self).create(request, *args, **kwargs) |
| 3647 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3648 | raise Exception("failed obj.can_update") |
| 3649 | |
| 3650 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 3651 | if (ret.status_code%100 != 200): |
| 3652 | raise Exception(ret.data) |
| 3653 | |
| 3654 | return ret |
| 3655 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3656 | |
| 3657 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3658 | queryset = Node.objects.select_related().all() |
| 3659 | serializer_class = NodeSerializer |
| 3660 | id_serializer_class = NodeIdSerializer |
| 3661 | |
| 3662 | def get_serializer_class(self): |
| 3663 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3664 | if (no_hyperlinks): |
| 3665 | return self.id_serializer_class |
| 3666 | else: |
| 3667 | return self.serializer_class |
| 3668 | |
| 3669 | def get_queryset(self): |
| 3670 | return Node.select_by_user(self.request.user) |
| 3671 | |
| 3672 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3673 | |
| 3674 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3675 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3676 | """ |
| 3677 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3678 | filled with defaults. I solved it another way, so this code may soon be |
| 3679 | abandoned. |
| 3680 | |
| 3681 | class NodeNew(GenericAPIView): |
| 3682 | serializer_class = NodeSerializer |
| 3683 | id_serializer_class = NodeIdSerializer |
| 3684 | |
| 3685 | def get(self, request, *args, **kwargs): |
| 3686 | return self.makenew(request, *args, **kwargs) |
| 3687 | |
| 3688 | def get_serializer_class(self): |
| 3689 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3690 | if (no_hyperlinks): |
| 3691 | return self.id_serializer_class |
| 3692 | else: |
| 3693 | return self.serializer_class |
| 3694 | |
| 3695 | def makenew(self, request, *args, **kwargs): |
| 3696 | obj = Node() |
| 3697 | serializer = self.get_serializer(obj) |
| 3698 | return Response(serializer.data) |
| 3699 | """ |
| 3700 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3701 | |
| 3702 | |
| 3703 | class DashboardViewList(generics.ListCreateAPIView): |
| 3704 | queryset = DashboardView.objects.select_related().all() |
| 3705 | serializer_class = DashboardViewSerializer |
| 3706 | id_serializer_class = DashboardViewIdSerializer |
| 3707 | filter_backends = (filters.DjangoFilterBackend,) |
| 3708 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',) |
| 3709 | |
| 3710 | def get_serializer_class(self): |
| 3711 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3712 | if (no_hyperlinks): |
| 3713 | return self.id_serializer_class |
| 3714 | else: |
| 3715 | return self.serializer_class |
| 3716 | |
| 3717 | def get_queryset(self): |
| 3718 | return DashboardView.select_by_user(self.request.user) |
| 3719 | |
| 3720 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3721 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3722 | if not (serializer.is_valid()): |
| 3723 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3724 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3725 | obj.caller = request.user |
| 3726 | if obj.can_update(request.user): |
| 3727 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 3728 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3729 | raise Exception("failed obj.can_update") |
| 3730 | |
| 3731 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 3732 | if (ret.status_code%100 != 200): |
| 3733 | raise Exception(ret.data) |
| 3734 | |
| 3735 | return ret |
| 3736 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3737 | |
| 3738 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3739 | queryset = DashboardView.objects.select_related().all() |
| 3740 | serializer_class = DashboardViewSerializer |
| 3741 | id_serializer_class = DashboardViewIdSerializer |
| 3742 | |
| 3743 | def get_serializer_class(self): |
| 3744 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3745 | if (no_hyperlinks): |
| 3746 | return self.id_serializer_class |
| 3747 | else: |
| 3748 | return self.serializer_class |
| 3749 | |
| 3750 | def get_queryset(self): |
| 3751 | return DashboardView.select_by_user(self.request.user) |
| 3752 | |
| 3753 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3754 | |
| 3755 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3756 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3757 | """ |
| 3758 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3759 | filled with defaults. I solved it another way, so this code may soon be |
| 3760 | abandoned. |
| 3761 | |
| 3762 | class DashboardViewNew(GenericAPIView): |
| 3763 | serializer_class = DashboardViewSerializer |
| 3764 | id_serializer_class = DashboardViewIdSerializer |
| 3765 | |
| 3766 | def get(self, request, *args, **kwargs): |
| 3767 | return self.makenew(request, *args, **kwargs) |
| 3768 | |
| 3769 | def get_serializer_class(self): |
| 3770 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3771 | if (no_hyperlinks): |
| 3772 | return self.id_serializer_class |
| 3773 | else: |
| 3774 | return self.serializer_class |
| 3775 | |
| 3776 | def makenew(self, request, *args, **kwargs): |
| 3777 | obj = DashboardView() |
| 3778 | serializer = self.get_serializer(obj) |
| 3779 | return Response(serializer.data) |
| 3780 | """ |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3781 | |
| 3782 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3783 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 3784 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 3785 | queryset = ImageDeployments.objects.select_related().all() |
| 3786 | serializer_class = ImageDeploymentsSerializer |
| 3787 | id_serializer_class = ImageDeploymentsIdSerializer |
| 3788 | filter_backends = (filters.DjangoFilterBackend,) |
| 3789 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',) |
| 3790 | |
| 3791 | def get_serializer_class(self): |
| 3792 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3793 | if (no_hyperlinks): |
| 3794 | return self.id_serializer_class |
| 3795 | else: |
| 3796 | return self.serializer_class |
| 3797 | |
| 3798 | def get_queryset(self): |
| 3799 | return ImageDeployments.select_by_user(self.request.user) |
| 3800 | |
| 3801 | def create(self, request, *args, **kwargs): |
| 3802 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3803 | if not (serializer.is_valid()): |
| 3804 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3805 | obj = serializer.object |
| 3806 | obj.caller = request.user |
| 3807 | if obj.can_update(request.user): |
| 3808 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
| 3809 | else: |
| 3810 | raise Exception("failed obj.can_update") |
| 3811 | |
| 3812 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
| 3813 | if (ret.status_code%100 != 200): |
| 3814 | raise Exception(ret.data) |
| 3815 | |
| 3816 | return ret |
| 3817 | |
| 3818 | |
| 3819 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3820 | queryset = ImageDeployments.objects.select_related().all() |
| 3821 | serializer_class = ImageDeploymentsSerializer |
| 3822 | id_serializer_class = ImageDeploymentsIdSerializer |
| 3823 | |
| 3824 | def get_serializer_class(self): |
| 3825 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3826 | if (no_hyperlinks): |
| 3827 | return self.id_serializer_class |
| 3828 | else: |
| 3829 | return self.serializer_class |
| 3830 | |
| 3831 | def get_queryset(self): |
| 3832 | return ImageDeployments.select_by_user(self.request.user) |
| 3833 | |
| 3834 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3835 | |
| 3836 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3837 | |
| 3838 | """ |
| 3839 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3840 | filled with defaults. I solved it another way, so this code may soon be |
| 3841 | abandoned. |
| 3842 | |
| 3843 | class ImageDeploymentsNew(GenericAPIView): |
| 3844 | serializer_class = ImageDeploymentsSerializer |
| 3845 | id_serializer_class = ImageDeploymentsIdSerializer |
| 3846 | |
| 3847 | def get(self, request, *args, **kwargs): |
| 3848 | return self.makenew(request, *args, **kwargs) |
| 3849 | |
| 3850 | def get_serializer_class(self): |
| 3851 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3852 | if (no_hyperlinks): |
| 3853 | return self.id_serializer_class |
| 3854 | else: |
| 3855 | return self.serializer_class |
| 3856 | |
| 3857 | def makenew(self, request, *args, **kwargs): |
| 3858 | obj = ImageDeployments() |
| 3859 | serializer = self.get_serializer(obj) |
| 3860 | return Response(serializer.data) |
| 3861 | """ |
| 3862 | |
| 3863 | |
| 3864 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3865 | class ReservedResourceList(generics.ListCreateAPIView): |
| 3866 | queryset = ReservedResource.objects.select_related().all() |
| 3867 | serializer_class = ReservedResourceSerializer |
| 3868 | id_serializer_class = ReservedResourceIdSerializer |
| 3869 | filter_backends = (filters.DjangoFilterBackend,) |
| 3870 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 3871 | |
| 3872 | def get_serializer_class(self): |
| 3873 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3874 | if (no_hyperlinks): |
| 3875 | return self.id_serializer_class |
| 3876 | else: |
| 3877 | return self.serializer_class |
| 3878 | |
| 3879 | def get_queryset(self): |
| 3880 | return ReservedResource.select_by_user(self.request.user) |
| 3881 | |
| 3882 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3883 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3884 | if not (serializer.is_valid()): |
| 3885 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3886 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3887 | obj.caller = request.user |
| 3888 | if obj.can_update(request.user): |
| 3889 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 3890 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3891 | raise Exception("failed obj.can_update") |
| 3892 | |
| 3893 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 3894 | if (ret.status_code%100 != 200): |
| 3895 | raise Exception(ret.data) |
| 3896 | |
| 3897 | return ret |
| 3898 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3899 | |
| 3900 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3901 | queryset = ReservedResource.objects.select_related().all() |
| 3902 | serializer_class = ReservedResourceSerializer |
| 3903 | id_serializer_class = ReservedResourceIdSerializer |
| 3904 | |
| 3905 | def get_serializer_class(self): |
| 3906 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3907 | if (no_hyperlinks): |
| 3908 | return self.id_serializer_class |
| 3909 | else: |
| 3910 | return self.serializer_class |
| 3911 | |
| 3912 | def get_queryset(self): |
| 3913 | return ReservedResource.select_by_user(self.request.user) |
| 3914 | |
| 3915 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3916 | |
| 3917 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3918 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3919 | """ |
| 3920 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 3921 | filled with defaults. I solved it another way, so this code may soon be |
| 3922 | abandoned. |
| 3923 | |
| 3924 | class ReservedResourceNew(GenericAPIView): |
| 3925 | serializer_class = ReservedResourceSerializer |
| 3926 | id_serializer_class = ReservedResourceIdSerializer |
| 3927 | |
| 3928 | def get(self, request, *args, **kwargs): |
| 3929 | return self.makenew(request, *args, **kwargs) |
| 3930 | |
| 3931 | def get_serializer_class(self): |
| 3932 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3933 | if (no_hyperlinks): |
| 3934 | return self.id_serializer_class |
| 3935 | else: |
| 3936 | return self.serializer_class |
| 3937 | |
| 3938 | def makenew(self, request, *args, **kwargs): |
| 3939 | obj = ReservedResource() |
| 3940 | serializer = self.get_serializer(obj) |
| 3941 | return Response(serializer.data) |
| 3942 | """ |
| 3943 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3944 | |
| 3945 | |
| 3946 | class NetworkSliceList(generics.ListCreateAPIView): |
| 3947 | queryset = NetworkSlice.objects.select_related().all() |
| 3948 | serializer_class = NetworkSliceSerializer |
| 3949 | id_serializer_class = NetworkSliceIdSerializer |
| 3950 | filter_backends = (filters.DjangoFilterBackend,) |
| 3951 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 3952 | |
| 3953 | def get_serializer_class(self): |
| 3954 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3955 | if (no_hyperlinks): |
| 3956 | return self.id_serializer_class |
| 3957 | else: |
| 3958 | return self.serializer_class |
| 3959 | |
| 3960 | def get_queryset(self): |
| 3961 | return NetworkSlice.select_by_user(self.request.user) |
| 3962 | |
| 3963 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3964 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3965 | if not (serializer.is_valid()): |
| 3966 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 3967 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3968 | obj.caller = request.user |
| 3969 | if obj.can_update(request.user): |
| 3970 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 3971 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3972 | raise Exception("failed obj.can_update") |
| 3973 | |
| 3974 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 3975 | if (ret.status_code%100 != 200): |
| 3976 | raise Exception(ret.data) |
| 3977 | |
| 3978 | return ret |
| 3979 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3980 | |
| 3981 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3982 | queryset = NetworkSlice.objects.select_related().all() |
| 3983 | serializer_class = NetworkSliceSerializer |
| 3984 | id_serializer_class = NetworkSliceIdSerializer |
| 3985 | |
| 3986 | def get_serializer_class(self): |
| 3987 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3988 | if (no_hyperlinks): |
| 3989 | return self.id_serializer_class |
| 3990 | else: |
| 3991 | return self.serializer_class |
| 3992 | |
| 3993 | def get_queryset(self): |
| 3994 | return NetworkSlice.select_by_user(self.request.user) |
| 3995 | |
| 3996 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3997 | |
| 3998 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3999 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4000 | """ |
| 4001 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4002 | filled with defaults. I solved it another way, so this code may soon be |
| 4003 | abandoned. |
| 4004 | |
| 4005 | class NetworkSliceNew(GenericAPIView): |
| 4006 | serializer_class = NetworkSliceSerializer |
| 4007 | id_serializer_class = NetworkSliceIdSerializer |
| 4008 | |
| 4009 | def get(self, request, *args, **kwargs): |
| 4010 | return self.makenew(request, *args, **kwargs) |
| 4011 | |
| 4012 | def get_serializer_class(self): |
| 4013 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4014 | if (no_hyperlinks): |
| 4015 | return self.id_serializer_class |
| 4016 | else: |
| 4017 | return self.serializer_class |
| 4018 | |
| 4019 | def makenew(self, request, *args, **kwargs): |
| 4020 | obj = NetworkSlice() |
| 4021 | serializer = self.get_serializer(obj) |
| 4022 | return Response(serializer.data) |
| 4023 | """ |
| 4024 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4025 | |
| 4026 | |
| 4027 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 4028 | queryset = UserDashboardView.objects.select_related().all() |
| 4029 | serializer_class = UserDashboardViewSerializer |
| 4030 | id_serializer_class = UserDashboardViewIdSerializer |
| 4031 | filter_backends = (filters.DjangoFilterBackend,) |
| 4032 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 4033 | |
| 4034 | def get_serializer_class(self): |
| 4035 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4036 | if (no_hyperlinks): |
| 4037 | return self.id_serializer_class |
| 4038 | else: |
| 4039 | return self.serializer_class |
| 4040 | |
| 4041 | def get_queryset(self): |
| 4042 | return UserDashboardView.select_by_user(self.request.user) |
| 4043 | |
| 4044 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4045 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4046 | if not (serializer.is_valid()): |
| 4047 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4048 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4049 | obj.caller = request.user |
| 4050 | if obj.can_update(request.user): |
| 4051 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4052 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4053 | raise Exception("failed obj.can_update") |
| 4054 | |
| 4055 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4056 | if (ret.status_code%100 != 200): |
| 4057 | raise Exception(ret.data) |
| 4058 | |
| 4059 | return ret |
| 4060 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4061 | |
| 4062 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4063 | queryset = UserDashboardView.objects.select_related().all() |
| 4064 | serializer_class = UserDashboardViewSerializer |
| 4065 | id_serializer_class = UserDashboardViewIdSerializer |
| 4066 | |
| 4067 | def get_serializer_class(self): |
| 4068 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4069 | if (no_hyperlinks): |
| 4070 | return self.id_serializer_class |
| 4071 | else: |
| 4072 | return self.serializer_class |
| 4073 | |
| 4074 | def get_queryset(self): |
| 4075 | return UserDashboardView.select_by_user(self.request.user) |
| 4076 | |
| 4077 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4078 | |
| 4079 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4080 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4081 | """ |
| 4082 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4083 | filled with defaults. I solved it another way, so this code may soon be |
| 4084 | abandoned. |
| 4085 | |
| 4086 | class UserDashboardViewNew(GenericAPIView): |
| 4087 | serializer_class = UserDashboardViewSerializer |
| 4088 | id_serializer_class = UserDashboardViewIdSerializer |
| 4089 | |
| 4090 | def get(self, request, *args, **kwargs): |
| 4091 | return self.makenew(request, *args, **kwargs) |
| 4092 | |
| 4093 | def get_serializer_class(self): |
| 4094 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4095 | if (no_hyperlinks): |
| 4096 | return self.id_serializer_class |
| 4097 | else: |
| 4098 | return self.serializer_class |
| 4099 | |
| 4100 | def makenew(self, request, *args, **kwargs): |
| 4101 | obj = UserDashboardView() |
| 4102 | serializer = self.get_serializer(obj) |
| 4103 | return Response(serializer.data) |
| 4104 | """ |
| 4105 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4106 | |
| 4107 | |
| 4108 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 4109 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4110 | serializer_class = PlanetStackPrivilegeSerializer |
| 4111 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4112 | filter_backends = (filters.DjangoFilterBackend,) |
| 4113 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 4114 | |
| 4115 | def get_serializer_class(self): |
| 4116 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4117 | if (no_hyperlinks): |
| 4118 | return self.id_serializer_class |
| 4119 | else: |
| 4120 | return self.serializer_class |
| 4121 | |
| 4122 | def get_queryset(self): |
| 4123 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4124 | |
| 4125 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4126 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4127 | if not (serializer.is_valid()): |
| 4128 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4129 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4130 | obj.caller = request.user |
| 4131 | if obj.can_update(request.user): |
| 4132 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4133 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4134 | raise Exception("failed obj.can_update") |
| 4135 | |
| 4136 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4137 | if (ret.status_code%100 != 200): |
| 4138 | raise Exception(ret.data) |
| 4139 | |
| 4140 | return ret |
| 4141 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4142 | |
| 4143 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4144 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4145 | serializer_class = PlanetStackPrivilegeSerializer |
| 4146 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4147 | |
| 4148 | def get_serializer_class(self): |
| 4149 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4150 | if (no_hyperlinks): |
| 4151 | return self.id_serializer_class |
| 4152 | else: |
| 4153 | return self.serializer_class |
| 4154 | |
| 4155 | def get_queryset(self): |
| 4156 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4157 | |
| 4158 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4159 | |
| 4160 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4161 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4162 | """ |
| 4163 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4164 | filled with defaults. I solved it another way, so this code may soon be |
| 4165 | abandoned. |
| 4166 | |
| 4167 | class PlanetStackPrivilegeNew(GenericAPIView): |
| 4168 | serializer_class = PlanetStackPrivilegeSerializer |
| 4169 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4170 | |
| 4171 | def get(self, request, *args, **kwargs): |
| 4172 | return self.makenew(request, *args, **kwargs) |
| 4173 | |
| 4174 | def get_serializer_class(self): |
| 4175 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4176 | if (no_hyperlinks): |
| 4177 | return self.id_serializer_class |
| 4178 | else: |
| 4179 | return self.serializer_class |
| 4180 | |
| 4181 | def makenew(self, request, *args, **kwargs): |
| 4182 | obj = PlanetStackPrivilege() |
| 4183 | serializer = self.get_serializer(obj) |
| 4184 | return Response(serializer.data) |
| 4185 | """ |
| 4186 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4187 | |
| 4188 | |
| 4189 | class UserList(generics.ListCreateAPIView): |
| 4190 | queryset = User.objects.select_related().all() |
| 4191 | serializer_class = UserSerializer |
| 4192 | id_serializer_class = UserIdSerializer |
| 4193 | filter_backends = (filters.DjangoFilterBackend,) |
| 4194 | 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',) |
| 4195 | |
| 4196 | def get_serializer_class(self): |
| 4197 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4198 | if (no_hyperlinks): |
| 4199 | return self.id_serializer_class |
| 4200 | else: |
| 4201 | return self.serializer_class |
| 4202 | |
| 4203 | def get_queryset(self): |
| 4204 | return User.select_by_user(self.request.user) |
| 4205 | |
| 4206 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4207 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4208 | if not (serializer.is_valid()): |
| 4209 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4210 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4211 | obj.caller = request.user |
| 4212 | if obj.can_update(request.user): |
| 4213 | return super(UserList, self).create(request, *args, **kwargs) |
| 4214 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4215 | raise Exception("failed obj.can_update") |
| 4216 | |
| 4217 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 4218 | if (ret.status_code%100 != 200): |
| 4219 | raise Exception(ret.data) |
| 4220 | |
| 4221 | return ret |
| 4222 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4223 | |
| 4224 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4225 | queryset = User.objects.select_related().all() |
| 4226 | serializer_class = UserSerializer |
| 4227 | id_serializer_class = UserIdSerializer |
| 4228 | |
| 4229 | def get_serializer_class(self): |
| 4230 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4231 | if (no_hyperlinks): |
| 4232 | return self.id_serializer_class |
| 4233 | else: |
| 4234 | return self.serializer_class |
| 4235 | |
| 4236 | def get_queryset(self): |
| 4237 | return User.select_by_user(self.request.user) |
| 4238 | |
| 4239 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4240 | |
| 4241 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4242 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4243 | """ |
| 4244 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4245 | filled with defaults. I solved it another way, so this code may soon be |
| 4246 | abandoned. |
| 4247 | |
| 4248 | class UserNew(GenericAPIView): |
| 4249 | serializer_class = UserSerializer |
| 4250 | id_serializer_class = UserIdSerializer |
| 4251 | |
| 4252 | def get(self, request, *args, **kwargs): |
| 4253 | return self.makenew(request, *args, **kwargs) |
| 4254 | |
| 4255 | def get_serializer_class(self): |
| 4256 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4257 | if (no_hyperlinks): |
| 4258 | return self.id_serializer_class |
| 4259 | else: |
| 4260 | return self.serializer_class |
| 4261 | |
| 4262 | def makenew(self, request, *args, **kwargs): |
| 4263 | obj = User() |
| 4264 | serializer = self.get_serializer(obj) |
| 4265 | return Response(serializer.data) |
| 4266 | """ |
| 4267 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4268 | |
| 4269 | |
| 4270 | class DeploymentList(generics.ListCreateAPIView): |
| 4271 | queryset = Deployment.objects.select_related().all() |
| 4272 | serializer_class = DeploymentSerializer |
| 4273 | id_serializer_class = DeploymentIdSerializer |
| 4274 | filter_backends = (filters.DjangoFilterBackend,) |
| 4275 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',) |
| 4276 | |
| 4277 | def get_serializer_class(self): |
| 4278 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4279 | if (no_hyperlinks): |
| 4280 | return self.id_serializer_class |
| 4281 | else: |
| 4282 | return self.serializer_class |
| 4283 | |
| 4284 | def get_queryset(self): |
| 4285 | return Deployment.select_by_user(self.request.user) |
| 4286 | |
| 4287 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4288 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4289 | if not (serializer.is_valid()): |
| 4290 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4291 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4292 | obj.caller = request.user |
| 4293 | if obj.can_update(request.user): |
| 4294 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 4295 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4296 | raise Exception("failed obj.can_update") |
| 4297 | |
| 4298 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 4299 | if (ret.status_code%100 != 200): |
| 4300 | raise Exception(ret.data) |
| 4301 | |
| 4302 | return ret |
| 4303 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4304 | |
| 4305 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4306 | queryset = Deployment.objects.select_related().all() |
| 4307 | serializer_class = DeploymentSerializer |
| 4308 | id_serializer_class = DeploymentIdSerializer |
| 4309 | |
| 4310 | def get_serializer_class(self): |
| 4311 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4312 | if (no_hyperlinks): |
| 4313 | return self.id_serializer_class |
| 4314 | else: |
| 4315 | return self.serializer_class |
| 4316 | |
| 4317 | def get_queryset(self): |
| 4318 | return Deployment.select_by_user(self.request.user) |
| 4319 | |
| 4320 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4321 | |
| 4322 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4323 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4324 | """ |
| 4325 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4326 | filled with defaults. I solved it another way, so this code may soon be |
| 4327 | abandoned. |
| 4328 | |
| 4329 | class DeploymentNew(GenericAPIView): |
| 4330 | serializer_class = DeploymentSerializer |
| 4331 | id_serializer_class = DeploymentIdSerializer |
| 4332 | |
| 4333 | def get(self, request, *args, **kwargs): |
| 4334 | return self.makenew(request, *args, **kwargs) |
| 4335 | |
| 4336 | def get_serializer_class(self): |
| 4337 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4338 | if (no_hyperlinks): |
| 4339 | return self.id_serializer_class |
| 4340 | else: |
| 4341 | return self.serializer_class |
| 4342 | |
| 4343 | def makenew(self, request, *args, **kwargs): |
| 4344 | obj = Deployment() |
| 4345 | serializer = self.get_serializer(obj) |
| 4346 | return Response(serializer.data) |
| 4347 | """ |
| 4348 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4349 | |
| 4350 | |
| 4351 | class ReservationList(generics.ListCreateAPIView): |
| 4352 | queryset = Reservation.objects.select_related().all() |
| 4353 | serializer_class = ReservationSerializer |
| 4354 | id_serializer_class = ReservationIdSerializer |
| 4355 | filter_backends = (filters.DjangoFilterBackend,) |
| 4356 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 4357 | |
| 4358 | def get_serializer_class(self): |
| 4359 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4360 | if (no_hyperlinks): |
| 4361 | return self.id_serializer_class |
| 4362 | else: |
| 4363 | return self.serializer_class |
| 4364 | |
| 4365 | def get_queryset(self): |
| 4366 | return Reservation.select_by_user(self.request.user) |
| 4367 | |
| 4368 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4369 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4370 | if not (serializer.is_valid()): |
| 4371 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4372 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4373 | obj.caller = request.user |
| 4374 | if obj.can_update(request.user): |
| 4375 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 4376 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4377 | raise Exception("failed obj.can_update") |
| 4378 | |
| 4379 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 4380 | if (ret.status_code%100 != 200): |
| 4381 | raise Exception(ret.data) |
| 4382 | |
| 4383 | return ret |
| 4384 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4385 | |
| 4386 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4387 | queryset = Reservation.objects.select_related().all() |
| 4388 | serializer_class = ReservationSerializer |
| 4389 | id_serializer_class = ReservationIdSerializer |
| 4390 | |
| 4391 | def get_serializer_class(self): |
| 4392 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4393 | if (no_hyperlinks): |
| 4394 | return self.id_serializer_class |
| 4395 | else: |
| 4396 | return self.serializer_class |
| 4397 | |
| 4398 | def get_queryset(self): |
| 4399 | return Reservation.select_by_user(self.request.user) |
| 4400 | |
| 4401 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4402 | |
| 4403 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4404 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4405 | """ |
| 4406 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4407 | filled with defaults. I solved it another way, so this code may soon be |
| 4408 | abandoned. |
| 4409 | |
| 4410 | class ReservationNew(GenericAPIView): |
| 4411 | serializer_class = ReservationSerializer |
| 4412 | id_serializer_class = ReservationIdSerializer |
| 4413 | |
| 4414 | def get(self, request, *args, **kwargs): |
| 4415 | return self.makenew(request, *args, **kwargs) |
| 4416 | |
| 4417 | def get_serializer_class(self): |
| 4418 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4419 | if (no_hyperlinks): |
| 4420 | return self.id_serializer_class |
| 4421 | else: |
| 4422 | return self.serializer_class |
| 4423 | |
| 4424 | def makenew(self, request, *args, **kwargs): |
| 4425 | obj = Reservation() |
| 4426 | serializer = self.get_serializer(obj) |
| 4427 | return Response(serializer.data) |
| 4428 | """ |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4429 | |
| 4430 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4431 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4432 | class SliceDeploymentsList(generics.ListCreateAPIView): |
| 4433 | queryset = SliceDeployments.objects.select_related().all() |
| 4434 | serializer_class = SliceDeploymentsSerializer |
| 4435 | id_serializer_class = SliceDeploymentsIdSerializer |
| 4436 | filter_backends = (filters.DjangoFilterBackend,) |
| 4437 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',) |
| 4438 | |
| 4439 | def get_serializer_class(self): |
| 4440 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4441 | if (no_hyperlinks): |
| 4442 | return self.id_serializer_class |
| 4443 | else: |
| 4444 | return self.serializer_class |
| 4445 | |
| 4446 | def get_queryset(self): |
| 4447 | return SliceDeployments.select_by_user(self.request.user) |
| 4448 | |
| 4449 | def create(self, request, *args, **kwargs): |
| 4450 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4451 | if not (serializer.is_valid()): |
| 4452 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4453 | obj = serializer.object |
| 4454 | obj.caller = request.user |
| 4455 | if obj.can_update(request.user): |
| 4456 | return super(SliceDeploymentsList, self).create(request, *args, **kwargs) |
| 4457 | else: |
| 4458 | raise Exception("failed obj.can_update") |
| 4459 | |
| 4460 | ret = super(SliceDeploymentsList, self).create(request, *args, **kwargs) |
| 4461 | if (ret.status_code%100 != 200): |
| 4462 | raise Exception(ret.data) |
| 4463 | |
| 4464 | return ret |
| 4465 | |
| 4466 | |
| 4467 | class SliceDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4468 | queryset = SliceDeployments.objects.select_related().all() |
| 4469 | serializer_class = SliceDeploymentsSerializer |
| 4470 | id_serializer_class = SliceDeploymentsIdSerializer |
| 4471 | |
| 4472 | def get_serializer_class(self): |
| 4473 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4474 | if (no_hyperlinks): |
| 4475 | return self.id_serializer_class |
| 4476 | else: |
| 4477 | return self.serializer_class |
| 4478 | |
| 4479 | def get_queryset(self): |
| 4480 | return SliceDeployments.select_by_user(self.request.user) |
| 4481 | |
| 4482 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4483 | |
| 4484 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4485 | |
| 4486 | """ |
| 4487 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4488 | filled with defaults. I solved it another way, so this code may soon be |
| 4489 | abandoned. |
| 4490 | |
| 4491 | class SliceDeploymentsNew(GenericAPIView): |
| 4492 | serializer_class = SliceDeploymentsSerializer |
| 4493 | id_serializer_class = SliceDeploymentsIdSerializer |
| 4494 | |
| 4495 | def get(self, request, *args, **kwargs): |
| 4496 | return self.makenew(request, *args, **kwargs) |
| 4497 | |
| 4498 | def get_serializer_class(self): |
| 4499 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4500 | if (no_hyperlinks): |
| 4501 | return self.id_serializer_class |
| 4502 | else: |
| 4503 | return self.serializer_class |
| 4504 | |
| 4505 | def makenew(self, request, *args, **kwargs): |
| 4506 | obj = SliceDeployments() |
| 4507 | serializer = self.get_serializer(obj) |
| 4508 | return Response(serializer.data) |
| 4509 | """ |
| 4510 | |
| 4511 | |
| 4512 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4513 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 4514 | queryset = SitePrivilege.objects.select_related().all() |
| 4515 | serializer_class = SitePrivilegeSerializer |
| 4516 | id_serializer_class = SitePrivilegeIdSerializer |
| 4517 | filter_backends = (filters.DjangoFilterBackend,) |
| 4518 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 4519 | |
| 4520 | def get_serializer_class(self): |
| 4521 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4522 | if (no_hyperlinks): |
| 4523 | return self.id_serializer_class |
| 4524 | else: |
| 4525 | return self.serializer_class |
| 4526 | |
| 4527 | def get_queryset(self): |
| 4528 | return SitePrivilege.select_by_user(self.request.user) |
| 4529 | |
| 4530 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4531 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4532 | if not (serializer.is_valid()): |
| 4533 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4534 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4535 | obj.caller = request.user |
| 4536 | if obj.can_update(request.user): |
| 4537 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4538 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4539 | raise Exception("failed obj.can_update") |
| 4540 | |
| 4541 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4542 | if (ret.status_code%100 != 200): |
| 4543 | raise Exception(ret.data) |
| 4544 | |
| 4545 | return ret |
| 4546 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4547 | |
| 4548 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4549 | queryset = SitePrivilege.objects.select_related().all() |
| 4550 | serializer_class = SitePrivilegeSerializer |
| 4551 | id_serializer_class = SitePrivilegeIdSerializer |
| 4552 | |
| 4553 | def get_serializer_class(self): |
| 4554 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4555 | if (no_hyperlinks): |
| 4556 | return self.id_serializer_class |
| 4557 | else: |
| 4558 | return self.serializer_class |
| 4559 | |
| 4560 | def get_queryset(self): |
| 4561 | return SitePrivilege.select_by_user(self.request.user) |
| 4562 | |
| 4563 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4564 | |
| 4565 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4566 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4567 | """ |
| 4568 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4569 | filled with defaults. I solved it another way, so this code may soon be |
| 4570 | abandoned. |
| 4571 | |
| 4572 | class SitePrivilegeNew(GenericAPIView): |
| 4573 | serializer_class = SitePrivilegeSerializer |
| 4574 | id_serializer_class = SitePrivilegeIdSerializer |
| 4575 | |
| 4576 | def get(self, request, *args, **kwargs): |
| 4577 | return self.makenew(request, *args, **kwargs) |
| 4578 | |
| 4579 | def get_serializer_class(self): |
| 4580 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4581 | if (no_hyperlinks): |
| 4582 | return self.id_serializer_class |
| 4583 | else: |
| 4584 | return self.serializer_class |
| 4585 | |
| 4586 | def makenew(self, request, *args, **kwargs): |
| 4587 | obj = SitePrivilege() |
| 4588 | serializer = self.get_serializer(obj) |
| 4589 | return Response(serializer.data) |
| 4590 | """ |
| 4591 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4592 | |
| 4593 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4594 | class PlanetStackList(generics.ListCreateAPIView): |
| 4595 | queryset = PlanetStack.objects.select_related().all() |
| 4596 | serializer_class = PlanetStackSerializer |
| 4597 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4598 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4599 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4600 | |
| 4601 | def get_serializer_class(self): |
| 4602 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4603 | if (no_hyperlinks): |
| 4604 | return self.id_serializer_class |
| 4605 | else: |
| 4606 | return self.serializer_class |
| 4607 | |
| 4608 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4609 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4610 | |
| 4611 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4612 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4613 | if not (serializer.is_valid()): |
| 4614 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4615 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4616 | obj.caller = request.user |
| 4617 | if obj.can_update(request.user): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4618 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4619 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4620 | raise Exception("failed obj.can_update") |
| 4621 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4622 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4623 | if (ret.status_code%100 != 200): |
| 4624 | raise Exception(ret.data) |
| 4625 | |
| 4626 | return ret |
| 4627 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4628 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4629 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4630 | queryset = PlanetStack.objects.select_related().all() |
| 4631 | serializer_class = PlanetStackSerializer |
| 4632 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4633 | |
| 4634 | def get_serializer_class(self): |
| 4635 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4636 | if (no_hyperlinks): |
| 4637 | return self.id_serializer_class |
| 4638 | else: |
| 4639 | return self.serializer_class |
| 4640 | |
| 4641 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4642 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4643 | |
| 4644 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4645 | |
| 4646 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4647 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4648 | """ |
| 4649 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4650 | filled with defaults. I solved it another way, so this code may soon be |
| 4651 | abandoned. |
| 4652 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4653 | class PlanetStackNew(GenericAPIView): |
| 4654 | serializer_class = PlanetStackSerializer |
| 4655 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4656 | |
| 4657 | def get(self, request, *args, **kwargs): |
| 4658 | return self.makenew(request, *args, **kwargs) |
| 4659 | |
| 4660 | def get_serializer_class(self): |
| 4661 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4662 | if (no_hyperlinks): |
| 4663 | return self.id_serializer_class |
| 4664 | else: |
| 4665 | return self.serializer_class |
| 4666 | |
| 4667 | def makenew(self, request, *args, **kwargs): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4668 | obj = PlanetStack() |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4669 | serializer = self.get_serializer(obj) |
| 4670 | return Response(serializer.data) |
| 4671 | """ |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4672 | |
| 4673 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4674 | |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4675 | class UserDeploymentsList(generics.ListCreateAPIView): |
| 4676 | queryset = UserDeployments.objects.select_related().all() |
| 4677 | serializer_class = UserDeploymentsSerializer |
| 4678 | id_serializer_class = UserDeploymentsIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4679 | filter_backends = (filters.DjangoFilterBackend,) |
| 4680 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',) |
| 4681 | |
| 4682 | def get_serializer_class(self): |
| 4683 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4684 | if (no_hyperlinks): |
| 4685 | return self.id_serializer_class |
| 4686 | else: |
| 4687 | return self.serializer_class |
| 4688 | |
| 4689 | def get_queryset(self): |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4690 | return UserDeployments.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4691 | |
| 4692 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4693 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4694 | if not (serializer.is_valid()): |
| 4695 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4696 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4697 | obj.caller = request.user |
| 4698 | if obj.can_update(request.user): |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4699 | return super(UserDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4700 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4701 | raise Exception("failed obj.can_update") |
| 4702 | |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4703 | ret = super(UserDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4704 | if (ret.status_code%100 != 200): |
| 4705 | raise Exception(ret.data) |
| 4706 | |
| 4707 | return ret |
| 4708 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4709 | |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4710 | class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4711 | queryset = UserDeployments.objects.select_related().all() |
| 4712 | serializer_class = UserDeploymentsSerializer |
| 4713 | id_serializer_class = UserDeploymentsIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4714 | |
| 4715 | def get_serializer_class(self): |
| 4716 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4717 | if (no_hyperlinks): |
| 4718 | return self.id_serializer_class |
| 4719 | else: |
| 4720 | return self.serializer_class |
| 4721 | |
| 4722 | def get_queryset(self): |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4723 | return UserDeployments.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4724 | |
| 4725 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4726 | |
| 4727 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4728 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4729 | """ |
| 4730 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4731 | filled with defaults. I solved it another way, so this code may soon be |
| 4732 | abandoned. |
| 4733 | |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4734 | class UserDeploymentsNew(GenericAPIView): |
| 4735 | serializer_class = UserDeploymentsSerializer |
| 4736 | id_serializer_class = UserDeploymentsIdSerializer |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4737 | |
| 4738 | def get(self, request, *args, **kwargs): |
| 4739 | return self.makenew(request, *args, **kwargs) |
| 4740 | |
| 4741 | def get_serializer_class(self): |
| 4742 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4743 | if (no_hyperlinks): |
| 4744 | return self.id_serializer_class |
| 4745 | else: |
| 4746 | return self.serializer_class |
| 4747 | |
| 4748 | def makenew(self, request, *args, **kwargs): |
Sapan Bhatia | e20777d | 2014-11-19 15:10:51 -0500 | [diff] [blame] | 4749 | obj = UserDeployments() |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4750 | serializer = self.get_serializer(obj) |
| 4751 | return Response(serializer.data) |
| 4752 | """ |
| 4753 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4754 | |
| 4755 | |
| 4756 | class AccountList(generics.ListCreateAPIView): |
| 4757 | queryset = Account.objects.select_related().all() |
| 4758 | serializer_class = AccountSerializer |
| 4759 | id_serializer_class = AccountIdSerializer |
| 4760 | filter_backends = (filters.DjangoFilterBackend,) |
| 4761 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 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): |
| 4771 | return Account.select_by_user(self.request.user) |
| 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()): |
| 4776 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4777 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4778 | obj.caller = request.user |
| 4779 | if obj.can_update(request.user): |
| 4780 | return super(AccountList, self).create(request, *args, **kwargs) |
| 4781 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4782 | raise Exception("failed obj.can_update") |
| 4783 | |
| 4784 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 4785 | if (ret.status_code%100 != 200): |
| 4786 | raise Exception(ret.data) |
| 4787 | |
| 4788 | return ret |
| 4789 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4790 | |
| 4791 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4792 | queryset = Account.objects.select_related().all() |
| 4793 | serializer_class = AccountSerializer |
| 4794 | id_serializer_class = AccountIdSerializer |
| 4795 | |
| 4796 | def get_serializer_class(self): |
| 4797 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4798 | if (no_hyperlinks): |
| 4799 | return self.id_serializer_class |
| 4800 | else: |
| 4801 | return self.serializer_class |
| 4802 | |
| 4803 | def get_queryset(self): |
| 4804 | return Account.select_by_user(self.request.user) |
| 4805 | |
| 4806 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4807 | |
| 4808 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4809 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4810 | """ |
| 4811 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4812 | filled with defaults. I solved it another way, so this code may soon be |
| 4813 | abandoned. |
| 4814 | |
| 4815 | class AccountNew(GenericAPIView): |
| 4816 | serializer_class = AccountSerializer |
| 4817 | id_serializer_class = AccountIdSerializer |
| 4818 | |
| 4819 | def get(self, request, *args, **kwargs): |
| 4820 | return self.makenew(request, *args, **kwargs) |
| 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 makenew(self, request, *args, **kwargs): |
| 4830 | obj = Account() |
| 4831 | serializer = self.get_serializer(obj) |
| 4832 | return Response(serializer.data) |
| 4833 | """ |
| 4834 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4835 | |
| 4836 | |
| 4837 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 4838 | queryset = NetworkParameterType.objects.select_related().all() |
| 4839 | serializer_class = NetworkParameterTypeSerializer |
| 4840 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 4841 | filter_backends = (filters.DjangoFilterBackend,) |
| 4842 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 4843 | |
| 4844 | def get_serializer_class(self): |
| 4845 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4846 | if (no_hyperlinks): |
| 4847 | return self.id_serializer_class |
| 4848 | else: |
| 4849 | return self.serializer_class |
| 4850 | |
| 4851 | def get_queryset(self): |
| 4852 | return NetworkParameterType.select_by_user(self.request.user) |
| 4853 | |
| 4854 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4855 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4856 | if not (serializer.is_valid()): |
| 4857 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4858 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4859 | obj.caller = request.user |
| 4860 | if obj.can_update(request.user): |
| 4861 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 4862 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4863 | raise Exception("failed obj.can_update") |
| 4864 | |
| 4865 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 4866 | if (ret.status_code%100 != 200): |
| 4867 | raise Exception(ret.data) |
| 4868 | |
| 4869 | return ret |
| 4870 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4871 | |
| 4872 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4873 | queryset = NetworkParameterType.objects.select_related().all() |
| 4874 | serializer_class = NetworkParameterTypeSerializer |
| 4875 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 4876 | |
| 4877 | def get_serializer_class(self): |
| 4878 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4879 | if (no_hyperlinks): |
| 4880 | return self.id_serializer_class |
| 4881 | else: |
| 4882 | return self.serializer_class |
| 4883 | |
| 4884 | def get_queryset(self): |
| 4885 | return NetworkParameterType.select_by_user(self.request.user) |
| 4886 | |
| 4887 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4888 | |
| 4889 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4890 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4891 | """ |
| 4892 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4893 | filled with defaults. I solved it another way, so this code may soon be |
| 4894 | abandoned. |
| 4895 | |
| 4896 | class NetworkParameterTypeNew(GenericAPIView): |
| 4897 | serializer_class = NetworkParameterTypeSerializer |
| 4898 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 4899 | |
| 4900 | def get(self, request, *args, **kwargs): |
| 4901 | return self.makenew(request, *args, **kwargs) |
| 4902 | |
| 4903 | def get_serializer_class(self): |
| 4904 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4905 | if (no_hyperlinks): |
| 4906 | return self.id_serializer_class |
| 4907 | else: |
| 4908 | return self.serializer_class |
| 4909 | |
| 4910 | def makenew(self, request, *args, **kwargs): |
| 4911 | obj = NetworkParameterType() |
| 4912 | serializer = self.get_serializer(obj) |
| 4913 | return Response(serializer.data) |
| 4914 | """ |
| 4915 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4916 | |
| 4917 | |
| 4918 | class SiteCredentialList(generics.ListCreateAPIView): |
| 4919 | queryset = SiteCredential.objects.select_related().all() |
| 4920 | serializer_class = SiteCredentialSerializer |
| 4921 | id_serializer_class = SiteCredentialIdSerializer |
| 4922 | filter_backends = (filters.DjangoFilterBackend,) |
| 4923 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 4924 | |
| 4925 | def get_serializer_class(self): |
| 4926 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4927 | if (no_hyperlinks): |
| 4928 | return self.id_serializer_class |
| 4929 | else: |
| 4930 | return self.serializer_class |
| 4931 | |
| 4932 | def get_queryset(self): |
| 4933 | return SiteCredential.select_by_user(self.request.user) |
| 4934 | |
| 4935 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4936 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4937 | if not (serializer.is_valid()): |
| 4938 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 4939 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4940 | obj.caller = request.user |
| 4941 | if obj.can_update(request.user): |
| 4942 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 4943 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4944 | raise Exception("failed obj.can_update") |
| 4945 | |
| 4946 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 4947 | if (ret.status_code%100 != 200): |
| 4948 | raise Exception(ret.data) |
| 4949 | |
| 4950 | return ret |
| 4951 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4952 | |
| 4953 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4954 | queryset = SiteCredential.objects.select_related().all() |
| 4955 | serializer_class = SiteCredentialSerializer |
| 4956 | id_serializer_class = SiteCredentialIdSerializer |
| 4957 | |
| 4958 | def get_serializer_class(self): |
| 4959 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4960 | if (no_hyperlinks): |
| 4961 | return self.id_serializer_class |
| 4962 | else: |
| 4963 | return self.serializer_class |
| 4964 | |
| 4965 | def get_queryset(self): |
| 4966 | return SiteCredential.select_by_user(self.request.user) |
| 4967 | |
| 4968 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4969 | |
| 4970 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4971 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4972 | """ |
| 4973 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 4974 | filled with defaults. I solved it another way, so this code may soon be |
| 4975 | abandoned. |
| 4976 | |
| 4977 | class SiteCredentialNew(GenericAPIView): |
| 4978 | serializer_class = SiteCredentialSerializer |
| 4979 | id_serializer_class = SiteCredentialIdSerializer |
| 4980 | |
| 4981 | def get(self, request, *args, **kwargs): |
| 4982 | return self.makenew(request, *args, **kwargs) |
| 4983 | |
| 4984 | def get_serializer_class(self): |
| 4985 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4986 | if (no_hyperlinks): |
| 4987 | return self.id_serializer_class |
| 4988 | else: |
| 4989 | return self.serializer_class |
| 4990 | |
| 4991 | def makenew(self, request, *args, **kwargs): |
| 4992 | obj = SiteCredential() |
| 4993 | serializer = self.get_serializer(obj) |
| 4994 | return Response(serializer.data) |
| 4995 | """ |
| 4996 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4997 | |
| 4998 | |
| 4999 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 5000 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5001 | serializer_class = DeploymentPrivilegeSerializer |
| 5002 | id_serializer_class = DeploymentPrivilegeIdSerializer |
| 5003 | filter_backends = (filters.DjangoFilterBackend,) |
| 5004 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 5005 | |
| 5006 | def get_serializer_class(self): |
| 5007 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5008 | if (no_hyperlinks): |
| 5009 | return self.id_serializer_class |
| 5010 | else: |
| 5011 | return self.serializer_class |
| 5012 | |
| 5013 | def get_queryset(self): |
| 5014 | return DeploymentPrivilege.select_by_user(self.request.user) |
| 5015 | |
| 5016 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5017 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5018 | if not (serializer.is_valid()): |
| 5019 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 5020 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5021 | obj.caller = request.user |
| 5022 | if obj.can_update(request.user): |
| 5023 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
| 5024 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5025 | raise Exception("failed obj.can_update") |
| 5026 | |
| 5027 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
| 5028 | if (ret.status_code%100 != 200): |
| 5029 | raise Exception(ret.data) |
| 5030 | |
| 5031 | return ret |
| 5032 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5033 | |
| 5034 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5035 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5036 | serializer_class = DeploymentPrivilegeSerializer |
| 5037 | id_serializer_class = DeploymentPrivilegeIdSerializer |
| 5038 | |
| 5039 | def get_serializer_class(self): |
| 5040 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5041 | if (no_hyperlinks): |
| 5042 | return self.id_serializer_class |
| 5043 | else: |
| 5044 | return self.serializer_class |
| 5045 | |
| 5046 | def get_queryset(self): |
| 5047 | return DeploymentPrivilege.select_by_user(self.request.user) |
| 5048 | |
| 5049 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5050 | |
| 5051 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5052 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5053 | """ |
| 5054 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 5055 | filled with defaults. I solved it another way, so this code may soon be |
| 5056 | abandoned. |
| 5057 | |
| 5058 | class DeploymentPrivilegeNew(GenericAPIView): |
| 5059 | serializer_class = DeploymentPrivilegeSerializer |
| 5060 | id_serializer_class = DeploymentPrivilegeIdSerializer |
| 5061 | |
| 5062 | def get(self, request, *args, **kwargs): |
| 5063 | return self.makenew(request, *args, **kwargs) |
| 5064 | |
| 5065 | def get_serializer_class(self): |
| 5066 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5067 | if (no_hyperlinks): |
| 5068 | return self.id_serializer_class |
| 5069 | else: |
| 5070 | return self.serializer_class |
| 5071 | |
| 5072 | def makenew(self, request, *args, **kwargs): |
| 5073 | obj = DeploymentPrivilege() |
| 5074 | serializer = self.get_serializer(obj) |
| 5075 | return Response(serializer.data) |
| 5076 | """ |
| 5077 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5078 | |
| 5079 | |
| 5080 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 5081 | queryset = DeploymentRole.objects.select_related().all() |
| 5082 | serializer_class = DeploymentRoleSerializer |
| 5083 | id_serializer_class = DeploymentRoleIdSerializer |
| 5084 | filter_backends = (filters.DjangoFilterBackend,) |
| 5085 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5086 | |
| 5087 | def get_serializer_class(self): |
| 5088 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5089 | if (no_hyperlinks): |
| 5090 | return self.id_serializer_class |
| 5091 | else: |
| 5092 | return self.serializer_class |
| 5093 | |
| 5094 | def get_queryset(self): |
| 5095 | return DeploymentRole.select_by_user(self.request.user) |
| 5096 | |
| 5097 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5098 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5099 | if not (serializer.is_valid()): |
| 5100 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 5101 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5102 | obj.caller = request.user |
| 5103 | if obj.can_update(request.user): |
| 5104 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
| 5105 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5106 | raise Exception("failed obj.can_update") |
| 5107 | |
| 5108 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
| 5109 | if (ret.status_code%100 != 200): |
| 5110 | raise Exception(ret.data) |
| 5111 | |
| 5112 | return ret |
| 5113 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5114 | |
| 5115 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5116 | queryset = DeploymentRole.objects.select_related().all() |
| 5117 | serializer_class = DeploymentRoleSerializer |
| 5118 | id_serializer_class = DeploymentRoleIdSerializer |
| 5119 | |
| 5120 | def get_serializer_class(self): |
| 5121 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5122 | if (no_hyperlinks): |
| 5123 | return self.id_serializer_class |
| 5124 | else: |
| 5125 | return self.serializer_class |
| 5126 | |
| 5127 | def get_queryset(self): |
| 5128 | return DeploymentRole.select_by_user(self.request.user) |
| 5129 | |
| 5130 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5131 | |
| 5132 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5133 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5134 | """ |
| 5135 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 5136 | filled with defaults. I solved it another way, so this code may soon be |
| 5137 | abandoned. |
| 5138 | |
| 5139 | class DeploymentRoleNew(GenericAPIView): |
| 5140 | serializer_class = DeploymentRoleSerializer |
| 5141 | id_serializer_class = DeploymentRoleIdSerializer |
| 5142 | |
| 5143 | def get(self, request, *args, **kwargs): |
| 5144 | return self.makenew(request, *args, **kwargs) |
| 5145 | |
| 5146 | def get_serializer_class(self): |
| 5147 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5148 | if (no_hyperlinks): |
| 5149 | return self.id_serializer_class |
| 5150 | else: |
| 5151 | return self.serializer_class |
| 5152 | |
| 5153 | def makenew(self, request, *args, **kwargs): |
| 5154 | obj = DeploymentRole() |
| 5155 | serializer = self.get_serializer(obj) |
| 5156 | return Response(serializer.data) |
| 5157 | """ |
| 5158 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5159 | |
| 5160 | |
| 5161 | class UserCredentialList(generics.ListCreateAPIView): |
| 5162 | queryset = UserCredential.objects.select_related().all() |
| 5163 | serializer_class = UserCredentialSerializer |
| 5164 | id_serializer_class = UserCredentialIdSerializer |
| 5165 | filter_backends = (filters.DjangoFilterBackend,) |
| 5166 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 5167 | |
| 5168 | def get_serializer_class(self): |
| 5169 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5170 | if (no_hyperlinks): |
| 5171 | return self.id_serializer_class |
| 5172 | else: |
| 5173 | return self.serializer_class |
| 5174 | |
| 5175 | def get_queryset(self): |
| 5176 | return UserCredential.select_by_user(self.request.user) |
| 5177 | |
| 5178 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5179 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5180 | if not (serializer.is_valid()): |
| 5181 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 5182 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5183 | obj.caller = request.user |
| 5184 | if obj.can_update(request.user): |
| 5185 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5186 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5187 | raise Exception("failed obj.can_update") |
| 5188 | |
| 5189 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5190 | if (ret.status_code%100 != 200): |
| 5191 | raise Exception(ret.data) |
| 5192 | |
| 5193 | return ret |
| 5194 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5195 | |
| 5196 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5197 | queryset = UserCredential.objects.select_related().all() |
| 5198 | serializer_class = UserCredentialSerializer |
| 5199 | id_serializer_class = UserCredentialIdSerializer |
| 5200 | |
| 5201 | def get_serializer_class(self): |
| 5202 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5203 | if (no_hyperlinks): |
| 5204 | return self.id_serializer_class |
| 5205 | else: |
| 5206 | return self.serializer_class |
| 5207 | |
| 5208 | def get_queryset(self): |
| 5209 | return UserCredential.select_by_user(self.request.user) |
| 5210 | |
| 5211 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5212 | |
| 5213 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5214 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5215 | """ |
| 5216 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 5217 | filled with defaults. I solved it another way, so this code may soon be |
| 5218 | abandoned. |
| 5219 | |
| 5220 | class UserCredentialNew(GenericAPIView): |
| 5221 | serializer_class = UserCredentialSerializer |
| 5222 | id_serializer_class = UserCredentialIdSerializer |
| 5223 | |
| 5224 | def get(self, request, *args, **kwargs): |
| 5225 | return self.makenew(request, *args, **kwargs) |
| 5226 | |
| 5227 | def get_serializer_class(self): |
| 5228 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5229 | if (no_hyperlinks): |
| 5230 | return self.id_serializer_class |
| 5231 | else: |
| 5232 | return self.serializer_class |
| 5233 | |
| 5234 | def makenew(self, request, *args, **kwargs): |
| 5235 | obj = UserCredential() |
| 5236 | serializer = self.get_serializer(obj) |
| 5237 | return Response(serializer.data) |
| 5238 | """ |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5239 | |
| 5240 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5241 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5242 | class SiteDeploymentsList(generics.ListCreateAPIView): |
| 5243 | queryset = SiteDeployments.objects.select_related().all() |
| 5244 | serializer_class = SiteDeploymentsSerializer |
| 5245 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5246 | filter_backends = (filters.DjangoFilterBackend,) |
| 5247 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',) |
| 5248 | |
| 5249 | def get_serializer_class(self): |
| 5250 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5251 | if (no_hyperlinks): |
| 5252 | return self.id_serializer_class |
| 5253 | else: |
| 5254 | return self.serializer_class |
| 5255 | |
| 5256 | def get_queryset(self): |
| 5257 | return SiteDeployments.select_by_user(self.request.user) |
| 5258 | |
| 5259 | def create(self, request, *args, **kwargs): |
| 5260 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5261 | if not (serializer.is_valid()): |
| 5262 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 5263 | obj = serializer.object |
| 5264 | obj.caller = request.user |
| 5265 | if obj.can_update(request.user): |
| 5266 | return super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 5267 | else: |
| 5268 | raise Exception("failed obj.can_update") |
| 5269 | |
| 5270 | ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 5271 | if (ret.status_code%100 != 200): |
| 5272 | raise Exception(ret.data) |
| 5273 | |
| 5274 | return ret |
| 5275 | |
| 5276 | |
| 5277 | class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5278 | queryset = SiteDeployments.objects.select_related().all() |
| 5279 | serializer_class = SiteDeploymentsSerializer |
| 5280 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5281 | |
| 5282 | def get_serializer_class(self): |
| 5283 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5284 | if (no_hyperlinks): |
| 5285 | return self.id_serializer_class |
| 5286 | else: |
| 5287 | return self.serializer_class |
| 5288 | |
| 5289 | def get_queryset(self): |
| 5290 | return SiteDeployments.select_by_user(self.request.user) |
| 5291 | |
| 5292 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5293 | |
| 5294 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5295 | |
| 5296 | """ |
| 5297 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 5298 | filled with defaults. I solved it another way, so this code may soon be |
| 5299 | abandoned. |
| 5300 | |
| 5301 | class SiteDeploymentsNew(GenericAPIView): |
| 5302 | serializer_class = SiteDeploymentsSerializer |
| 5303 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5304 | |
| 5305 | def get(self, request, *args, **kwargs): |
| 5306 | return self.makenew(request, *args, **kwargs) |
| 5307 | |
| 5308 | def get_serializer_class(self): |
| 5309 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5310 | if (no_hyperlinks): |
| 5311 | return self.id_serializer_class |
| 5312 | else: |
| 5313 | return self.serializer_class |
| 5314 | |
| 5315 | def makenew(self, request, *args, **kwargs): |
| 5316 | obj = SiteDeployments() |
| 5317 | serializer = self.get_serializer(obj) |
| 5318 | return Response(serializer.data) |
| 5319 | """ |
| 5320 | |
| 5321 | |
| 5322 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5323 | class SliceTagList(generics.ListCreateAPIView): |
| 5324 | queryset = SliceTag.objects.select_related().all() |
| 5325 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5326 | id_serializer_class = SliceTagIdSerializer |
| 5327 | filter_backends = (filters.DjangoFilterBackend,) |
| 5328 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 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 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5337 | def get_queryset(self): |
| 5338 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5339 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5340 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5341 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5342 | if not (serializer.is_valid()): |
| 5343 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 5344 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5345 | obj.caller = request.user |
| 5346 | if obj.can_update(request.user): |
| 5347 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 5348 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5349 | raise Exception("failed obj.can_update") |
| 5350 | |
| 5351 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 5352 | if (ret.status_code%100 != 200): |
| 5353 | raise Exception(ret.data) |
| 5354 | |
| 5355 | return ret |
| 5356 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5357 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5358 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5359 | queryset = SliceTag.objects.select_related().all() |
| 5360 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5361 | id_serializer_class = SliceTagIdSerializer |
| 5362 | |
| 5363 | def get_serializer_class(self): |
| 5364 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5365 | if (no_hyperlinks): |
| 5366 | return self.id_serializer_class |
| 5367 | else: |
| 5368 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5369 | |
| 5370 | def get_queryset(self): |
| 5371 | return SliceTag.select_by_user(self.request.user) |
| 5372 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5373 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5374 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5375 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5376 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5377 | """ |
| 5378 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 5379 | filled with defaults. I solved it another way, so this code may soon be |
| 5380 | abandoned. |
| 5381 | |
| 5382 | class SliceTagNew(GenericAPIView): |
| 5383 | serializer_class = SliceTagSerializer |
| 5384 | id_serializer_class = SliceTagIdSerializer |
| 5385 | |
| 5386 | def get(self, request, *args, **kwargs): |
| 5387 | return self.makenew(request, *args, **kwargs) |
| 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 makenew(self, request, *args, **kwargs): |
| 5397 | obj = SliceTag() |
| 5398 | serializer = self.get_serializer(obj) |
| 5399 | return Response(serializer.data) |
| 5400 | """ |
| 5401 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5402 | |
| 5403 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5404 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 5405 | queryset = NetworkTemplate.objects.select_related().all() |
| 5406 | serializer_class = NetworkTemplateSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5407 | id_serializer_class = NetworkTemplateIdSerializer |
| 5408 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 5409 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5410 | |
| 5411 | def get_serializer_class(self): |
| 5412 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5413 | if (no_hyperlinks): |
| 5414 | return self.id_serializer_class |
| 5415 | else: |
| 5416 | return self.serializer_class |
| 5417 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5418 | def get_queryset(self): |
| 5419 | return NetworkTemplate.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5420 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5421 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5422 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5423 | if not (serializer.is_valid()): |
| 5424 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 5425 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5426 | obj.caller = request.user |
| 5427 | if obj.can_update(request.user): |
| 5428 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 5429 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5430 | raise Exception("failed obj.can_update") |
| 5431 | |
| 5432 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 5433 | if (ret.status_code%100 != 200): |
| 5434 | raise Exception(ret.data) |
| 5435 | |
| 5436 | return ret |
| 5437 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5438 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5439 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5440 | queryset = NetworkTemplate.objects.select_related().all() |
| 5441 | serializer_class = NetworkTemplateSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5442 | id_serializer_class = NetworkTemplateIdSerializer |
| 5443 | |
| 5444 | def get_serializer_class(self): |
| 5445 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5446 | if (no_hyperlinks): |
| 5447 | return self.id_serializer_class |
| 5448 | else: |
| 5449 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5450 | |
| 5451 | def get_queryset(self): |
| 5452 | return NetworkTemplate.select_by_user(self.request.user) |
| 5453 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5454 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5455 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5456 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5457 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5458 | """ |
| 5459 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 5460 | filled with defaults. I solved it another way, so this code may soon be |
| 5461 | abandoned. |
| 5462 | |
| 5463 | class NetworkTemplateNew(GenericAPIView): |
| 5464 | serializer_class = NetworkTemplateSerializer |
| 5465 | id_serializer_class = NetworkTemplateIdSerializer |
| 5466 | |
| 5467 | def get(self, request, *args, **kwargs): |
| 5468 | return self.makenew(request, *args, **kwargs) |
| 5469 | |
| 5470 | def get_serializer_class(self): |
| 5471 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5472 | if (no_hyperlinks): |
| 5473 | return self.id_serializer_class |
| 5474 | else: |
| 5475 | return self.serializer_class |
| 5476 | |
| 5477 | def makenew(self, request, *args, **kwargs): |
| 5478 | obj = NetworkTemplate() |
| 5479 | serializer = self.get_serializer(obj) |
| 5480 | return Response(serializer.data) |
| 5481 | """ |
| 5482 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5483 | |
| 5484 | |
| 5485 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5486 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5487 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5488 | id_serializer_class = RouterIdSerializer |
| 5489 | filter_backends = (filters.DjangoFilterBackend,) |
| 5490 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',) |
| 5491 | |
| 5492 | def get_serializer_class(self): |
| 5493 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5494 | if (no_hyperlinks): |
| 5495 | return self.id_serializer_class |
| 5496 | else: |
| 5497 | return self.serializer_class |
| 5498 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5499 | def get_queryset(self): |
| 5500 | return Router.select_by_user(self.request.user) |
| 5501 | |
| 5502 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5503 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5504 | if not (serializer.is_valid()): |
| 5505 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 5506 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5507 | obj.caller = request.user |
| 5508 | if obj.can_update(request.user): |
| 5509 | return super(RouterList, self).create(request, *args, **kwargs) |
| 5510 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5511 | raise Exception("failed obj.can_update") |
| 5512 | |
| 5513 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 5514 | if (ret.status_code%100 != 200): |
| 5515 | raise Exception(ret.data) |
| 5516 | |
| 5517 | return ret |
| 5518 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5519 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5520 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5521 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5522 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5523 | id_serializer_class = RouterIdSerializer |
| 5524 | |
| 5525 | def get_serializer_class(self): |
| 5526 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5527 | if (no_hyperlinks): |
| 5528 | return self.id_serializer_class |
| 5529 | else: |
| 5530 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5531 | |
| 5532 | def get_queryset(self): |
| 5533 | return Router.select_by_user(self.request.user) |
| 5534 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5535 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5536 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5537 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5538 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5539 | """ |
| 5540 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 5541 | filled with defaults. I solved it another way, so this code may soon be |
| 5542 | abandoned. |
| 5543 | |
| 5544 | class RouterNew(GenericAPIView): |
| 5545 | serializer_class = RouterSerializer |
| 5546 | id_serializer_class = RouterIdSerializer |
| 5547 | |
| 5548 | def get(self, request, *args, **kwargs): |
| 5549 | return self.makenew(request, *args, **kwargs) |
| 5550 | |
| 5551 | def get_serializer_class(self): |
| 5552 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5553 | if (no_hyperlinks): |
| 5554 | return self.id_serializer_class |
| 5555 | else: |
| 5556 | return self.serializer_class |
| 5557 | |
| 5558 | def makenew(self, request, *args, **kwargs): |
| 5559 | obj = Router() |
| 5560 | serializer = self.get_serializer(obj) |
| 5561 | return Response(serializer.data) |
| 5562 | """ |
| 5563 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5564 | |
| 5565 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5566 | class ServiceResourceList(generics.ListCreateAPIView): |
| 5567 | queryset = ServiceResource.objects.select_related().all() |
| 5568 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5569 | id_serializer_class = ServiceResourceIdSerializer |
| 5570 | filter_backends = (filters.DjangoFilterBackend,) |
| 5571 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 5572 | |
| 5573 | def get_serializer_class(self): |
| 5574 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5575 | if (no_hyperlinks): |
| 5576 | return self.id_serializer_class |
| 5577 | else: |
| 5578 | return self.serializer_class |
| 5579 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5580 | def get_queryset(self): |
| 5581 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5582 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5583 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5584 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5585 | if not (serializer.is_valid()): |
| 5586 | raise Exception("failed serializer.is_valid: " + str(serializer.errors)) |
| 5587 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5588 | obj.caller = request.user |
| 5589 | if obj.can_update(request.user): |
| 5590 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5591 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5592 | raise Exception("failed obj.can_update") |
| 5593 | |
| 5594 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5595 | if (ret.status_code%100 != 200): |
| 5596 | raise Exception(ret.data) |
| 5597 | |
| 5598 | return ret |
| 5599 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5600 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5601 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5602 | queryset = ServiceResource.objects.select_related().all() |
| 5603 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5604 | id_serializer_class = ServiceResourceIdSerializer |
| 5605 | |
| 5606 | def get_serializer_class(self): |
| 5607 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5608 | if (no_hyperlinks): |
| 5609 | return self.id_serializer_class |
| 5610 | else: |
| 5611 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5612 | |
| 5613 | def get_queryset(self): |
| 5614 | return ServiceResource.select_by_user(self.request.user) |
| 5615 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5616 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5617 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5618 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5619 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5620 | """ |
| 5621 | XXX smbaker: my intent was to create a view that would return 'new' objects |
| 5622 | filled with defaults. I solved it another way, so this code may soon be |
| 5623 | abandoned. |
| 5624 | |
| 5625 | class ServiceResourceNew(GenericAPIView): |
| 5626 | serializer_class = ServiceResourceSerializer |
| 5627 | id_serializer_class = ServiceResourceIdSerializer |
| 5628 | |
| 5629 | def get(self, request, *args, **kwargs): |
| 5630 | return self.makenew(request, *args, **kwargs) |
| 5631 | |
| 5632 | def get_serializer_class(self): |
| 5633 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5634 | if (no_hyperlinks): |
| 5635 | return self.id_serializer_class |
| 5636 | else: |
| 5637 | return self.serializer_class |
| 5638 | |
| 5639 | def makenew(self, request, *args, **kwargs): |
| 5640 | obj = ServiceResource() |
| 5641 | serializer = self.get_serializer(obj) |
| 5642 | return Response(serializer.data) |
| 5643 | """ |
| 5644 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5645 | |
| 5646 | |