summaryrefslogtreecommitdiffstats
path: root/windriver/titanium_cloud/swagger
diff options
context:
space:
mode:
Diffstat (limited to 'windriver/titanium_cloud/swagger')
-rw-r--r--windriver/titanium_cloud/swagger/tests.py2
-rw-r--r--windriver/titanium_cloud/swagger/urls.py16
-rw-r--r--windriver/titanium_cloud/swagger/views.py60
3 files changed, 74 insertions, 4 deletions
diff --git a/windriver/titanium_cloud/swagger/tests.py b/windriver/titanium_cloud/swagger/tests.py
index 83fe5409..fde26217 100644
--- a/windriver/titanium_cloud/swagger/tests.py
+++ b/windriver/titanium_cloud/swagger/tests.py
@@ -26,7 +26,7 @@ class SampleViewTest(unittest.TestCase):
pass
def test_sample(self):
- response = self.client.get("/api/multicloud-titanium_cloud/v0/swagger.json")
+ response = self.client.get("/api/multicloud-titaniumcloud/v0/swagger.json")
self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
# resp_data = response.json()
# self.assertEqual({"status": "active"}, resp_data)
diff --git a/windriver/titanium_cloud/swagger/urls.py b/windriver/titanium_cloud/swagger/urls.py
index 723777dc..38573d58 100644
--- a/windriver/titanium_cloud/swagger/urls.py
+++ b/windriver/titanium_cloud/swagger/urls.py
@@ -15,10 +15,24 @@
from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
+from titanium_cloud.swagger.views import SwaggerJsonViewDepreciated
+from titanium_cloud.swagger.views import APIv1SwaggerJsonViewDepreciated
from titanium_cloud.swagger.views import SwaggerJsonView
+from titanium_cloud.swagger.views import APIv1SwaggerJsonView
urlpatterns = [
- url(r'^api/multicloud-titanium_cloud/v0/swagger.json$', SwaggerJsonView.as_view()),
+ # API v0, depreciated
+ url(r'^api/multicloud-titanium_cloud/v0/swagger.json$', SwaggerJsonViewDepreciated.as_view()),
+
+ # API v1, depreciated
+ url(r'^api/multicloud-titanium_cloud/v1/swagger.json$', APIv1SwaggerJsonViewDepreciated.as_view()),
+
+ # API v0, new namespace: MULTICLOUD-335
+ url(r'^api/multicloud-titaniumcloud/v0/swagger.json$', SwaggerJsonView.as_view()),
+
+ # API v1, new namespace: MULTICLOUD-335
+ url(r'^api/multicloud-titaniumcloud/v1/swagger.json$', APIv1SwaggerJsonView.as_view()),
+
]
urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/windriver/titanium_cloud/swagger/views.py b/windriver/titanium_cloud/swagger/views.py
index e912b751..6829714b 100644
--- a/windriver/titanium_cloud/swagger/views.py
+++ b/windriver/titanium_cloud/swagger/views.py
@@ -27,6 +27,45 @@ from newton_base.swagger import views as newton_json_view
logger = logging.getLogger(__name__)
+class SwaggerJsonViewDepreciated(newton_json_view.SwaggerJsonView):
+
+ def get(self, request):
+ '''
+ reuse newton code and update the basePath
+ :param request:
+ :return:
+ '''
+
+ resp = super(SwaggerJsonViewDepreciated,self).get(request)
+ json_data = resp.data if resp else None
+ if json_data:
+ json_data["basePath"] = "/api/multicloud-titanium_cloud/v0/"
+ json_data["info"]["title"] = "Depreciated Service NBI of MultiCloud plugin for Titanium Cloud"
+ return Response(data=json_data, status=200)
+ else:
+ return Response(data={'error':'internal error'}, status=500)
+
+
+
+class APIv1SwaggerJsonViewDepreciated(newton_json_view.SwaggerJsonView):
+
+ def get(self, request):
+ '''
+ reuse newton code and update the basePath
+ :param request:
+ :return:
+ '''
+
+ resp = super(APIv1SwaggerJsonViewDepreciated,self).get(request)
+ json_data = resp.data if resp else None
+ if json_data:
+ json_data["basePath"] = "/api/multicloud-titanium_cloud/v1/"
+ json_data["info"]["title"] = "Depreciated Service NBI v1 of MultiCloud plugin for Titanium Cloud"
+ return Response(data=json_data, status=200)
+ else:
+ return Response(data={'error':'internal error'}, status=500)
+
+
class SwaggerJsonView(newton_json_view.SwaggerJsonView):
def get(self, request):
@@ -39,10 +78,27 @@ class SwaggerJsonView(newton_json_view.SwaggerJsonView):
resp = super(SwaggerJsonView,self).get(request)
json_data = resp.data if resp else None
if json_data:
- json_data["basePath"] = "/api/multicloud-titanium_cloud/v0/"
- json_data["info"]["title"] = "Service NBI of MultiCloud plugin for Titanium Cloud"
+ json_data["basePath"] = "/api/multicloud-titaniumcloud/v0/"
+ json_data["info"]["title"] = "Service NBI v0 of MultiCloud plugin for Titanium Cloud"
return Response(data=json_data, status=200)
else:
return Response(data={'error':'internal error'}, status=500)
+class APIv1SwaggerJsonView(newton_json_view.SwaggerJsonView):
+
+ def get(self, request):
+ '''
+ reuse newton code and update the basePath
+ :param request:
+ :return:
+ '''
+
+ resp = super(APIv1SwaggerJsonView,self).get(request)
+ json_data = resp.data if resp else None
+ if json_data:
+ json_data["basePath"] = "/api/multicloud-titaniumcloud/v1/"
+ json_data["info"]["title"] = "Service NBI v1 of MultiCloud plugin for Titanium Cloud"
+ return Response(data=json_data, status=200)
+ else:
+ return Response(data={'error':'internal error'}, status=500)