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