Skip to content
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PluginCallback(APIView):
extensions=gen_apigateway_resource_config(
is_public=True,
allow_apply_permission=True,
user_verified_required=True,
user_verified_required=False,
app_verified_required=True,
resource_permission_required=True,
description_en="plugin callback",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Detail(APIView):
permission_classes = [permissions.AllowAny]

@extend_schema(
exclude=True,
summary="获取指定版本的插件详情",
operation_id="plugin_detail",
responses={200: standard_response_enveloper(DetailResponseSerializer)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Invoke(APIView):
extensions=gen_apigateway_resource_config(
is_public=True,
allow_apply_permission=True,
user_verified_required=True,
user_verified_required=False,
app_verified_required=True,
resource_permission_required=True,
description_en="Invoke specific version plugin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Logs(APIView):
permission_classes = [permissions.AllowAny]

@extend_schema(
exclude=True,
summary="获取插件执行日志",
operation_id="plugin_logs",
responses={200: standard_response_enveloper(LogsResponseSerializer)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Meta(APIView):
permission_classes = [permissions.AllowAny]

@extend_schema(
exclude=True,
summary="获取插件元信息",
operation_id="plugin_meta_info",
responses={200: standard_response_enveloper(MetaResponseSerializer)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class PluginAPIDispatch(APIView):
extensions=gen_apigateway_resource_config(
is_public=True,
allow_apply_permission=True,
user_verified_required=True,
user_verified_required=False,
app_verified_required=True,
resource_permission_required=True,
description_en="Plugin API dispatch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Schedule(APIView):
permission_classes = [permissions.AllowAny]

@extend_schema(
exclude=True,
summary="获取插件调度详情",
operation_id="plugin_schedule",
parameters=[ScheduleParamsSerializer],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
urlpatterns = [
path(r"meta/", api.Meta.as_view()),
path(r"detail/<str:version>", api.Detail.as_view()),
path(r"invoke/<str:version>", api.Invoke.as_view()),
path(r"schedule/<str:trace_id>", api.Schedule.as_view()),
path(r"plugin_api_dispatch/", api.PluginAPIDispatch.as_view()),
path(r"callback/<str:token>/", api.PluginCallback.as_view()),
]

# add log api
Expand Down
31 changes: 0 additions & 31 deletions runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,37 +238,6 @@ def logging_addition_settings(logging_dict):
}


def preprocessing_filter_internal_apis(endpoints):
"""
预处理钩子:排除不需要注册到 API 网关的内部 API
"""
# 需要排除的 API 路径模式
excluded_patterns = [
"/bk_plugin/detail",
"/bk_plugin/meta",
"/bk_plugin/logs",
"/bk_plugin/schedule",
]
filtered = []
for path, path_regex, method, callback in endpoints:
# 检查路径是否匹配排除模式
should_exclude = any(pattern in path for pattern in excluded_patterns)
if not should_exclude:
filtered.append((path, path_regex, method, callback))
return filtered


# drf_spectacular settings
SPECTACULAR_SETTINGS = {
"TITLE": "BK Plugin API",
"DESCRIPTION": "蓝鲸插件服务 API",
"VERSION": "1.0.0",
# 预处理钩子:排除内部 API
"PREPROCESSING_HOOKS": [
"bk_plugin_runtime.config.default.preprocessing_filter_internal_apis",
],
}

# 网关是否公开,公开则其他开发者可见/可申请权限
BK_APIGW_IS_PUBLIC = str(env.bool("BK_APIGW_IS_PUBLIC", default=True)).lower()
# if BK_APIGW_IS_OFFICIAL is True, the BK_APIGW_NAME should be start with `bk-`
Expand Down
7 changes: 6 additions & 1 deletion runtime/bk-plugin-runtime/bk_plugin_runtime/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

from django.conf import settings
from django.contrib import admin
from django.urls import include, re_path
from django.urls import include, path, re_path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions

from bk_plugin_framework.services.bpf_service import api

schema_view = get_schema_view(
openapi.Info(
title="PluginService API",
Expand All @@ -27,6 +29,9 @@


urlpatterns = [
path(r"plugin_api_dispatch/", api.PluginAPIDispatch.as_view()),
path(r"callback/<str:token>/", api.PluginCallback.as_view()),
path(r"invoke/<str:version>/", api.Invoke.as_view()),
re_path(r"^admin/", admin.site.urls),
re_path(r"^account/", include("blueapps.account.urls")),
re_path(r"^i18n/", include("django.conf.urls.i18n")),
Expand Down
3 changes: 2 additions & 1 deletion template/{{cookiecutter.project_name}}/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ opentelemetry-proto==1.25.0
opentelemetry-sdk==1.25.0
opentelemetry-semantic-conventions==0.46b0
opentelemetry-util-http==0.46b0
# add your custom requirements below this line
# add your custom requirements below this line
django-environ==0.11.2