Skip to content

Commit ca0b18b

Browse files
bennychendengyh
authored andcommitted
feat: 新增 private openapi
1 parent 1286b41 commit ca0b18b

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

  • bk-plugin-framework/bk_plugin_framework/services/bpf_service

bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/support-files/resources.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,40 @@ paths:
187187
disabledStages: []
188188
descriptionEn: Plugin open API entry
189189

190+
/bk_plugin/private/:
191+
x-bk-apigateway-method-any:
192+
operationId: plugin_private
193+
summary: 插件私有API
194+
description: 插件私有 API 入口,支持子路径匹配
195+
tags:
196+
- private
197+
responses:
198+
default:
199+
description: '插件私有API响应'
200+
x-bk-apigateway-resource:
201+
isPublic: true
202+
allowApplyPermission: true
203+
matchSubpath: true
204+
backend:
205+
type: HTTP
206+
name: default
207+
method: any
208+
{% if settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH %}
209+
path: /{env.api_sub_path}/bk_plugin/private/
210+
{% else %}
211+
path: /bk_plugin/private/
212+
{% endif %}
213+
matchSubpath: true
214+
timeout: 0
215+
upstreams: {}
216+
transformHeaders: {}
217+
authConfig:
218+
userVerifiedRequired: true
219+
appVerifiedRequired: true
220+
resourcePermissionRequired: false
221+
disabledStages: []
222+
descriptionEn: Plugin private API entry
223+
190224
/plugin_api_dispatch:
191225
post:
192226
operationId: plugin_api_dispatch

bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
PLUGIN_API_URLS_MODULE = "bk_plugin.apis.urls"
2121
PLUGIN_OPENAPI_URLS_MODULE = "bk_plugin.openapi.urls"
22+
PLUGIN_PRIVATE_URLS_MODULE = "bk_plugin.private.urls"
2223

2324
urlpatterns = [
2425
# 协议层接口(与平台方对接)
@@ -52,3 +53,12 @@
5253
else:
5354
sys.stdout.write("[!]plugin openapi urls module found\n")
5455
urlpatterns.append(path(r"openapi/", include(PLUGIN_OPENAPI_URLS_MODULE)))
56+
57+
# add plugin private
58+
try:
59+
importlib.import_module(PLUGIN_PRIVATE_URLS_MODULE)
60+
except ModuleNotFoundError:
61+
sys.stdout.write("[!]can not find plugin private urls module, skip it\n")
62+
else:
63+
sys.stdout.write("[!]plugin private urls module found\n")
64+
urlpatterns.append(path(r"private/", include(PLUGIN_PRIVATE_URLS_MODULE)))

0 commit comments

Comments
 (0)