add endpoints for autogenerated api in the new place
diff --git a/xos/tools/apigen/api.template.py b/xos/tools/apigen/api.template.py
index 9bd5a22..de733e8 100644
--- a/xos/tools/apigen/api.template.py
+++ b/xos/tools/apigen/api.template.py
@@ -36,14 +36,29 @@
def get_REST_patterns():
return patterns('',
+ # legacy - deprecated
url(r'^xos/$', api_root),
{% for object in generator.all %}
- url(r'xos/{{ object.rest_name }}/$', {{ object.camel }}List.as_view(), name='{{ object.singular }}-list'),
- url(r'xos/{{ object.rest_name }}/(?P<pk>[a-zA-Z0-9\-]+)/$', {{ object.camel }}Detail.as_view(), name ='{{ object.singular }}-detail'),
+ url(r'xos/{{ object.rest_name }}/$', {{ object.camel }}List.as_view(), name='{{ object.singular }}-list-legacy'),
+ url(r'xos/{{ object.rest_name }}/(?P<pk>[a-zA-Z0-9\-]+)/$', {{ object.camel }}Detail.as_view(), name ='{{ object.singular }}-detail-legacy'),
+ {% endfor %}
+ ) + patterns('',
+ # new - use these instead of the above
+ url(r'^api/core/$', api_root),
+ {% for object in generator.all %}
+ url(r'api/core/{{ object.rest_name }}/$', {{ object.camel }}List.as_view(), name='{{ object.singular }}-list'),
+ url(r'api/core/{{ object.rest_name }}/(?P<pk>[a-zA-Z0-9\-]+)/$', {{ object.camel }}Detail.as_view(), name ='{{ object.singular }}-detail'),
{% endfor %}
)
@api_view(['GET'])
+def api_root_legacy(request, format=None):
+ return Response({
+ {% for object in generator.all %}'{{ object.plural }}': reverse('{{ object }}-list-legacy', request=request, format=format),
+ {% endfor %}
+ })
+
+@api_view(['GET'])
def api_root(request, format=None):
return Response({
{% for object in generator.all %}'{{ object.plural }}': reverse('{{ object }}-list', request=request, format=format),
@@ -172,8 +187,8 @@
def get_serializer_class(self):
no_hyperlinks=False
- if hasattr(self.request,"QUERY_PARAMS"):
- no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
+ if hasattr(self.request,"query_params"):
+ no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
if (no_hyperlinks):
return self.id_serializer_class
else:
@@ -192,8 +207,8 @@
def get_serializer_class(self):
no_hyperlinks=False
- if hasattr(self.request,"QUERY_PARAMS"):
- no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
+ if hasattr(self.request,"query_params"):
+ no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
if (no_hyperlinks):
return self.id_serializer_class
else:
diff --git a/xos/tools/apigen/hpc-api.template.py b/xos/tools/apigen/hpc-api.template.py
index 56aa074..2bb8b8a 100644
--- a/xos/tools/apigen/hpc-api.template.py
+++ b/xos/tools/apigen/hpc-api.template.py
@@ -36,14 +36,28 @@
def get_hpc_REST_patterns():
return patterns('',
- url(r'^hpcapi/$', hpc_api_root),
+ url(r'^hpcapi/$', hpc_api_root_legacy),
+ # legacy - deprecated
{% for object in generator.rest_models %}
- url(r'hpcapi/{{ object.rest_name }}/$', {{ object.camel }}List.as_view(), name='{{ object.singular }}-list'),
- url(r'hpcapi/{{ object.rest_name }}/(?P<pk>[a-zA-Z0-9\-]+)/$', {{ object.camel }}Detail.as_view(), name ='{{ object.singular }}-detail'),
+ url(r'hpcapi/{{ object.rest_name }}/$', {{ object.camel }}List.as_view(), name='{{ object.singular }}-list-legacy'),
+ url(r'hpcapi/{{ object.rest_name }}/(?P<pk>[a-zA-Z0-9\-]+)/$', {{ object.camel }}Detail.as_view(), name ='{{ object.singular }}-detail-legacy'),
+ {% endfor %}
+ # new api - use these
+ url(r'^api/service/hpc/$', hpc_api_root),
+ {% for object in generator.rest_models %}
+ url(r'api/service/hpc/{{ object.rest_name }}/$', {{ object.camel }}List.as_view(), name='{{ object.singular }}-list'),
+ url(r'api/service/hpc/{{ object.rest_name }}/(?P<pk>[a-zA-Z0-9\-]+)/$', {{ object.camel }}Detail.as_view(), name ='{{ object.singular }}-detail'),
{% endfor %}
)
@api_view(['GET'])
+def hpc_api_root_legacy(request, format=None):
+ return Response({
+ {% for object in generator.rest_models %}'{{ object.plural }}': reverse('{{ object }}-list-legacy', request=request, format=format),
+ {% endfor %}
+ })
+
+@api_view(['GET'])
def hpc_api_root(request, format=None):
return Response({
{% for object in generator.rest_models %}'{{ object.plural }}': reverse('{{ object }}-list', request=request, format=format),
@@ -172,8 +186,8 @@
def get_serializer_class(self):
no_hyperlinks=False
- if hasattr(self.request,"QUERY_PARAMS"):
- no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
+ if hasattr(self.request,"query_params"):
+ no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
if (no_hyperlinks):
return self.id_serializer_class
else:
@@ -192,8 +206,8 @@
def get_serializer_class(self):
no_hyperlinks=False
- if hasattr(self.request,"QUERY_PARAMS"):
- no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
+ if hasattr(self.request,"query_params"):
+ no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
if (no_hyperlinks):
return self.id_serializer_class
else: