Browse Source

[api] Moving urls into its own module

Romain Rigaux 4 năm trước cách đây
mục cha
commit
b37907bf5c

+ 31 - 0
desktop/core/src/desktop/api_public_urls.py

@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+
+from desktop import api_public
+
+if sys.version_info[0] > 2:
+  from django.urls import re_path
+else:
+  from django.conf.urls import url as re_path
+
+
+urlpatterns = [
+  re_path(r'^query/create_notebook/?$', api_public.create_notebook, name='create_notebook'),
+  # ...
+]

+ 2 - 7
desktop/core/src/desktop/urls.py

@@ -49,7 +49,7 @@ from desktop import appmanager
 from desktop import views as desktop_views
 from desktop import api as desktop_api
 from desktop import api2 as desktop_api2
-from desktop import api_public
+from desktop import api_public_urls
 from desktop.auth import views as desktop_auth_views
 from desktop.conf import METRICS, USE_NEW_EDITOR, ENABLE_DJANGO_DEBUG_TOOL, ANALYTICS, has_connectors, ENABLE_PROMETHEUS, SLACK
 from desktop.configuration import api as desktop_configuration_api
@@ -211,20 +211,15 @@ dynamic_patterns += [
   re_path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
   re_path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
   re_path('api/token/verify/', TokenVerifyView.as_view(), name='token_verify'),
-]
 
-dynamic_patterns += [
-  re_path(r'^api/v1/create_notebook/?$', api_public.create_notebook, name='create_notebook'),
-  # ...
+  re_path(r'^api/', include('desktop.api_public_urls')),
 ]
 
-
 dynamic_patterns += [
   re_path(r'^desktop/api/vcs/contents/?$', desktop_lib_vcs_api.contents),
   re_path(r'^desktop/api/vcs/authorize/?$', desktop_lib_vcs_api.authorize),
 ]
 
-# Metrics specific
 if METRICS.ENABLE_WEB_METRICS.get():
   dynamic_patterns += [
     re_path(r'^desktop/metrics/?', include('desktop.lib.metrics.urls'))