summaryrefslogtreecommitdiffstats
path: root/windriver/titanium_cloud/swagger
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2018-09-03 08:46:12 +0000
committerBin Yang <bin.yang@windriver.com>2018-09-03 08:46:12 +0000
commit0ac4f904fae7793a3909f6db34ad9b3c35a08c12 (patch)
treeac9239304a11abd8429f4f6e36ef407b51d012f5 /windriver/titanium_cloud/swagger
parent1a4ae5657da11a59bd5cbde5240450f5db69e379 (diff)
Add new namespace to workaround ISTIO hostname
ISTIO restrains the usage of _ in hostname Issue-ID: MULTICLOUD-335 Change-Id: I54c712aea1a95c6aaac7d50c3b07472730608503 Signed-off-by: Bin Yang <bin.yang@windriver.com>
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)