From a78f982b4a4c9c50dd8f117e99179b78cd5645f1 Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Mon, 29 Dec 2025 21:04:46 +0800 Subject: [PATCH 01/17] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=93=8D=E5=BA=94=E5=B0=81=E8=A3=85=20&&=20pre-commit?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flake8 | 29 + .pre-commit-config.yaml | 35 + bk-plugin-framework/.flake8 | 23 - bk-plugin-framework/bk_plugin/__init__.py | 1 - .../bk_plugin/versions/__init__.py | 1 - .../bk_plugin_framework/__init__.py | 1 - .../bk_plugin_framework/__version__.py | 1 - .../bk_plugin_framework/constants.py | 2 +- .../bk_plugin_framework/envs.py | 5 +- .../bk_plugin_framework/hub/__init__.py | 4 +- .../bk_plugin_framework/kit/__init__.py | 12 +- .../bk_plugin_framework/kit/api.py | 15 +- .../bk_plugin_framework/kit/authentication.py | 2 +- .../bk_plugin_framework/kit/decorators.py | 2 +- .../bk_plugin_framework/kit/plugin.py | 12 +- .../bk_plugin_framework/metrics.py | 13 +- .../bk_plugin_framework/runtime/__init__.py | 1 - .../runtime/callback/__init__.py | 1 - .../runtime/callback/api.py | 17 +- .../runtime/callback/apps.py | 1 - .../runtime/callback/celery/__init__.py | 1 - .../runtime/callback/celery/queues.py | 1 - .../runtime/callback/celery/tasks.py | 20 +- .../runtime/callback/migrations/__init__.py | 1 - .../bk_plugin_framework/runtime/callbacker.py | 1 - .../bk_plugin_framework/runtime/executor.py | 32 +- .../runtime/loghub/__init__.py | 1 - .../runtime/loghub/admin.py | 5 +- .../runtime/loghub/apps.py | 1 - .../bk_plugin_framework/runtime/loghub/log.py | 4 +- .../runtime/loghub/migrations/0001_initial.py | 1 - .../runtime/loghub/models.py | 2 - .../runtime/schedule/__init__.py | 1 - .../runtime/schedule/admin.py | 5 +- .../runtime/schedule/apps.py | 3 +- .../runtime/schedule/celery/__init__.py | 1 - .../runtime/schedule/celery/beat.py | 1 - .../runtime/schedule/celery/queues.py | 1 - .../runtime/schedule/celery/tasks.py | 8 +- .../schedule/migrations/0001_initial.py | 2 - .../runtime/schedule/migrations/__init__.py | 1 - .../runtime/schedule/models.py | 1 - .../runtime/schedule/utils.py | 4 +- .../bk_plugin_framework/serializers.py | 19 + .../bk_plugin_framework/services/__init__.py | 1 - .../services/bpf_service/__init__.py | 1 - .../services/bpf_service/admin.py | 1 - .../services/bpf_service/api/__init__.py | 7 +- .../services/bpf_service/api/callback.py | 13 +- .../services/bpf_service/api/detail.py | 20 +- .../services/bpf_service/api/invoke.py | 28 +- .../services/bpf_service/api/logs.py | 20 +- .../services/bpf_service/api/meta.py | 24 +- .../services/bpf_service/api/permissions.py | 4 +- .../bpf_service/api/plugin_api_dispatch.py | 33 +- .../services/bpf_service/api/schedule.py | 22 +- .../bpf_service/api/serializers/__init__.py | 1 - .../services/bpf_service/apps.py | 5 +- .../bpf_service/management/__init__.py | 1 - .../management/commands/__init__.py | 1 - .../management/commands/sync_plugin_apigw.py | 3 +- .../services/bpf_service/middlewares.py | 1 - .../bpf_service/migrations/__init__.py | 1 - .../services/bpf_service/urls.py | 7 +- .../management/commands/__init__.py | 1 - .../management/commands/rundebugserver.py | 1 - .../debug_panel/migrations/__init__.py | 1 - .../services/debug_panel/views.py | 4 +- .../bk_plugin_framework/utils/__init__.py | 1 - .../bk_plugin_framework/utils/local.py | 1 - .../bk_plugin_framework/utils/log.py | 1 - .../bk_plugin_framework/utils/module_load.py | 5 +- .../bk_plugin_framework/utils/validations.py | 2 - bk-plugin-framework/poetry.lock | 29 +- bk-plugin-framework/pyproject.toml | 3 +- bk-plugin-framework/tests/conftest.py | 4 +- bk-plugin-framework/tests/hub/__init__.py | 1 - bk-plugin-framework/tests/hub/test_hub.py | 1 - bk-plugin-framework/tests/kit/__init__.py | 1 - bk-plugin-framework/tests/kit/test_plugin.py | 11 +- bk-plugin-framework/tests/runtime/__init__.py | 1 - .../tests/runtime/callback/__init__.py | 1 - .../tests/runtime/callback/celery/__init__.py | 1 - .../runtime/callback/celery/test_tasks.py | 11 +- .../tests/runtime/callback/test_utils.py | 9 +- .../tests/runtime/schedule/__init__.py | 1 - .../tests/runtime/schedule/celery/__init__.py | 1 - .../runtime/schedule/celery/test_tasks.py | 5 +- .../tests/runtime/schedule/test_utils.py | 5 +- .../tests/runtime/test_executor.py | 11 +- bk-plugin-framework/tests/settings.py | 2 +- bk-plugin-framework/tests/utils/__init__.py | 1 - bk-plugin-framework/tests/utils/test_local.py | 1 - bk-plugin-framework/tests/utils/test_log.py | 2 +- .../tests/utils/test_validations.py | 1 - .../bk_plugin_runtime/__init__.py | 1 - .../bk_plugin_runtime/__version__.py | 1 - .../bk_plugin_runtime/config/__init__.py | 9 +- .../bk_plugin_runtime/config/default.py | 26 +- .../bk_plugin_runtime/config/dev.py | 7 +- .../bk_plugin_runtime/config/prod.py | 1 - .../bk_plugin_runtime/config/stag.py | 2 +- .../bk_plugin_runtime/manage.py | 1 - .../packages/apigw/backends.py | 1 - .../packages/open/blueking/__init__.py | 3 +- .../open/blueking/component/__init__.py | 1 - .../open/blueking/component/apis/__init__.py | 1 - .../open/blueking/component/apis/bk_login.py | 38 +- .../open/blueking/component/apis/bk_paas.py | 10 +- .../open/blueking/component/apis/cc.py | 868 ++++++++++-------- .../open/blueking/component/apis/cmsi.py | 53 +- .../open/blueking/component/apis/gse.py | 38 +- .../open/blueking/component/apis/itsm.py | 73 +- .../open/blueking/component/apis/job.py | 185 ++-- .../open/blueking/component/apis/jobv3.py | 171 ++-- .../blueking/component/apis/monitor_v3.py | 521 ++++++----- .../open/blueking/component/apis/sops.py | 227 +++-- .../blueking/component/apis/usermanage.py | 52 +- .../packages/open/blueking/component/base.py | 14 +- .../open/blueking/component/client.py | 9 +- .../open/blueking/component/collections.py | 25 +- .../open/blueking/component/compat.py | 1 - .../packages/open/blueking/component/conf.py | 5 +- .../open/blueking/component/exceptions.py | 7 +- .../open/blueking/component/shortcuts.py | 3 +- .../packages/open/blueking/component/utils.py | 9 +- .../open/blueking/tests/test_client.py | 72 +- .../open/blueking/tests/test_shortcuts.py | 30 +- .../open/blueking/tests/test_utils.py | 24 +- .../open/blueking/tests/utils/utils.py | 17 +- .../bk_plugin_runtime/settings.py | 4 +- .../bk_plugin_runtime/urls.py | 7 +- .../bk_plugin_runtime/wsgi.py | 1 - .../bin/manage.py | 1 - .../bk_plugin/__init__.py | 1 - .../bk_plugin/versions/v1_0_0.py | 8 +- 136 files changed, 1694 insertions(+), 1443 deletions(-) create mode 100644 .flake8 create mode 100644 .pre-commit-config.yaml delete mode 100644 bk-plugin-framework/.flake8 create mode 100644 bk-plugin-framework/bk_plugin_framework/serializers.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..f379160 --- /dev/null +++ b/.flake8 @@ -0,0 +1,29 @@ +[flake8] +ignore = F405, W503, E203 +exclude = + *migrations*, + # python related + *.pyc, + .git, + __pycache__, + */node_modules/* + ./static/* + ./blueking/* + */blueking/* + ./blueapps/* + */blueapps/* + ./pipeline/* + ./sites/* + ./config/default.py + ./scripts_tools/* + ./support-files/* + ./upgrade.py + ./iam/* + + +max-line-length=120 +max-complexity=26 +format=pylint +show_source=False +statistics=True +count=True \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3bc2b4c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +default_stages: [pre-commit] +repos: + - repo: https://github.com/asottile/pyupgrade + rev: v3.21.2 + hooks: + - id: pyupgrade + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-merge-conflict + + - repo: https://github.com/psf/black + rev: 25.12.0 + hooks: + - id: black + language_version: python3.10 + args: + - "--line-length=120" + + - repo: https://github.com/pycqa/isort + rev: 7.0.0 + hooks: + - id: isort + args: + - "--profile" + - "black" + + - repo: https://github.com/pycqa/flake8 + rev: 7.3.0 + hooks: + - id: flake8 + args: + - "--config" + - ".flake8" \ No newline at end of file diff --git a/bk-plugin-framework/.flake8 b/bk-plugin-framework/.flake8 deleted file mode 100644 index 8ec2e77..0000000 --- a/bk-plugin-framework/.flake8 +++ /dev/null @@ -1,23 +0,0 @@ -[flake8] -ignore = - ;W503 line break before binary operator - W503, - ;This behaviour may raise E203 whitespace before ':' warnings in style guide enforcement tools like Flake8. - ;Since E203 is not PEP 8 compliant, you should tell Flake8 to ignore these warnings. - E203, - C901 - -max-line-length = 120 -max-complexity = 25 - -; exclude file -exclude = - .tox, - .git, - __pycache__, - build, - dist, - *.pyc, - *.egg-info, - .cache, - .eggs \ No newline at end of file diff --git a/bk-plugin-framework/bk_plugin/__init__.py b/bk-plugin-framework/bk_plugin/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin/__init__.py +++ b/bk-plugin-framework/bk_plugin/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin/versions/__init__.py b/bk-plugin-framework/bk_plugin/versions/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin/versions/__init__.py +++ b/bk-plugin-framework/bk_plugin/versions/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/__init__.py b/bk-plugin-framework/bk_plugin_framework/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/__version__.py b/bk-plugin-framework/bk_plugin_framework/__version__.py index d1eff91..f752a36 100644 --- a/bk-plugin-framework/bk_plugin_framework/__version__.py +++ b/bk-plugin-framework/bk_plugin_framework/__version__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/constants.py b/bk-plugin-framework/bk_plugin_framework/constants.py index a1e4667..8b78e17 100644 --- a/bk-plugin-framework/bk_plugin_framework/constants.py +++ b/bk-plugin-framework/bk_plugin_framework/constants.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,6 +8,7 @@ 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. """ + from enum import Enum diff --git a/bk-plugin-framework/bk_plugin_framework/envs.py b/bk-plugin-framework/bk_plugin_framework/envs.py index a0973b0..dd3b6e7 100644 --- a/bk-plugin-framework/bk_plugin_framework/envs.py +++ b/bk-plugin-framework/bk_plugin_framework/envs.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,15 +8,17 @@ 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 os + import base64 import hashlib import logging +import os try: from pydantic.v1 import BaseSettings except ImportError: from pydantic import BaseSettings + from django.conf import settings as default_settings logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/hub/__init__.py b/bk-plugin-framework/bk_plugin_framework/hub/__init__.py index 4288c9e..d57ea25 100644 --- a/bk-plugin-framework/bk_plugin_framework/hub/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/hub/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,9 +9,10 @@ specific language governing permissions and limitations under the License. """ +import logging import os import typing -import logging + from bk_plugin_framework.utils.module_load import load_form_module_path logger = logging.getLogger("bk-plugin-framework") diff --git a/bk-plugin-framework/bk_plugin_framework/kit/__init__.py b/bk-plugin-framework/bk_plugin_framework/kit/__init__.py index 9f86e23..644678a 100644 --- a/bk-plugin-framework/bk_plugin_framework/kit/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/kit/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -14,13 +13,14 @@ from pydantic.v1 import Field except ImportError: from pydantic import Field # noqa + from bk_plugin_framework.kit.plugin import ( # noqa - Plugin, - InputsModel, + Callback, Context, - OutputsModel, ContextRequire, - State, - Callback, FormModel, + InputsModel, + OutputsModel, + Plugin, + State, ) diff --git a/bk-plugin-framework/bk_plugin_framework/kit/api.py b/bk-plugin-framework/bk_plugin_framework/kit/api.py index fb38f9a..cde5165 100644 --- a/bk-plugin-framework/bk_plugin_framework/kit/api.py +++ b/bk-plugin-framework/bk_plugin_framework/kit/api.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,18 +8,18 @@ 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 json -from django.utils.decorators import method_decorator -from django.conf import settings as default_settings -from rest_framework.views import APIView -from rest_framework.request import Request -from bkoauth import get_app_access_token from apigw_manager.apigw.decorators import apigw_require - from bk_plugin_framework.envs import settings -from bk_plugin_framework.kit.decorators import login_exempt, inject_user_token from bk_plugin_framework.kit.authentication import CsrfExemptSessionAuthentication +from bk_plugin_framework.kit.decorators import inject_user_token, login_exempt +from bkoauth import get_app_access_token +from django.conf import settings as default_settings +from django.utils.decorators import method_decorator +from rest_framework.request import Request +from rest_framework.views import APIView custom_authentication_classes = ( [ diff --git a/bk-plugin-framework/bk_plugin_framework/kit/authentication.py b/bk-plugin-framework/bk_plugin_framework/kit/authentication.py index 470291f..feb6137 100644 --- a/bk-plugin-framework/bk_plugin_framework/kit/authentication.py +++ b/bk-plugin-framework/bk_plugin_framework/kit/authentication.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,6 +8,7 @@ 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. """ + from rest_framework.authentication import SessionAuthentication diff --git a/bk-plugin-framework/bk_plugin_framework/kit/decorators.py b/bk-plugin-framework/bk_plugin_framework/kit/decorators.py index 621b7e2..b11e8ab 100644 --- a/bk-plugin-framework/bk_plugin_framework/kit/decorators.py +++ b/bk-plugin-framework/bk_plugin_framework/kit/decorators.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,6 +8,7 @@ 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. """ + from functools import wraps from bk_plugin_framework.envs import settings diff --git a/bk-plugin-framework/bk_plugin_framework/kit/plugin.py b/bk-plugin-framework/bk_plugin_framework/kit/plugin.py index 0fc951e..ca776b2 100644 --- a/bk-plugin-framework/bk_plugin_framework/kit/plugin.py +++ b/bk-plugin-framework/bk_plugin_framework/kit/plugin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,18 +9,21 @@ specific language governing permissions and limitations under the License. """ +import inspect import re import typing -import inspect try: from pydantic.v1 import BaseModel except ImportError: from pydantic import BaseModel -from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.constants import State -from bk_plugin_framework.runtime.callback.api import prepare_callback, CallbackPreparation +from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.runtime.callback.api import ( + CallbackPreparation, + prepare_callback, +) VALID_VERSION_PATTERN = re.compile(r"^[0-9]+\.[0-9]+\.[0-9][a-z0-9]*$") @@ -50,7 +52,7 @@ class ContextRequire(BaseModel): pass -class Callback(object): +class Callback: def __init__(self, callback_id: str = "", callback_data: dict = {}): self.id = callback_id self.data = callback_data diff --git a/bk-plugin-framework/bk_plugin_framework/metrics.py b/bk-plugin-framework/bk_plugin_framework/metrics.py index eb00914..8af3cd1 100644 --- a/bk-plugin-framework/bk_plugin_framework/metrics.py +++ b/bk-plugin-framework/bk_plugin_framework/metrics.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- import os import socket import time from functools import wraps -from prometheus_client import Counter, Histogram, Gauge +from prometheus_client import Counter, Gauge, Histogram def get_hostname(): @@ -129,14 +128,16 @@ def _wrapper(*args, **kwargs): # 正在执行的 EXECUTE 数量 BK_PLUGIN_EXECUTE_RUNNING_PROCESSES = Gauge( - name="bk_plugin_execute_running_processes", documentation="count running state processes", - labelnames=["hostname", "version"] + name="bk_plugin_execute_running_processes", + documentation="count running state processes", + labelnames=["hostname", "version"], ) # 正在执行的 SCHEDULE 数量 BK_PLUGIN_SCHEDULE_RUNNING_PROCESSES = Gauge( - name="bk_plugin_schedule_running_processes", documentation="count running state schedules", - labelnames=["hostname", "version"] + name="bk_plugin_schedule_running_processes", + documentation="count running state schedules", + labelnames=["hostname", "version"], ) # CALLBACK 异常次数 diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/__init__.py b/bk-plugin-framework/bk_plugin_framework/runtime/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/__init__.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/__init__.py index 9213cba..39de18e 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py index 45612ed..b95ecde 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,23 +8,23 @@ 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 uuid -import time + import json import logging +import time +import uuid -from django.conf import settings as default_settings -from celery import current_app -from cryptography.fernet import Fernet - +from bk_plugin_framework.constants import State from bk_plugin_framework.envs import settings from bk_plugin_framework.runtime.schedule.models import Schedule -from bk_plugin_framework.constants import State +from celery import current_app +from cryptography.fernet import Fernet +from django.conf import settings as default_settings logger = logging.getLogger("bk_plugin") -class CallbackPreparation(object): +class CallbackPreparation: def __init__(self, callback_id: str, callback_url: str): self.id = callback_id self.url = callback_url diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/apps.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/apps.py index 53f29c0..d347d7c 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/apps.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/apps.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/__init__.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/queues.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/queues.py index d94c210..9f5f2c1 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/queues.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/queues.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py index 4b3d03b..34fa830 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,21 +8,25 @@ 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 json import logging import random import time -from celery import shared_task, current_app - -from bk_plugin_framework.kit import State -from bk_plugin_framework.metrics import BK_PLUGIN_CALLBACK_EXCEPTION_COUNT, HOSTNAME, BK_PLUGIN_CALLBACK_TIME -from bk_plugin_framework.utils import local from bk_plugin_framework.envs import settings from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.kit import State +from bk_plugin_framework.metrics import ( + BK_PLUGIN_CALLBACK_EXCEPTION_COUNT, + BK_PLUGIN_CALLBACK_TIME, + HOSTNAME, +) from bk_plugin_framework.runtime.executor import BKPluginExecutor from bk_plugin_framework.runtime.schedule.models import Schedule from bk_plugin_framework.runtime.schedule.utils import get_schedule_lock +from bk_plugin_framework.utils import local +from celery import current_app, shared_task logger = logging.getLogger("bk_plugin") @@ -60,7 +63,7 @@ def callback(trace_id: str, callback_id: str, callback_data: str): if schedule.state is not State.CALLBACK.value: logger.exception( - "[callback_task] schedule state[%s] is not CALLBACK,trace_id[%s]" % (schedule.state, trace_id) + "[callback_task] schedule state[{}] is not CALLBACK,trace_id[{}]".format(schedule.state, trace_id) ) return @@ -80,4 +83,5 @@ def callback(trace_id: str, callback_id: str, callback_data: str): _set_schedule_state(trace_id=trace_id, state=State.FAIL) BK_PLUGIN_CALLBACK_TIME.labels(hostname=HOSTNAME, version=schedule.plugin_version).observe( - time.perf_counter() - start) + time.perf_counter() - start + ) diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/migrations/__init__.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/migrations/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/migrations/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/migrations/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callbacker.py b/bk-plugin-framework/bk_plugin_framework/runtime/callbacker.py index 85602ea..4119705 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callbacker.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callbacker.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import json import logging diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/executor.py b/bk-plugin-framework/bk_plugin_framework/runtime/executor.py index 2cc2031..6363f8e 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/executor.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/executor.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -11,8 +10,8 @@ """ import json -import typing import logging +import typing from celery import current_app @@ -20,25 +19,32 @@ from pydantic.v1 import ValidationError except ImportError: from pydantic import ValidationError -from django.utils.timezone import now -from bk_plugin_framework.kit import Plugin, Context, State, InputsModel, ContextRequire, Callback +from bk_plugin_framework.kit import ( + Callback, + Context, + ContextRequire, + InputsModel, + Plugin, + State, +) from bk_plugin_framework.kit.plugin import PluginCallbackModel from bk_plugin_framework.metrics import ( - HOSTNAME, - BK_PLUGIN_EXECUTE_FAILED_COUNT, BK_PLUGIN_EXECUTE_EXCEPTION_COUNT, - BK_PLUGIN_SCHEDULE_FAILED_COUNT, - BK_PLUGIN_SCHEDULE_EXCEPTION_COUNT, - setup_gauge, - setup_histogram, + BK_PLUGIN_EXECUTE_FAILED_COUNT, BK_PLUGIN_EXECUTE_RUNNING_PROCESSES, BK_PLUGIN_EXECUTE_TIME, + BK_PLUGIN_SCHEDULE_EXCEPTION_COUNT, + BK_PLUGIN_SCHEDULE_FAILED_COUNT, BK_PLUGIN_SCHEDULE_RUNNING_PROCESSES, BK_PLUGIN_SCHEDULE_TIME, + HOSTNAME, + setup_gauge, + setup_histogram, ) from bk_plugin_framework.runtime.callbacker import PluginCallbacker from bk_plugin_framework.runtime.schedule.models import Schedule +from django.utils.timezone import now logger = logging.getLogger("bk_plugin") @@ -179,7 +185,9 @@ def execute( return ExecuteResult(state=State.FAIL, outputs=None, err="schedule task dispatch error: %s" % str(e)) - logger.info("[execute] task delay success, task_id: %s, count_down: %s" % (task_id, plugin.poll_interval)) + logger.info( + "[execute] task delay success, task_id: {}, count_down: {}".format(task_id, plugin.poll_interval) + ) return ExecuteResult(state=state, outputs=context.outputs, err=None) @@ -315,7 +323,7 @@ def schedule(self, plugin_cls: Plugin, schedule: Schedule, callback_info: dict = queue="plugin_schedule", ) logger.info( - "[schedule] task delay success, task_id: %s, count_down: %s" % (task_id, plugin.poll_interval) + "[schedule] task delay success, task_id: {}, count_down: {}".format(task_id, plugin.poll_interval) ) except Exception: logger.exception("[schedule] schedule task dispatch error") diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/__init__.py b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/__init__.py index 28643c1..e7760c7 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/admin.py b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/admin.py index e2de9e4..c6e7966 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/admin.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/admin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,10 +9,8 @@ specific language governing permissions and limitations under the License. """ - -from django.contrib import admin - from bk_plugin_framework.runtime.loghub import models +from django.contrib import admin @admin.register(models.LogEntry) diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/apps.py b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/apps.py index 61503c8..687adfb 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/apps.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/apps.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/log.py b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/log.py index d3ff2c5..21dbaa1 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/log.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/log.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -13,9 +12,8 @@ import logging from logging import LogRecord -from django.core.exceptions import AppRegistryNotReady - from bk_plugin_framework.utils import local +from django.core.exceptions import AppRegistryNotReady class TraceContextLogHandler(logging.Handler): diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/migrations/0001_initial.py b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/migrations/0001_initial.py index 81028e7..ca0664a 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/migrations/0001_initial.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/models.py b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/models.py index a8bdcab..ed751cb 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/models.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,7 +9,6 @@ specific language governing permissions and limitations under the License. """ - from django.db import models diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/__init__.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/__init__.py index 3ad245c..639bfa8 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/admin.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/admin.py index e3375a8..367c311 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/admin.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/admin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,10 +9,8 @@ specific language governing permissions and limitations under the License. """ - -from django.contrib import admin - from bk_plugin_framework.runtime.schedule import models +from django.contrib import admin @admin.register(models.Schedule) diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/apps.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/apps.py index 849cbe5..0bc861d 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/apps.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/apps.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -17,4 +16,4 @@ class ScheduleConfig(AppConfig): name = "bk_plugin_framework.runtime.schedule" def ready(self): - from .celery.tasks import schedule, delete_expired_schedule # noqa + from .celery.tasks import delete_expired_schedule, schedule # noqa diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/__init__.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/beat.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/beat.py index f82ede6..c0ad07c 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/beat.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/beat.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/queues.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/queues.py index 97ffeed..a4f8bf6 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/queues.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/queues.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/tasks.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/tasks.py index d9c9f87..f5a9836 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/tasks.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/tasks.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -12,14 +11,13 @@ import logging -from celery import shared_task - -from bk_plugin_framework.kit import State -from bk_plugin_framework.utils import local from bk_plugin_framework.envs import settings from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.kit import State from bk_plugin_framework.runtime.executor import BKPluginExecutor from bk_plugin_framework.runtime.schedule.models import Schedule +from bk_plugin_framework.utils import local +from celery import shared_task logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/migrations/0001_initial.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/migrations/0001_initial.py index 2c3f480..842183b 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/migrations/0001_initial.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,7 +9,6 @@ specific language governing permissions and limitations under the License. """ - from django.db import migrations, models diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/migrations/__init__.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/migrations/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/migrations/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/migrations/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/models.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/models.py index 8399b33..98f269c 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/models.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/utils.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/utils.py index 8da5231..f6911d0 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/utils.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,10 +8,11 @@ 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. """ + from bk_plugin_framework.runtime.schedule.models import Schedule -class ScheduleLock(object): +class ScheduleLock: def __init__(self, trace_id: str): self.trace_id = trace_id self.locked = False diff --git a/bk-plugin-framework/bk_plugin_framework/serializers.py b/bk-plugin-framework/bk_plugin_framework/serializers.py new file mode 100644 index 0000000..36bcc49 --- /dev/null +++ b/bk-plugin-framework/bk_plugin_framework/serializers.py @@ -0,0 +1,19 @@ +from drf_spectacular.utils import extend_schema_serializer +from rest_framework import serializers + + +def enveloper(serializer_class, many: bool = False): + """统一响应包装器(参考您的模式)""" + component_name = "Enveloped{}{}".format( + serializer_class.__name__.replace("Serializer", ""), + "List" if many else "", + ) + + @extend_schema_serializer(many=False, component_name=component_name) + class EnvelopeSerializer(serializers.Serializer): + code = serializers.IntegerField(help_text="状态码,0表示成功") + data = serializer_class(many=many) + message = serializers.CharField(help_text="响应消息") + result = serializers.BooleanField(help_text="操作结果") + + return EnvelopeSerializer diff --git a/bk-plugin-framework/bk_plugin_framework/services/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/__init__.py index d6e8b03..544718d 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/admin.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/admin.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/admin.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/admin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/__init__.py index efa2fb7..c64bd9e 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,10 +9,10 @@ specific language governing permissions and limitations under the License. """ -from .meta import Meta # noqa +from .callback import PluginCallback # noqa from .detail import Detail # noqa from .invoke import Invoke # noqa from .logs import Logs # noqa -from .schedule import Schedule # noqa +from .meta import Meta # noqa from .plugin_api_dispatch import PluginAPIDispatch # noqa -from .callback import PluginCallback # noqa +from .schedule import Schedule # noqa diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py index 77d2c44..a1d1e42 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,19 +8,19 @@ 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 json import logging import traceback +from apigw_manager.apigw.decorators import apigw_require +from bk_plugin_framework.runtime.callback.api import callback, parse_callback_token +from blueapps.account.decorators import login_exempt +from django.utils.decorators import method_decorator from drf_yasg.utils import swagger_auto_schema from rest_framework.decorators import action -from rest_framework.views import APIView from rest_framework.response import Response -from django.utils.decorators import method_decorator -from blueapps.account.decorators import login_exempt -from apigw_manager.apigw.decorators import apigw_require - -from bk_plugin_framework.runtime.callback.api import parse_callback_token, callback +from rest_framework.views import APIView logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py index 90a5142..e3ff05b 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -12,18 +11,17 @@ import logging +from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) +from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator -from rest_framework import status -from rest_framework import permissions -from rest_framework import serializers -from rest_framework.views import APIView -from rest_framework.response import Response -from rest_framework.decorators import action from drf_yasg.utils import swagger_auto_schema -from blueapps.account.decorators import login_exempt - -from bk_plugin_framework.hub import VersionHub -from bk_plugin_framework.services.bpf_service.api.serializers import StandardResponseSerializer +from rest_framework import permissions, serializers, status +from rest_framework.decorators import action +from rest_framework.response import Response +from rest_framework.views import APIView logger = logging.getLogger("root") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py index 117e532..78f7221 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -12,22 +11,23 @@ import logging -from django.utils.decorators import method_decorator -from rest_framework import status -from rest_framework import serializers -from rest_framework.views import APIView -from rest_framework.response import Response -from rest_framework.decorators import action -from rest_framework.exceptions import ValidationError -from drf_yasg.utils import swagger_auto_schema -from blueapps.account.decorators import login_exempt from apigw_manager.apigw.decorators import apigw_require - - from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.runtime.executor import BKPluginExecutor -from bk_plugin_framework.services.bpf_service.api.permissions import ScopeAllowPermission -from bk_plugin_framework.services.bpf_service.api.serializers import StandardResponseSerializer +from bk_plugin_framework.services.bpf_service.api.permissions import ( + ScopeAllowPermission, +) +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) +from blueapps.account.decorators import login_exempt +from django.utils.decorators import method_decorator +from drf_yasg.utils import swagger_auto_schema +from rest_framework import serializers, status +from rest_framework.decorators import action +from rest_framework.exceptions import ValidationError +from rest_framework.response import Response +from rest_framework.views import APIView logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py index bd2fafc..8726ffc 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -12,18 +11,17 @@ import logging +from bk_plugin_framework.runtime.loghub.models import LogEntry +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) +from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator -from rest_framework import permissions -from rest_framework import serializers -from rest_framework.views import APIView -from rest_framework.response import Response -from rest_framework.decorators import action from drf_yasg.utils import swagger_auto_schema -from blueapps.account.decorators import login_exempt - - -from bk_plugin_framework.runtime.loghub.models import LogEntry -from bk_plugin_framework.services.bpf_service.api.serializers import StandardResponseSerializer +from rest_framework import permissions, serializers +from rest_framework.decorators import action +from rest_framework.response import Response +from rest_framework.views import APIView logger = logging.getLogger("root") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py index 9a451df..5f82b60 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -13,20 +12,19 @@ import logging from importlib import import_module -from django.utils.decorators import method_decorator -from django.conf import settings -from rest_framework import permissions -from rest_framework import serializers -from rest_framework.views import APIView -from rest_framework.response import Response -from rest_framework.decorators import action -from drf_yasg.utils import swagger_auto_schema -from blueapps.account.decorators import login_exempt - - from bk_plugin_framework import __version__ as bpf_version from bk_plugin_framework.hub import VersionHub -from bk_plugin_framework.services.bpf_service.api.serializers import StandardResponseSerializer +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) +from blueapps.account.decorators import login_exempt +from django.conf import settings +from django.utils.decorators import method_decorator +from drf_yasg.utils import swagger_auto_schema +from rest_framework import permissions, serializers +from rest_framework.decorators import action +from rest_framework.response import Response +from rest_framework.views import APIView logger = logging.getLogger("root") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/permissions.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/permissions.py index dd6f22d..8e776aa 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/permissions.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/permissions.py @@ -1,11 +1,9 @@ -# -*- coding: utf-8 -*- from importlib import import_module +from bk_plugin_framework.utils.validations import validate_allow_scope from rest_framework.permissions import BasePermission from rest_framework.request import Request -from bk_plugin_framework.utils.validations import validate_allow_scope - try: meta_module = import_module("bk_plugin.meta") except ImportError: diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py index 3686354..716daaa 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,27 +8,29 @@ 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 json import logging import re - from urllib.parse import urlsplit + +from apigw_manager.apigw.decorators import apigw_require +from bk_plugin_framework.services.bpf_service.api.permissions import ( + ScopeAllowPermission, +) +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) +from blueapps.account.decorators import login_exempt from django.test import RequestFactory -from django.urls import resolve, Resolver404 +from django.urls import Resolver404, resolve from django.utils.decorators import method_decorator -from rest_framework import status -from rest_framework import serializers -from rest_framework.views import APIView -from rest_framework.response import Response +from drf_yasg.utils import swagger_auto_schema +from rest_framework import serializers, status from rest_framework.decorators import action from rest_framework.exceptions import ValidationError -from drf_yasg.utils import swagger_auto_schema - -from blueapps.account.decorators import login_exempt -from apigw_manager.apigw.decorators import apigw_require - -from bk_plugin_framework.services.bpf_service.api.permissions import ScopeAllowPermission -from bk_plugin_framework.services.bpf_service.api.serializers import StandardResponseSerializer +from rest_framework.response import Response +from rest_framework.views import APIView logger = logging.getLogger("bk_plugin") @@ -64,7 +65,7 @@ class PluginAPIDispatchResponseSerializer(StandardResponseSerializer): data = serializers.DictField(help_text="DATA API 返回的数据") -class DummyUser(object): +class DummyUser: def __init__(self, username): self.username = username @@ -97,7 +98,7 @@ def post(self, request): try: parsed = urlsplit(request_data["url"]) - logger.info("url(%s) parsed: %s" % (request_data["url"], parsed)) + logger.info("url({}) parsed: {}".format(request_data["url"], parsed)) matched = resolve(parsed.path, urlconf=None) view_func, kwargs = matched.func, matched.kwargs diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py index 5f6034b..dd1c804 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -13,18 +12,17 @@ import json import logging +from bk_plugin_framework.runtime.schedule.models import Schedule as ScheduleModel +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) +from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator -from rest_framework import permissions -from rest_framework import serializers -from rest_framework.views import APIView -from rest_framework.response import Response -from rest_framework.decorators import action from drf_yasg.utils import swagger_auto_schema -from blueapps.account.decorators import login_exempt - - -from bk_plugin_framework.runtime.schedule.models import Schedule as ScheduleModel -from bk_plugin_framework.services.bpf_service.api.serializers import StandardResponseSerializer +from rest_framework import permissions, serializers +from rest_framework.decorators import action +from rest_framework.response import Response +from rest_framework.views import APIView logger = logging.getLogger("root") @@ -77,7 +75,7 @@ def get(self, request, trace_id): { "result": False, "data": None, - "message": "outputs fetch with trace_id %s error: %s" % (trace_id, str(e)), + "message": "outputs fetch with trace_id {} error: {}".format(trace_id, str(e)), "trace_id": request.trace_id, } ) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/serializers/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/serializers/__init__.py index 8a34026..6b8d4c8 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/serializers/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/serializers/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/apps.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/apps.py index bdc6d64..8cfee1a 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/apps.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/apps.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,12 +9,10 @@ specific language governing permissions and limitations under the License. """ - from importlib import import_module -from django.apps import AppConfig - from bk_plugin_framework.utils.module_load import discover_plugins +from django.apps import AppConfig class BpfServiceConfig(AppConfig): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_plugin_apigw.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_plugin_apigw.py index eb224ab..46c246b 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_plugin_apigw.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_plugin_apigw.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -13,8 +12,8 @@ import os from django.conf import settings -from django.core.management.base import BaseCommand from django.core.management import call_command +from django.core.management.base import BaseCommand class Command(BaseCommand): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/middlewares.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/middlewares.py index 58b725d..f6ead7c 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/middlewares.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/middlewares.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/migrations/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/migrations/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/migrations/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/migrations/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py index 7d8e248..ecdeaaa 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,12 +9,12 @@ specific language governing permissions and limitations under the License. """ -import sys import importlib +import sys -from django.urls import path, include -from bk_plugin_framework.services.bpf_service import api from bk_plugin_framework.envs import settings +from bk_plugin_framework.services.bpf_service import api +from django.urls import include, path PLUGIN_API_URLS_MODULE = "bk_plugin.apis.urls" PLUGIN_OPENAPI_URLS_MODULE = "bk_plugin.openapi.urls" diff --git a/bk-plugin-framework/bk_plugin_framework/services/debug_panel/management/commands/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/debug_panel/management/commands/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/debug_panel/management/commands/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/debug_panel/management/commands/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/debug_panel/management/commands/rundebugserver.py b/bk-plugin-framework/bk_plugin_framework/services/debug_panel/management/commands/rundebugserver.py index 4d3e774..047bb2e 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/debug_panel/management/commands/rundebugserver.py +++ b/bk-plugin-framework/bk_plugin_framework/services/debug_panel/management/commands/rundebugserver.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/debug_panel/migrations/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/debug_panel/migrations/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/debug_panel/migrations/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/services/debug_panel/migrations/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/services/debug_panel/views.py b/bk-plugin-framework/bk_plugin_framework/services/debug_panel/views.py index 61272dd..9ce2ccf 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/debug_panel/views.py +++ b/bk-plugin-framework/bk_plugin_framework/services/debug_panel/views.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,9 +9,8 @@ specific language governing permissions and limitations under the License. """ -from django.shortcuts import render - from blueapps.account.decorators import login_exempt +from django.shortcuts import render @login_exempt diff --git a/bk-plugin-framework/bk_plugin_framework/utils/__init__.py b/bk-plugin-framework/bk_plugin_framework/utils/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/bk_plugin_framework/utils/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/utils/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/utils/local.py b/bk-plugin-framework/bk_plugin_framework/utils/local.py index b6d7895..04aa5bf 100644 --- a/bk-plugin-framework/bk_plugin_framework/utils/local.py +++ b/bk-plugin-framework/bk_plugin_framework/utils/local.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/utils/log.py b/bk-plugin-framework/bk_plugin_framework/utils/log.py index 1e274ac..e521c25 100644 --- a/bk-plugin-framework/bk_plugin_framework/utils/log.py +++ b/bk-plugin-framework/bk_plugin_framework/utils/log.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/bk_plugin_framework/utils/module_load.py b/bk-plugin-framework/bk_plugin_framework/utils/module_load.py index 0190e0a..3fa6021 100644 --- a/bk-plugin-framework/bk_plugin_framework/utils/module_load.py +++ b/bk-plugin-framework/bk_plugin_framework/utils/module_load.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,11 +9,11 @@ specific language governing permissions and limitations under the License. """ +import logging import os +import pkgutil import sys import typing -import pkgutil -import logging from importlib import import_module logger = logging.getLogger("bk-plugin-framework") diff --git a/bk-plugin-framework/bk_plugin_framework/utils/validations.py b/bk-plugin-framework/bk_plugin_framework/utils/validations.py index a6440a7..3348c62 100644 --- a/bk-plugin-framework/bk_plugin_framework/utils/validations.py +++ b/bk-plugin-framework/bk_plugin_framework/utils/validations.py @@ -1,9 +1,7 @@ -# -*- coding: utf-8 -*- import logging import jsonschema - logger = logging.getLogger("bk-plugin-framework") diff --git a/bk-plugin-framework/poetry.lock b/bk-plugin-framework/poetry.lock index 2681369..c5200a0 100644 --- a/bk-plugin-framework/poetry.lock +++ b/bk-plugin-framework/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. [[package]] name = "amqp" @@ -1238,6 +1238,31 @@ files = [ [package.dependencies] django = ">=4.2" +[[package]] +name = "drf-spectacular" +version = "0.29.0" +description = "Sane and flexible OpenAPI 3 schema generation for Django REST framework" +optional = false +python-versions = ">=3.7" +groups = ["main"] +files = [ + {file = "drf_spectacular-0.29.0-py3-none-any.whl", hash = "sha256:d1ee7c9535d89848affb4427347f7c4a22c5d22530b8842ef133d7b72e19b41a"}, + {file = "drf_spectacular-0.29.0.tar.gz", hash = "sha256:0a069339ea390ce7f14a75e8b5af4a0860a46e833fd4af027411a3e94fc1a0cc"}, +] + +[package.dependencies] +Django = ">=2.2" +djangorestframework = ">=3.10.3" +inflection = ">=0.3.1" +jsonschema = ">=2.6.0" +PyYAML = ">=5.1" +typing-extensions = {version = "*", markers = "python_version < \"3.10\""} +uritemplate = ">=2.0.0" + +[package.extras] +offline = ["drf-spectacular-sidecar"] +sidecar = ["drf-spectacular-sidecar"] + [[package]] name = "drf-yasg" version = "1.21.10" @@ -4404,4 +4429,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.8.0,<4.0" -content-hash = "1164524473a272e2ef48520906ad465781ddae26f408c996b9596ff5b11c77fb" +content-hash = "728614741d8ba7bdbbcb5dbfe3aeaf43aaafae490f4767a3f88c3327d2903da1" diff --git a/bk-plugin-framework/pyproject.toml b/bk-plugin-framework/pyproject.toml index d6f5405..7e84021 100644 --- a/bk-plugin-framework/pyproject.toml +++ b/bk-plugin-framework/pyproject.toml @@ -12,8 +12,9 @@ werkzeug = ">=2.0.0, <4.0" apigw-manager = {version = ">=1.0.6, <4", extras = ["extra"]} bk-plugin-runtime = "2.1.2" jsonschema = ">=2.5.0,<5.0.0" +drf-spectacular = "^0.29.0" -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] pytest = "^7.0.0" black = "^20.8b1" pytest-django = "^4.5.2" diff --git a/bk-plugin-framework/tests/conftest.py b/bk-plugin-framework/tests/conftest.py index 51fa133..fb2a38f 100644 --- a/bk-plugin-framework/tests/conftest.py +++ b/bk-plugin-framework/tests/conftest.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -11,9 +10,8 @@ """ import pytest - -from bk_plugin_framework.utils import local from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.utils import local @pytest.fixture(autouse=True) diff --git a/bk-plugin-framework/tests/hub/__init__.py b/bk-plugin-framework/tests/hub/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/tests/hub/__init__.py +++ b/bk-plugin-framework/tests/hub/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/hub/test_hub.py b/bk-plugin-framework/tests/hub/test_hub.py index da9eea0..78a0ce8 100644 --- a/bk-plugin-framework/tests/hub/test_hub.py +++ b/bk-plugin-framework/tests/hub/test_hub.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/kit/__init__.py b/bk-plugin-framework/tests/kit/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/tests/kit/__init__.py +++ b/bk-plugin-framework/tests/kit/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/kit/test_plugin.py b/bk-plugin-framework/tests/kit/test_plugin.py index 4d95a04..6f3b434 100644 --- a/bk-plugin-framework/tests/kit/test_plugin.py +++ b/bk-plugin-framework/tests/kit/test_plugin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,17 +8,17 @@ 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 pytest from unittest.mock import MagicMock, patch +import pytest from bk_plugin_framework.kit import ( - Plugin, - InputsModel, - OutputsModel, - ContextRequire, Callback, Context, + ContextRequire, + InputsModel, + OutputsModel, + Plugin, State, ) from bk_plugin_framework.runtime.callback.api import CallbackPreparation diff --git a/bk-plugin-framework/tests/runtime/__init__.py b/bk-plugin-framework/tests/runtime/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/tests/runtime/__init__.py +++ b/bk-plugin-framework/tests/runtime/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/runtime/callback/__init__.py b/bk-plugin-framework/tests/runtime/callback/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/tests/runtime/callback/__init__.py +++ b/bk-plugin-framework/tests/runtime/callback/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/runtime/callback/celery/__init__.py b/bk-plugin-framework/tests/runtime/callback/celery/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/tests/runtime/callback/celery/__init__.py +++ b/bk-plugin-framework/tests/runtime/callback/celery/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/runtime/callback/celery/test_tasks.py b/bk-plugin-framework/tests/runtime/callback/celery/test_tasks.py index 97c0b80..a6461b1 100644 --- a/bk-plugin-framework/tests/runtime/callback/celery/test_tasks.py +++ b/bk-plugin-framework/tests/runtime/callback/celery/test_tasks.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,15 +8,15 @@ 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 uuid + import json +import uuid from unittest.mock import MagicMock, patch import pytest - from bk_plugin_framework.kit import State -from bk_plugin_framework.utils import local from bk_plugin_framework.runtime.callback.celery import tasks +from bk_plugin_framework.utils import local @pytest.fixture @@ -35,7 +34,7 @@ def callback_data(): return json.dumps({"result": "True", "data": {}}) -class MockScheduleLock(object): +class MockScheduleLock: def __init__(self, trace_id: str, locked: bool): self.trace_id = trace_id self.locked = locked @@ -62,7 +61,7 @@ def test_callback_get_lock_fail(self, trace_id, callback_id, callback_data): random = MagicMock() random.randint = MagicMock(return_value=2) - class CurrentApp(object): + class CurrentApp: def __init__(self): self.tasks = {"bk_plugin_framework.runtime.callback.celery.tasks.callback": task} diff --git a/bk-plugin-framework/tests/runtime/callback/test_utils.py b/bk-plugin-framework/tests/runtime/callback/test_utils.py index 1aec704..88f677b 100644 --- a/bk-plugin-framework/tests/runtime/callback/test_utils.py +++ b/bk-plugin-framework/tests/runtime/callback/test_utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,11 +8,15 @@ 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 uuid import pytest - -from bk_plugin_framework.runtime.callback.api import prepare_callback, parse_callback_token, CallbackPreparation +from bk_plugin_framework.runtime.callback.api import ( + CallbackPreparation, + parse_callback_token, + prepare_callback, +) @pytest.fixture diff --git a/bk-plugin-framework/tests/runtime/schedule/__init__.py b/bk-plugin-framework/tests/runtime/schedule/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/tests/runtime/schedule/__init__.py +++ b/bk-plugin-framework/tests/runtime/schedule/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/runtime/schedule/celery/__init__.py b/bk-plugin-framework/tests/runtime/schedule/celery/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/tests/runtime/schedule/celery/__init__.py +++ b/bk-plugin-framework/tests/runtime/schedule/celery/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/runtime/schedule/celery/test_tasks.py b/bk-plugin-framework/tests/runtime/schedule/celery/test_tasks.py index a7de293..e115461 100644 --- a/bk-plugin-framework/tests/runtime/schedule/celery/test_tasks.py +++ b/bk-plugin-framework/tests/runtime/schedule/celery/test_tasks.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,14 +8,14 @@ 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 uuid from unittest.mock import MagicMock, patch import pytest - from bk_plugin_framework.kit import State -from bk_plugin_framework.utils import local from bk_plugin_framework.runtime.schedule.celery import tasks +from bk_plugin_framework.utils import local @pytest.fixture diff --git a/bk-plugin-framework/tests/runtime/schedule/test_utils.py b/bk-plugin-framework/tests/runtime/schedule/test_utils.py index c6dbc51..7610822 100644 --- a/bk-plugin-framework/tests/runtime/schedule/test_utils.py +++ b/bk-plugin-framework/tests/runtime/schedule/test_utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,11 +8,11 @@ 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 uuid -import pytest +import uuid from unittest.mock import MagicMock, patch +import pytest from bk_plugin_framework.runtime.schedule.utils import get_schedule_lock diff --git a/bk-plugin-framework/tests/runtime/test_executor.py b/bk-plugin-framework/tests/runtime/test_executor.py index 8c3c096..a9eb20d 100644 --- a/bk-plugin-framework/tests/runtime/test_executor.py +++ b/bk-plugin-framework/tests/runtime/test_executor.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,16 +8,16 @@ 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 json -import pytest +import json from unittest.mock import MagicMock, patch +import pytest from bk_plugin_framework.kit import ( - Plugin, - InputsModel, - ContextRequire, Context, + ContextRequire, + InputsModel, + Plugin, State, ) from bk_plugin_framework.runtime.executor import BKPluginExecutor diff --git a/bk-plugin-framework/tests/settings.py b/bk-plugin-framework/tests/settings.py index 2f55ef0..0b3ee8a 100644 --- a/bk-plugin-framework/tests/settings.py +++ b/bk-plugin-framework/tests/settings.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,6 +8,7 @@ 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. """ + SECRET_KEY = "SECRET_KEY" BK_APP_SECRET = "1" * 52 BK_PLUGIN_APIGW_BACKEND_HOST = "" diff --git a/bk-plugin-framework/tests/utils/__init__.py b/bk-plugin-framework/tests/utils/__init__.py index 872e779..a7d8957 100644 --- a/bk-plugin-framework/tests/utils/__init__.py +++ b/bk-plugin-framework/tests/utils/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/utils/test_local.py b/bk-plugin-framework/tests/utils/test_local.py index 81939eb..513fb15 100644 --- a/bk-plugin-framework/tests/utils/test_local.py +++ b/bk-plugin-framework/tests/utils/test_local.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/bk-plugin-framework/tests/utils/test_log.py b/bk-plugin-framework/tests/utils/test_log.py index 43d4947..6292e94 100644 --- a/bk-plugin-framework/tests/utils/test_log.py +++ b/bk-plugin-framework/tests/utils/test_log.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -9,6 +8,7 @@ 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. """ + from unittest.mock import MagicMock from bk_plugin_framework.utils import local diff --git a/bk-plugin-framework/tests/utils/test_validations.py b/bk-plugin-framework/tests/utils/test_validations.py index fee3759..e4448dd 100644 --- a/bk-plugin-framework/tests/utils/test_validations.py +++ b/bk-plugin-framework/tests/utils/test_validations.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from bk_plugin_framework.utils.validations import validate_allow_scope diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/__init__.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/__init__.py index 872e779..a7d8957 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/__init__.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/__version__.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/__version__.py index 0089067..b558932 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/__version__.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/__version__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/__init__.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/__init__.py index 88070b6..eff3cbe 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/__init__.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,8 +9,6 @@ specific language governing permissions and limitations under the License. """ -from __future__ import absolute_import - __all__ = ["celery_app", "RUN_VER", "APP_CODE", "SECRET_KEY", "BK_URL", "BASE_DIR"] import os @@ -19,8 +16,8 @@ # This will make sure the app is always imported when # Django starts so that shared_task will use this app. from blueapps.core.celery import celery_app -from django.utils.functional import cached_property from django.db.backends.mysql.features import DatabaseFeatures +from django.utils.functional import cached_property # app 基本信息 @@ -30,9 +27,7 @@ def get_env_or_raise(key): value = os.environ.get(key) if not value: raise RuntimeError( - ( - 'Environment variable "{}" not found, you must set this variable to run this application.' - ).format(key) + ('Environment variable "{}" not found, you must set this variable to run this application.').format(key) ) return value diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py index 0b7c0be..8ebe066 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -10,12 +9,12 @@ specific language governing permissions and limitations under the License. """ -import os import json +import os import urllib -from blueapps.conf.log import get_logging_config_dict from blueapps.conf.default_settings import * # noqa +from blueapps.conf.log import get_logging_config_dict BKPAAS_ENVIRONMENT = os.getenv("BKPAAS_ENVIRONMENT", "dev") # 默认关闭可观侧性 @@ -38,8 +37,12 @@ if BKPAAS_ENVIRONMENT == "dev": INSTALLED_APPS += ("bk_plugin_framework.services.debug_panel",) # noqa -from bk_plugin_framework.runtime.schedule.celery import queues as schedule_queues # noqa -from bk_plugin_framework.runtime.callback.celery import queues as callback_queues # noqa +from bk_plugin_framework.runtime.callback.celery import ( # noqa + queues as callback_queues, +) +from bk_plugin_framework.runtime.schedule.celery import ( # noqa + queues as schedule_queues, +) CELERY_QUEUES = schedule_queues.CELERY_QUEUES CELERY_QUEUES.extend(callback_queues.CELERY_QUEUES) @@ -77,9 +80,7 @@ ) # 用户认证 -AUTHENTICATION_BACKENDS += ( # noqa - "bk_plugin_runtime.packages.apigw.backends.APIGWUserModelBackend", -) +AUTHENTICATION_BACKENDS += ("bk_plugin_runtime.packages.apigw.backends.APIGWUserModelBackend",) # noqa # 所有环境的日志级别可以在这里配置 # LOG_LEVEL = 'INFO' @@ -132,8 +133,8 @@ LANGUAGE_CODE = "zh-hans" LANGUAGES = ( - ("en", u"English"), - ("zh-hans", u"简体中文"), + ("en", "English"), + ("zh-hans", "简体中文"), ) """ @@ -173,8 +174,8 @@ ROOT_URLCONF = "bk_plugin_runtime.urls" -from blueapps.core.celery import celery_app # noqa from bk_plugin_framework.runtime.schedule.celery.beat import SCHEDULE # noqa +from blueapps.core.celery import celery_app # noqa celery_app.conf.beat_schedule = SCHEDULE @@ -254,6 +255,5 @@ def logging_addition_settings(logging_dict): BK_APIGW_CORS_ALLOW_HEADERS = os.getenv("BK_APIGW_CORS_ALLOW_HEADERS", "") BK_APIGW_DEFAULT_TIMEOUT = int(os.getenv("BK_APIGW_DEFAULT_TIMEOUT", "60")) BK_APIGW_GRANTED_APPS = [BK_APP_CODE] + [ - each.strip() for each in os.getenv("BK_APIGW_GRANTED_APPS", "").split(",") - if each.strip() + each.strip() for each in os.getenv("BK_APIGW_GRANTED_APPS", "").split(",") if each.strip() ] diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py index aa60d20..727b933 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -11,6 +10,7 @@ """ import os + import MySQLdb from bk_plugin_runtime.config import RUN_VER @@ -37,10 +37,7 @@ # 本地开发数据库默认使用sqlite3 DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": APP_CODE # noqa - }, + "default": {"ENGINE": "django.db.backends.sqlite3", "NAME": APP_CODE}, # noqa } # 本地开发是否使用mysql数据库 BK_PLUGIN_DEV_USE_MYSQL = os.getenv("BK_PLUGIN_DEV_USE_MYSQL") diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/prod.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/prod.py index b0d991a..42da106 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/prod.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/prod.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/stag.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/stag.py index 1829056..7bf5260 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/stag.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/stag.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -11,6 +10,7 @@ """ import os + from bk_plugin_runtime.config import RUN_VER if RUN_VER == "open": diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/manage.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/manage.py index 23a3536..9f06a8e 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/manage.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/manage.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/apigw/backends.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/apigw/backends.py index 98769b9..4db57aa 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/apigw/backends.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/apigw/backends.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/__init__.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/__init__.py index c2aedd9..4c2e7ec 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/__init__.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- -__author__ = u"蓝鲸智云" +__author__ = "蓝鲸智云" diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/__init__.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/__init__.py index 40a96af..e69de29 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/__init__.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/__init__.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/__init__.py index 40a96af..e69de29 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/__init__.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/bk_login.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/bk_login.py index 859ecd7..6864e95 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/bk_login.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/bk_login.py @@ -1,35 +1,39 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsBkLogin(object): +class CollectionsBkLogin: """Collections of BK_LOGIN APIS""" def __init__(self, client): self.client = client self.get_all_users = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/bk_login/get_all_users/', - description=u'获取所有用户信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/bk_login/get_all_users/", + description="获取所有用户信息", ) self.get_batch_users = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/bk_login/get_batch_users/', - description=u'批量获取用户信息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/bk_login/get_batch_users/", + description="批量获取用户信息", ) self.get_user = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/bk_login/get_user/', - description=u'获取用户信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/bk_login/get_user/", + description="获取用户信息", ) self.get_all_user = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/bk_login/get_all_user/', - description=u'获取所有用户信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/bk_login/get_all_user/", + description="获取所有用户信息", ) self.get_batch_user = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/bk_login/get_batch_user/', - description=u'获取多个用户信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/bk_login/get_batch_user/", + description="获取多个用户信息", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/bk_paas.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/bk_paas.py index 7ae5ba9..470908b 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/bk_paas.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/bk_paas.py @@ -1,15 +1,15 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsBkPaas(object): +class CollectionsBkPaas: """Collections of BK_PAAS APIS""" def __init__(self, client): self.client = client self.get_app_info = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/bk_paas/get_app_info/', - description=u'获取应用信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/bk_paas/get_app_info/", + description="获取应用信息", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/cc.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/cc.py index 5a9118a..f27838b 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/cc.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/cc.py @@ -1,645 +1,747 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsCC(object): +class CollectionsCC: """Collections of CC APIS""" def __init__(self, client): self.client = client self.add_host_lock = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/add_host_lock/', - description=u'新加主机锁' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/add_host_lock/", + description="新加主机锁", ) self.add_host_to_resource = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/add_host_to_resource/', - description=u'新增主机到资源池' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/add_host_to_resource/", + description="新增主机到资源池", ) self.add_instance_association = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/add_instance_association/', - description=u'新建模型实例之间的关联关系' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/add_instance_association/", + description="新建模型实例之间的关联关系", ) self.add_label_for_service_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/add_label_for_service_instance/', - description=u'为服务实例添加标签' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/add_label_for_service_instance/", + description="为服务实例添加标签", ) self.batch_create_proc_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/batch_create_proc_template/', - description=u'批量创建进程模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/batch_create_proc_template/", + description="批量创建进程模板", ) self.batch_delete_inst = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/batch_delete_inst/', - description=u'批量删除实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/batch_delete_inst/", + description="批量删除实例", ) self.batch_delete_set = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/batch_delete_set/', - description=u'批量删除集群' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/batch_delete_set/", + description="批量删除集群", ) self.batch_update_host = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/batch_update_host/', - description=u'批量更新主机属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/batch_update_host/", + description="批量更新主机属性", ) self.batch_update_inst = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/batch_update_inst/', - description=u'批量更新对象实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/batch_update_inst/", + description="批量更新对象实例", ) self.bind_role_privilege = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/bind_role_privilege/', - description=u'绑定角色权限' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/bind_role_privilege/", + description="绑定角色权限", ) self.clone_host_property = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/clone_host_property/', - description=u'克隆主机属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/clone_host_property/", + description="克隆主机属性", ) self.create_biz_custom_field = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_biz_custom_field/', - description=u'创建业务自定义模型属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_biz_custom_field/", + description="创建业务自定义模型属性", ) self.create_business = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_business/', - description=u'新建业务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_business/", + description="新建业务", ) self.create_classification = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_classification/', - description=u'添加模型分类' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_classification/", + description="添加模型分类", ) self.create_cloud_area = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_cloud_area/', - description=u'创建云区域' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_cloud_area/", + description="创建云区域", ) self.create_custom_query = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_custom_query/', - description=u'添加自定义查询' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_custom_query/", + description="添加自定义查询", ) self.create_inst = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_inst/', - description=u'创建实例' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cc/create_inst/", description="创建实例" ) self.create_module = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_module/', - description=u'创建模块' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_module/", + description="创建模块", ) self.create_object = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_object/', - description=u'创建模型' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_object/", + description="创建模型", ) self.create_object_attribute = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_object_attribute/', - description=u'创建模型属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_object_attribute/", + description="创建模型属性", ) self.create_process_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_process_instance/', - description=u'创建进程实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_process_instance/", + description="创建进程实例", ) self.create_service_category = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_service_category/', - description=u'新建服务分类' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_service_category/", + description="新建服务分类", ) self.create_service_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_service_instance/', - description=u'创建服务实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_service_instance/", + description="创建服务实例", ) self.create_service_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_service_template/', - description=u'新建服务模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_service_template/", + description="新建服务模板", ) self.create_set = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_set/', - description=u'创建集群' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cc/create_set/", description="创建集群" ) self.create_set_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/create_set_template/', - description=u'新建集群模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/create_set_template/", + description="新建集群模板", ) self.delete_business = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_business/', - description=u'删除业务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_business/", + description="删除业务", ) self.delete_classification = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_classification/', - description=u'删除模型分类' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_classification/", + description="删除模型分类", ) self.delete_cloud_area = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_cloud_area/', - description=u'删除云区域' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_cloud_area/", + description="删除云区域", ) self.delete_custom_query = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_custom_query/', - description=u'删除自定义查询' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_custom_query/", + description="删除自定义查询", ) self.delete_host = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_host/', - description=u'删除主机' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cc/delete_host/", description="删除主机" ) self.delete_host_lock = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_host_lock/', - description=u'删除主机锁' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_host_lock/", + description="删除主机锁", ) self.delete_inst = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_inst/', - description=u'删除实例' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cc/delete_inst/", description="删除实例" ) self.delete_instance_association = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_instance_association/', - description=u'删除模型实例之间的关联关系' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_instance_association/", + description="删除模型实例之间的关联关系", ) self.delete_module = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_module/', - description=u'删除模块' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_module/", + description="删除模块", ) self.delete_object = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_object/', - description=u'删除模型' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_object/", + description="删除模型", ) self.delete_object_attribute = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_object_attribute/', - description=u'删除对象模型属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_object_attribute/", + description="删除对象模型属性", ) self.delete_proc_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_proc_template/', - description=u'删除进程模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_proc_template/", + description="删除进程模板", ) self.delete_process_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_process_instance/', - description=u'删除进程实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_process_instance/", + description="删除进程实例", ) self.delete_service_category = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_service_category/', - description=u'删除服务分类' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_service_category/", + description="删除服务分类", ) self.delete_service_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_service_instance/', - description=u'删除服务实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_service_instance/", + description="删除服务实例", ) self.delete_service_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_service_template/', - description=u'删除服务模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_service_template/", + description="删除服务模板", ) self.delete_set = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_set/', - description=u'删除集群' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cc/delete_set/", description="删除集群" ) self.delete_set_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/delete_set_template/', - description=u'删除集群模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/delete_set_template/", + description="删除集群模板", ) self.find_host_biz_relations = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_host_biz_relations/', - description=u'查询主机业务关系信息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_host_biz_relations/", + description="查询主机业务关系信息", ) self.find_host_by_module = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_host_by_module/', - description=u'根据模块查询主机' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_host_by_module/", + description="根据模块查询主机", ) self.find_host_by_service_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_host_by_service_template/', - description=u'查询服务模板下的主机' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_host_by_service_template/", + description="查询服务模板下的主机", ) self.find_host_by_set_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_host_by_set_template/', - description=u'查询集群模板下的主机' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_host_by_set_template/", + description="查询集群模板下的主机", ) self.find_host_snapshot_batch = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_host_snapshot_batch/', - description=u'批量查询主机快照' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_host_snapshot_batch/", + description="批量查询主机快照", ) self.find_host_topo_relation = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_host_topo_relation/', - description=u'获取主机与拓扑的关系' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_host_topo_relation/", + description="获取主机与拓扑的关系", ) self.find_instance_association = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_instance_association/', - description=u'查询模型实例之间的关联关系' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_instance_association/", + description="查询模型实例之间的关联关系", ) self.find_module_batch = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_module_batch/', - description=u'批量查询某业务的模块详情' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_module_batch/", + description="批量查询某业务的模块详情", ) self.find_module_host_relation = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_module_host_relation/', - description=u'根据模块ID查询主机和模块的关系' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_module_host_relation/", + description="根据模块ID查询主机和模块的关系", ) self.find_object_association = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_object_association/', - description=u'查询模型之间的关联关系' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_object_association/", + description="查询模型之间的关联关系", ) self.find_set_batch = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_set_batch/', - description=u'批量查询某业务的集群详情' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_set_batch/", + description="批量查询某业务的集群详情", ) self.find_topo_node_paths = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/find_topo_node_paths/', - description=u'查询业务拓扑节点的拓扑路径' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/find_topo_node_paths/", + description="查询业务拓扑节点的拓扑路径", ) self.get_biz_internal_module = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/get_biz_internal_module/', - description=u'查询业务的空闲机/故障机/待回收模块' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/get_biz_internal_module/", + description="查询业务的空闲机/故障机/待回收模块", ) self.get_custom_query_data = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/get_custom_query_data/', - description=u'根据自定义查询获取数据' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/get_custom_query_data/", + description="根据自定义查询获取数据", ) self.get_custom_query_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/get_custom_query_detail/', - description=u'获取自定义查询详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/get_custom_query_detail/", + description="获取自定义查询详情", ) self.get_host_base_info = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/get_host_base_info/', - description=u'获取主机详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/get_host_base_info/", + description="获取主机详情", ) self.get_mainline_object_topo = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/get_mainline_object_topo/', - description=u'查询主线模型的业务拓扑' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/get_mainline_object_topo/", + description="查询主线模型的业务拓扑", ) self.get_operation_log = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/get_operation_log/', - description=u'获取操作日志' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/get_operation_log/", + description="获取操作日志", ) self.get_proc_template = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/get_proc_template/', - description=u'获取进程模板' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/get_proc_template/", + description="获取进程模板", ) self.get_service_template = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/get_service_template/', - description=u'获取服务模板' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/get_service_template/", + description="获取服务模板", ) self.list_biz_hosts = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_biz_hosts/', - description=u'查询业务下的主机' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_biz_hosts/", + description="查询业务下的主机", ) self.list_biz_hosts_topo = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_biz_hosts_topo/', - description=u'查询业务下的主机和拓扑信息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_biz_hosts_topo/", + description="查询业务下的主机和拓扑信息", ) self.list_hosts_without_biz = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_hosts_without_biz/', - description=u'没有业务ID的主机查询' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_hosts_without_biz/", + description="没有业务ID的主机查询", ) self.list_proc_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_proc_template/', - description=u'查询进程模板列表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_proc_template/", + description="查询进程模板列表", ) self.list_process_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_process_instance/', - description=u'查询进程实例列表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_process_instance/", + description="查询进程实例列表", ) self.list_resource_pool_hosts = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_resource_pool_hosts/', - description=u'查询资源池中的主机' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_resource_pool_hosts/", + description="查询资源池中的主机", ) self.list_service_category = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_service_category/', - description=u'查询服务分类列表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_service_category/", + description="查询服务分类列表", ) self.list_service_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_service_instance/', - description=u'查询服务实例列表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_service_instance/", + description="查询服务实例列表", ) self.list_service_instance_by_host = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_service_instance_by_host/', - description=u'通过主机查询关联的服务实例列表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_service_instance_by_host/", + description="通过主机查询关联的服务实例列表", ) self.list_service_instance_detail = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_service_instance_detail/', - description=u'获取服务实例详细信息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_service_instance_detail/", + description="获取服务实例详细信息", ) self.list_service_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_service_template/', - description=u'服务模板列表查询' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_service_template/", + description="服务模板列表查询", ) self.list_set_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/list_set_template/', - description=u'查询集群模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/list_set_template/", + description="查询集群模板", ) self.list_set_template_related_service_template = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/list_set_template_related_service_template/', - description=u'获取某集群模版下的服务模版列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/list_set_template_related_service_template/", + description="获取某集群模版下的服务模版列表", ) self.remove_label_from_service_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/remove_label_from_service_instance/', - description=u'从服务实例移除标签' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/remove_label_from_service_instance/", + description="从服务实例移除标签", ) self.resource_watch = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/resource_watch/', - description=u'监听资源变化事件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/resource_watch/", + description="监听资源变化事件", ) self.search_biz_inst_topo = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cc/search_biz_inst_topo/', - description=u'查询业务实例拓扑' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cc/search_biz_inst_topo/", + description="查询业务实例拓扑", ) self.search_business = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_business/', - description=u'查询业务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_business/", + description="查询业务", ) self.search_classifications = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_classifications/', - description=u'查询模型分类' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_classifications/", + description="查询模型分类", ) self.search_cloud_area = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_cloud_area/', - description=u'查询云区域' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_cloud_area/", + description="查询云区域", ) self.search_custom_query = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_custom_query/', - description=u'查询自定义查询' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_custom_query/", + description="查询自定义查询", ) self.search_host = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_host/', - description=u'根据条件查询主机' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_host/", + description="根据条件查询主机", ) self.search_host_lock = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_host_lock/', - description=u'查询主机锁' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_host_lock/", + description="查询主机锁", ) self.search_hostidentifier = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_hostidentifier/', - description=u'根据条件查询主机身份' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_hostidentifier/", + description="根据条件查询主机身份", ) self.search_inst = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_inst/', - description=u'查询实例' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cc/search_inst/", description="查询实例" ) self.search_inst_association_topo = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_inst_association_topo/', - description=u'查询实例关联拓扑' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_inst_association_topo/", + description="查询实例关联拓扑", ) self.search_inst_asst_object_inst_base_info = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_inst_asst_object_inst_base_info/', - description=u'查询实例关联模型实例基本信息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_inst_asst_object_inst_base_info/", + description="查询实例关联模型实例基本信息", ) self.search_inst_by_object = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_inst_by_object/', - description=u'查询实例详情' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_inst_by_object/", + description="查询实例详情", ) self.search_module = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_module/', - description=u'查询模块' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_module/", + description="查询模块", ) self.search_object_attribute = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_object_attribute/', - description=u'查询对象模型属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_object_attribute/", + description="查询对象模型属性", ) self.search_object_topo = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_object_topo/', - description=u'查询普通模型拓扑' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_object_topo/", + description="查询普通模型拓扑", ) self.search_objects = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_objects/', - description=u'查询模型' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_objects/", + description="查询模型", ) self.search_set = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_set/', - description=u'查询集群' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cc/search_set/", description="查询集群" ) self.search_subscription = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_subscription/', - description=u'查询订阅' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_subscription/", + description="查询订阅", ) self.search_topo_tree = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/search_topo_tree/', - description=u'搜索业务拓扑树' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/search_topo_tree/", + description="搜索业务拓扑树", ) self.subscribe_event = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/subscribe_event/', - description=u'订阅事件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/subscribe_event/", + description="订阅事件", ) self.sync_set_template_to_set = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/sync_set_template_to_set/', - description=u'集群模板同步' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/sync_set_template_to_set/", + description="集群模板同步", ) self.transfer_host_module = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/transfer_host_module/', - description=u'业务内主机转移模块' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/transfer_host_module/", + description="业务内主机转移模块", ) self.transfer_host_to_faultmodule = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/transfer_host_to_faultmodule/', - description=u'上交主机到业务的故障机模块' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/transfer_host_to_faultmodule/", + description="上交主机到业务的故障机模块", ) self.transfer_host_to_idlemodule = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/transfer_host_to_idlemodule/', - description=u'上交主机到业务的空闲机模块' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/transfer_host_to_idlemodule/", + description="上交主机到业务的空闲机模块", ) self.transfer_host_to_resourcemodule = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/transfer_host_to_resourcemodule/', - description=u'上交主机至资源池' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/transfer_host_to_resourcemodule/", + description="上交主机至资源池", ) self.transfer_resourcehost_to_idlemodule = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/transfer_resourcehost_to_idlemodule/', - description=u'资源池主机分配至业务的空闲机模块' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/transfer_resourcehost_to_idlemodule/", + description="资源池主机分配至业务的空闲机模块", ) self.transfer_sethost_to_idle_module = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/transfer_sethost_to_idle_module/', - description=u'清空业务下集群/模块中主机' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/transfer_sethost_to_idle_module/", + description="清空业务下集群/模块中主机", ) self.unsubcribe_event = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/unsubcribe_event/', - description=u'退订事件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/unsubcribe_event/", + description="退订事件", ) self.update_biz_custom_field = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_biz_custom_field/', - description=u'更新业务自定义模型属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_biz_custom_field/", + description="更新业务自定义模型属性", ) self.update_business = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_business/', - description=u'修改业务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_business/", + description="修改业务", ) self.update_business_enable_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_business_enable_status/', - description=u'修改业务启用状态' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_business_enable_status/", + description="修改业务启用状态", ) self.update_classification = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_classification/', - description=u'更新模型分类' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_classification/", + description="更新模型分类", ) self.update_cloud_area = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_cloud_area/', - description=u'更新云区域' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_cloud_area/", + description="更新云区域", ) self.update_custom_query = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_custom_query/', - description=u'更新自定义查询' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_custom_query/", + description="更新自定义查询", ) self.update_event_subscribe = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_event_subscribe/', - description=u'修改订阅' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_event_subscribe/", + description="修改订阅", ) self.update_host = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_host/', - description=u'更新主机属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_host/", + description="更新主机属性", ) self.update_host_cloud_area_field = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_host_cloud_area_field/', - description=u'更新主机的云区域字段' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_host_cloud_area_field/", + description="更新主机的云区域字段", ) self.update_inst = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_inst/', - description=u'更新对象实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_inst/", + description="更新对象实例", ) self.update_module = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_module/', - description=u'更新模块' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_module/", + description="更新模块", ) self.update_object = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_object/', - description=u'更新定义' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_object/", + description="更新定义", ) self.update_object_attribute = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_object_attribute/', - description=u'更新对象模型属性' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_object_attribute/", + description="更新对象模型属性", ) self.update_object_topo_graphics = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_object_topo_graphics/', - description=u'更新拓扑图' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_object_topo_graphics/", + description="更新拓扑图", ) self.update_proc_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_proc_template/', - description=u'更新进程模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_proc_template/", + description="更新进程模板", ) self.update_process_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_process_instance/', - description=u'更新进程实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_process_instance/", + description="更新进程实例", ) self.update_service_category = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_service_category/', - description=u'更新服务分类' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_service_category/", + description="更新服务分类", ) self.update_service_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_service_template/', - description=u'更新服务模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_service_template/", + description="更新服务模板", ) self.update_set = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_set/', - description=u'更新集群' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cc/update_set/", description="更新集群" ) self.update_set_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cc/update_set_template/', - description=u'编辑集群模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cc/update_set_template/", + description="编辑集群模板", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/cmsi.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/cmsi.py index f9819b6..0dcdbd8 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/cmsi.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/cmsi.py @@ -1,50 +1,51 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsCMSI(object): +class CollectionsCMSI: """Collections of CMSI APIS""" def __init__(self, client): self.client = client self.get_msg_type = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/cmsi/get_msg_type/', - description=u'查询消息发送类型' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/cmsi/get_msg_type/", + description="查询消息发送类型", ) self.send_mail = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cmsi/send_mail/', - description=u'发送邮件' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cmsi/send_mail/", description="发送邮件" ) self.send_mp_weixin = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cmsi/send_mp_weixin/', - description=u'发送公众号微信消息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cmsi/send_mp_weixin/", + description="发送公众号微信消息", ) self.send_msg = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cmsi/send_msg/', - description=u'通用消息发送' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cmsi/send_msg/", + description="通用消息发送", ) self.send_qy_weixin = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cmsi/send_qy_weixin/', - description=u'发送企业微信' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cmsi/send_qy_weixin/", + description="发送企业微信", ) self.send_sms = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cmsi/send_sms/', - description=u'发送短信' + client=self.client, method="POST", path="/api/c/compapi{bk_api_ver}/cmsi/send_sms/", description="发送短信" ) self.send_voice_msg = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cmsi/send_voice_msg/', - description=u'公共语音通知' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cmsi/send_voice_msg/", + description="公共语音通知", ) self.send_weixin = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/cmsi/send_weixin/', - description=u'发送微信消息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/cmsi/send_weixin/", + description="发送微信消息", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/gse.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/gse.py index 3998864..c06703a 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/gse.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/gse.py @@ -1,35 +1,39 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsGSE(object): +class CollectionsGSE: """Collections of GSE APIS""" def __init__(self, client): self.client = client self.get_agent_info = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/gse/get_agent_info/', - description=u'Agent心跳信息查询' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/gse/get_agent_info/", + description="Agent心跳信息查询", ) self.get_agent_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/gse/get_agent_status/', - description=u'Agent在线状态查询' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/gse/get_agent_status/", + description="Agent在线状态查询", ) self.proc_create_session = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/gse/proc_create_session/', - description=u'进程管理:新建 session' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/gse/proc_create_session/", + description="进程管理:新建 session", ) self.proc_get_task_result_by_id = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/gse/proc_get_task_result_by_id/', - description=u'进程管理:获取任务结果' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/gse/proc_get_task_result_by_id/", + description="进程管理:获取任务结果", ) self.proc_run_command = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/gse/proc_run_command/', - description=u'进程管理:执行命令' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/gse/proc_run_command/", + description="进程管理:执行命令", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/itsm.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/itsm.py index 92dd0d3..3041191 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/itsm.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/itsm.py @@ -1,60 +1,69 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsITSM(object): +class CollectionsITSM: """Collections of ITSM APIS""" def __init__(self, client): self.client = client self.create_ticket = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/itsm/create_ticket/', - description=u'创建单据' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/itsm/create_ticket/", + description="创建单据", ) self.get_service_catalogs = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/itsm/get_service_catalogs/', - description=u'服务目录查询' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/itsm/get_service_catalogs/", + description="服务目录查询", ) self.get_service_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/itsm/get_service_detail/', - description=u'服务详情查询' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/itsm/get_service_detail/", + description="服务详情查询", ) self.get_services = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/itsm/get_services/', - description=u'服务列表查询' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/itsm/get_services/", + description="服务列表查询", ) self.get_ticket_info = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/itsm/get_ticket_info/', - description=u'单据详情查询' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/itsm/get_ticket_info/", + description="单据详情查询", ) self.get_ticket_logs = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/itsm/get_ticket_logs/', - description=u'单据日志查询' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/itsm/get_ticket_logs/", + description="单据日志查询", ) self.get_ticket_status = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/itsm/get_ticket_status/', - description=u'单据状态查询' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/itsm/get_ticket_status/", + description="单据状态查询", ) self.get_tickets = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/itsm/get_tickets/', - description=u'获取单据列表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/itsm/get_tickets/", + description="获取单据列表", ) self.operate_node = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/itsm/operate_node/', - description=u'处理单据节点' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/itsm/operate_node/", + description="处理单据节点", ) self.operate_ticket = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/itsm/operate_ticket/', - description=u'处理单据' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/itsm/operate_ticket/", + description="处理单据", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/job.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/job.py index 873748f..201d311 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/job.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/job.py @@ -1,140 +1,165 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsJOB(object): +class CollectionsJOB: """Collections of JOB APIS""" def __init__(self, client): self.client = client self.execute_job = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/execute_job/', - description=u'启动作业' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/execute_job/", + description="启动作业", ) self.fast_execute_script = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/fast_execute_script/', - description=u'快速执行脚本' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/fast_execute_script/", + description="快速执行脚本", ) self.fast_execute_sql = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/fast_execute_sql/', - description=u'快速执行SQL脚本' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/fast_execute_sql/", + description="快速执行SQL脚本", ) self.fast_push_file = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/fast_push_file/', - description=u'快速分发文件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/fast_push_file/", + description="快速分发文件", ) self.get_cron_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_cron_list/', - description=u'查询业务下定时作业信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_cron_list/", + description="查询业务下定时作业信息", ) self.get_job_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_job_detail/', - description=u'查询作业模板详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_job_detail/", + description="查询作业模板详情", ) self.get_job_instance_log = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_job_instance_log/', - description=u'根据作业实例ID查询作业执行日志' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_job_instance_log/", + description="根据作业实例ID查询作业执行日志", ) self.get_job_instance_status = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_job_instance_status/', - description=u'查询作业执行状态' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_job_instance_status/", + description="查询作业执行状态", ) self.get_job_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_job_list/', - description=u'查询作业模板' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_job_list/", + description="查询作业模板", ) self.get_os_account = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_os_account/', - description=u'查询业务下的执行账号' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_os_account/", + description="查询业务下的执行账号", ) self.get_own_db_account_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_own_db_account_list/', - description=u'查询用户有权限的DB帐号列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_own_db_account_list/", + description="查询用户有权限的DB帐号列表", ) self.get_public_script_list = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/get_public_script_list/', - description=u'查询公共脚本列表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/get_public_script_list/", + description="查询公共脚本列表", ) self.get_script_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_script_detail/', - description=u'查询脚本详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_script_detail/", + description="查询脚本详情", ) self.get_script_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_script_list/', - description=u'查询脚本列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_script_list/", + description="查询脚本列表", ) self.get_step_instance_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/get_step_instance_status/', - description=u'查询作业步骤的执行状态' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/get_step_instance_status/", + description="查询作业步骤的执行状态", ) self.change_cron_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/change_cron_status/', - description=u'更新定时作业状态' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/change_cron_status/", + description="更新定时作业状态", ) self.execute_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/execute_task/', - description=u'根据作业模板ID启动作业' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/execute_task/", + description="根据作业模板ID启动作业", ) self.execute_task_ext = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/execute_task_ext/', - description=u'启动作业Ext(带全局变量启动)' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/execute_task_ext/", + description="启动作业Ext(带全局变量启动)", ) self.get_agent_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/get_agent_status/', - description=u'查询Agent状态' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/get_agent_status/", + description="查询Agent状态", ) self.get_cron = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_cron/', - description=u'查询业务下定时作业信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_cron/", + description="查询业务下定时作业信息", ) self.get_task = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_task/', - description=u'查询作业模板' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_task/", + description="查询作业模板", ) self.get_task_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_task_detail/', - description=u'查询作业模板详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_task_detail/", + description="查询作业模板详情", ) self.get_task_ip_log = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_task_ip_log/', - description=u'根据作业实例ID查询作业执行日志' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_task_ip_log/", + description="根据作业实例ID查询作业执行日志", ) self.get_task_result = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/job/get_task_result/', - description=u'根据作业实例 ID 查询作业执行状态' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/job/get_task_result/", + description="根据作业实例 ID 查询作业执行状态", ) self.save_cron = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/save_cron/', - description=u'新建或保存定时作业' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/save_cron/", + description="新建或保存定时作业", ) self.update_cron_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/job/update_cron_status/', - description=u'更新定时作业状态' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/job/update_cron_status/", + description="更新定时作业状态", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/jobv3.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/jobv3.py index b64d65b..5099223 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/jobv3.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/jobv3.py @@ -1,130 +1,153 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsJOBV3(object): +class CollectionsJOBV3: """Collections of JOBV3 APIS""" def __init__(self, client): self.client = client self.execute_job_plan = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/jobv3/execute_job_plan/', - description=u'执行作业执行方案' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/jobv3/execute_job_plan/", + description="执行作业执行方案", ) self.fast_execute_script = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/jobv3/fast_execute_script/', - description=u'快速执行脚本' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/jobv3/fast_execute_script/", + description="快速执行脚本", ) self.fast_execute_sql = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/jobv3/fast_execute_sql/', - description=u'快速执行SQL' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/jobv3/fast_execute_sql/", + description="快速执行SQL", ) self.fast_transfer_file = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/jobv3/fast_transfer_file/', - description=u'快速分发文件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/jobv3/fast_transfer_file/", + description="快速分发文件", ) self.get_account_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_account_list/', - description=u'查询业务下的执行账号' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_account_list/", + description="查询业务下的执行账号", ) self.get_cron_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_cron_detail/', - description=u'查询定时作业详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_cron_detail/", + description="查询定时作业详情", ) self.get_cron_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_cron_list/', - description=u'查询业务下定时作业信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_cron_list/", + description="查询业务下定时作业信息", ) self.get_job_instance_global_var_value = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_job_instance_global_var_value/', - description=u'获取作业实例全局变量值' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_job_instance_global_var_value/", + description="获取作业实例全局变量值", ) self.get_job_instance_ip_log = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_job_instance_ip_log/', - description=u'根据作业实例ID查询作业执行日志' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_job_instance_ip_log/", + description="根据作业实例ID查询作业执行日志", ) self.get_job_instance_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_job_instance_list/', - description=u'查询作业实例列表(执行历史)' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_job_instance_list/", + description="查询作业实例列表(执行历史)", ) self.get_job_instance_status = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_job_instance_status/', - description=u'根据作业实例 ID 查询作业执行状态' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_job_instance_status/", + description="根据作业实例 ID 查询作业执行状态", ) self.get_job_plan_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_job_plan_detail/', - description=u'查询执行方案详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_job_plan_detail/", + description="查询执行方案详情", ) self.get_job_plan_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_job_plan_list/', - description=u'查询执行方案列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_job_plan_list/", + description="查询执行方案列表", ) self.get_job_template_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_job_template_list/', - description=u'查询作业模版列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_job_template_list/", + description="查询作业模版列表", ) self.get_public_script_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_public_script_list/', - description=u'查询公共脚本列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_public_script_list/", + description="查询公共脚本列表", ) self.get_public_script_version_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_public_script_version_detail/', - description=u'查询公共脚本详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_public_script_version_detail/", + description="查询公共脚本详情", ) self.get_public_script_version_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_public_script_version_list/', - description=u'查询公共脚本版本列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_public_script_version_list/", + description="查询公共脚本版本列表", ) self.get_script_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_script_list/', - description=u'查询脚本列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_script_list/", + description="查询脚本列表", ) self.get_script_version_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_script_version_detail/', - description=u'查询脚本详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_script_version_detail/", + description="查询脚本详情", ) self.get_script_version_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/jobv3/get_script_version_list/', - description=u'查询脚本版本列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/jobv3/get_script_version_list/", + description="查询脚本版本列表", ) self.operate_job_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/jobv3/operate_job_instance/', - description=u'作业实例操作' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/jobv3/operate_job_instance/", + description="作业实例操作", ) self.operate_step_instance = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/jobv3/operate_step_instance/', - description=u'步骤实例操作' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/jobv3/operate_step_instance/", + description="步骤实例操作", ) self.save_cron = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/jobv3/save_cron/', - description=u'新建或保存定时作业' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/jobv3/save_cron/", + description="新建或保存定时作业", ) self.update_cron_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/jobv3/update_cron_status/', - description=u'更新定时作业状态,如启动或暂停' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/jobv3/update_cron_status/", + description="更新定时作业状态,如启动或暂停", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/monitor_v3.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/monitor_v3.py index b3bac3d..586aef4 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/monitor_v3.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/monitor_v3.py @@ -1,380 +1,453 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsMonitorV3(object): +class CollectionsMonitorV3: """Collections of MONITOR_V3 APIS""" def __init__(self, client): self.client = client self.add_shield = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/add_shield/', - description=u'新增告警屏蔽' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/add_shield/", + description="新增告警屏蔽", ) self.batch_retry_config = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/batch_retry_config/', - description=u'批量重试采集配置的失败实例' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/batch_retry_config/", + description="批量重试采集配置的失败实例", ) self.batch_retry_instance_step = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/batch_retry_instance_step/', - description=u'重试失败的节点步骤' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/batch_retry_instance_step/", + description="重试失败的节点步骤", ) self.collect_running_status = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/collect_running_status/', - description=u'获取采集配置主机的运行状态' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/collect_running_status/", + description="获取采集配置主机的运行状态", ) self.create_custom_event_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/create_custom_event_group/', - description=u'创建自定义事件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/create_custom_event_group/", + description="创建自定义事件", ) self.create_custom_time_series = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/create_custom_time_series/', - description=u'创建自定义指标' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/create_custom_time_series/", + description="创建自定义指标", ) self.custom_time_series = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/custom_time_series/', - description=u'自定义指标列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/custom_time_series/", + description="自定义指标列表", ) self.custom_time_series_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/custom_time_series_detail/', - description=u'自定义指标详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/custom_time_series_detail/", + description="自定义指标详情", ) self.delete_alarm_strategy = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/delete_alarm_strategy/', - description=u'删除告警策略' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/delete_alarm_strategy/", + description="删除告警策略", ) self.delete_collect_config = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/delete_collect_config/', - description=u'删除采集配置' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/delete_collect_config/", + description="删除采集配置", ) self.delete_custom_event_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/delete_custom_event_group/', - description=u'删除自定义事件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/delete_custom_event_group/", + description="删除自定义事件", ) self.delete_custom_time_series = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/delete_custom_time_series/', - description=u'删除自定义指标' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/delete_custom_time_series/", + description="删除自定义指标", ) self.delete_notice_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/delete_notice_group/', - description=u'删除通知组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/delete_notice_group/", + description="删除通知组", ) self.disable_shield = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/disable_shield/', - description=u'解除告警屏蔽' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/disable_shield/", + description="解除告警屏蔽", ) self.edit_shield = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/edit_shield/', - description=u'编辑告警屏蔽' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/edit_shield/", + description="编辑告警屏蔽", ) self.export_uptime_check_task = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/export_uptime_check_task/', - description=u'导出拨测任务配置' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/export_uptime_check_task/", + description="导出拨测任务配置", ) self.get_collect_config_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_collect_config_list/', - description=u'采集配置列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_collect_config_list/", + description="采集配置列表", ) self.get_collect_log_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_collect_log_detail/', - description=u'获取采集下发详细日志' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_collect_log_detail/", + description="获取采集下发详细日志", ) self.get_collect_status = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_collect_status/', - description=u'查询采集配置节点状态' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_collect_status/", + description="查询采集配置节点状态", ) self.get_custom_event_group = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_custom_event_group/', - description=u'获取自定义事件详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_custom_event_group/", + description="获取自定义事件详情", ) self.get_es_data = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_es_data/', - description=u'获取监控链路时序数据' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_es_data/", + description="获取监控链路时序数据", ) self.get_event_log = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_event_log/', - description=u'查询事件流转记录' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_event_log/", + description="查询事件流转记录", ) self.get_shield = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_shield/', - description=u'获取告警屏蔽' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_shield/", + description="获取告警屏蔽", ) self.get_ts_data = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_ts_data/', - description=u'获取时序数据' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_ts_data/", + description="获取时序数据", ) self.get_uptime_check_node_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_uptime_check_node_list/', - description=u'拨测节点列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_uptime_check_node_list/", + description="拨测节点列表", ) self.get_uptime_check_task_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/get_uptime_check_task_list/', - description=u'拨测任务列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/get_uptime_check_task_list/", + description="拨测任务列表", ) self.import_uptime_check_node = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/import_uptime_check_node/', - description=u'导入拨测节点配置' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/import_uptime_check_node/", + description="导入拨测节点配置", ) self.import_uptime_check_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/import_uptime_check_task/', - description=u'导入拨测任务配置' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/import_uptime_check_task/", + description="导入拨测任务配置", ) self.list_shield = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/list_shield/', - description=u'获取告警屏蔽列表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/list_shield/", + description="获取告警屏蔽列表", ) self.metadata_create_cluster_info = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_cluster_info/', - description=u'创建存储集群信息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_cluster_info/", + description="创建存储集群信息", ) self.metadata_create_data_id = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_data_id/', - description=u'创建监控数据源' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_data_id/", + description="创建监控数据源", ) self.metadata_create_event_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_event_group/', - description=u'创建事件分组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_event_group/", + description="创建事件分组", ) self.metadata_create_result_table = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_result_table/', - description=u'创建监控结果表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_result_table/", + description="创建监控结果表", ) self.metadata_create_result_table_metric_split = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_result_table_metric_split/', - description=u'创建结果表的维度拆分配置' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_result_table_metric_split/", + description="创建结果表的维度拆分配置", ) self.metadata_create_time_series_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_time_series_group/', - description=u'创建自定义时序分组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_create_time_series_group/", + description="创建自定义时序分组", ) self.metadata_delete_event_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_delete_event_group/', - description=u'删除事件分组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_delete_event_group/", + description="删除事件分组", ) self.metadata_delete_time_series_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_delete_time_series_group/', - description=u'删除自定义时序分组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_delete_time_series_group/", + description="删除自定义时序分组", ) self.metadata_get_cluster_info = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_cluster_info/', - description=u'查询指定存储集群信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_cluster_info/", + description="查询指定存储集群信息", ) self.metadata_get_data_id = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_data_id/', - description=u'获取监控数据源具体信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_data_id/", + description="获取监控数据源具体信息", ) self.metadata_get_event_group = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_event_group/', - description=u'查询事件分组具体内容' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_event_group/", + description="查询事件分组具体内容", ) self.metadata_get_result_table = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_result_table/', - description=u'获取监控结果表具体信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_result_table/", + description="获取监控结果表具体信息", ) self.metadata_get_result_table_storage = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_result_table_storage/', - description=u'查询指定结果表的指定存储信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_result_table_storage/", + description="查询指定结果表的指定存储信息", ) self.metadata_get_time_series_group = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_time_series_group/', - description=u'获取自定义时序分组具体内容' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_time_series_group/", + description="获取自定义时序分组具体内容", ) self.metadata_get_time_series_metrics = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_time_series_metrics/', - description=u'获取自定义时序结果表的metrics信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_get_time_series_metrics/", + description="获取自定义时序结果表的metrics信息", ) self.metadata_list_label = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_list_label/', - description=u'查询当前已有的标签信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_list_label/", + description="查询当前已有的标签信息", ) self.metadata_list_result_table = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_list_result_table/', - description=u'查询监控结果表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_list_result_table/", + description="查询监控结果表", ) self.metadata_list_transfer_cluster = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_list_transfer_cluster/', - description=u'获取所有transfer集群信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_list_transfer_cluster/", + description="获取所有transfer集群信息", ) self.metadata_modify_cluster_info = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_cluster_info/', - description=u'修改存储集群信息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_cluster_info/", + description="修改存储集群信息", ) self.metadata_modify_data_id = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_data_id/', - description=u'修改指定数据源的配置信息' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_data_id/", + description="修改指定数据源的配置信息", ) self.metadata_modify_event_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_event_group/', - description=u'修改事件分组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_event_group/", + description="修改事件分组", ) self.metadata_modify_result_table = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_result_table/', - description=u'修改监控结果表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_result_table/", + description="修改监控结果表", ) self.metadata_modify_time_series_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_time_series_group/', - description=u'修改自定义时序分组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_modify_time_series_group/", + description="修改自定义时序分组", ) self.metadata_query_event_group = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_query_event_group/', - description=u'创建事件分组' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_query_event_group/", + description="创建事件分组", ) self.metadata_query_tag_values = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_query_tag_values/', - description=u'获取自定义时序分组具体内容' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_query_tag_values/", + description="获取自定义时序分组具体内容", ) self.metadata_query_time_series_group = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_query_time_series_group/', - description=u'查询事件分组' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_query_time_series_group/", + description="查询事件分组", ) self.metadata_upgrade_result_table = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/metadata_upgrade_result_table/', - description=u'将指定的监控单业务结果表升级为全业务结果表' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/metadata_upgrade_result_table/", + description="将指定的监控单业务结果表升级为全业务结果表", ) self.modify_custom_event_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/modify_custom_event_group/', - description=u'修改自定义事件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/modify_custom_event_group/", + description="修改自定义事件", ) self.modify_custom_time_series = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/modify_custom_time_series/', - description=u'修改自定义指标' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/modify_custom_time_series/", + description="修改自定义指标", ) self.proxy_host_info = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/proxy_host_info/', - description=u'获取自定义上报的proxy主机信息' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/proxy_host_info/", + description="获取自定义上报的proxy主机信息", ) self.query_collect_config = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/query_collect_config/', - description=u'查询采集配置' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/query_collect_config/", + description="查询采集配置", ) self.query_custom_event_group = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/query_custom_event_group/', - description=u'获取业务下自定义事件列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/query_custom_event_group/", + description="获取业务下自定义事件列表", ) self.retry_target_nodes = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/retry_target_nodes/', - description=u'重试部分实例或主机' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/retry_target_nodes/", + description="重试部分实例或主机", ) self.rollback_deployment_config = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/rollback_deployment_config/', - description=u'采集配置回滚' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/rollback_deployment_config/", + description="采集配置回滚", ) self.save_alarm_strategy = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/save_alarm_strategy/', - description=u'保存告警策略' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/save_alarm_strategy/", + description="保存告警策略", ) self.save_collect_config = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/save_collect_config/', - description=u'创建/保存采集配置' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/save_collect_config/", + description="创建/保存采集配置", ) self.save_notice_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/save_notice_group/', - description=u'保存通知组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/save_notice_group/", + description="保存通知组", ) self.search_alarm_strategy = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/search_alarm_strategy/', - description=u'查询告警策略' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/search_alarm_strategy/", + description="查询告警策略", ) self.search_event = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/search_event/', - description=u'查询事件' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/search_event/", + description="查询事件", ) self.search_notice_group = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/search_notice_group/', - description=u'查询通知组' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/search_notice_group/", + description="查询通知组", ) self.switch_alarm_strategy = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/switch_alarm_strategy/', - description=u'启停告警策略' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/switch_alarm_strategy/", + description="启停告警策略", ) self.toggle_collect_config_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/toggle_collect_config_status/', - description=u'启停采集配置' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/toggle_collect_config_status/", + description="启停采集配置", ) self.upgrade_collect_plugin = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/monitor_v3/upgrade_collect_plugin/', - description=u'采集配置插件升级' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/monitor_v3/upgrade_collect_plugin/", + description="采集配置插件升级", ) self.validate_custom_event_group_name = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/validate_custom_event_group_name/', - description=u'校验自定义事件名称是否合法' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/validate_custom_event_group_name/", + description="校验自定义事件名称是否合法", ) self.validate_custom_ts_group_name = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/monitor_v3/validate_custom_ts_group_name/', - description=u'校验自定义指标名称是否合法' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/monitor_v3/validate_custom_ts_group_name/", + description="校验自定义指标名称是否合法", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/sops.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/sops.py index 6387c5c..901f844 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/sops.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/sops.py @@ -1,170 +1,201 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsSOPS(object): +class CollectionsSOPS: """Collections of SOPS APIS""" def __init__(self, client): self.client = client self.claim_functionalization_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/claim_functionalization_task/', - description=u'认领职能化任务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/claim_functionalization_task/", + description="认领职能化任务", ) self.create_periodic_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/create_periodic_task/', - description=u'通过流程模板新建周期任务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/create_periodic_task/", + description="通过流程模板新建周期任务", ) self.create_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/create_task/', - description=u'通过流程模板新建任务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/create_task/", + description="通过流程模板新建任务", ) self.fast_create_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/fast_create_task/', - description=u'快速新建一次性任务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/fast_create_task/", + description="快速新建一次性任务", ) self.get_common_template_info = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_common_template_info/', - description=u'查询单个公共流程模板详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_common_template_info/", + description="查询单个公共流程模板详情", ) self.get_common_template_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_common_template_list/', - description=u'查询公共模板列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_common_template_list/", + description="查询公共模板列表", ) self.get_periodic_task_info = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_periodic_task_info/', - description=u'查询业务下的某个周期任务详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_periodic_task_info/", + description="查询业务下的某个周期任务详情", ) self.get_periodic_task_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_periodic_task_list/', - description=u'查询业务下的周期任务列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_periodic_task_list/", + description="查询业务下的周期任务列表", ) self.get_plugin_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_plugin_list/', - description=u'查询某个业务下的插件列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_plugin_list/", + description="查询某个业务下的插件列表", ) self.get_task_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_task_detail/', - description=u'查询任务执行详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_task_detail/", + description="查询任务执行详情", ) self.get_task_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_task_list/', - description=u'获取业务下的任务列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_task_list/", + description="获取业务下的任务列表", ) self.get_task_node_data = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_task_node_data/', - description=u'获取节点执行数据' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_task_node_data/", + description="获取节点执行数据", ) self.get_task_node_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_task_node_detail/', - description=u'查询任务节点执行详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_task_node_detail/", + description="查询任务节点执行详情", ) self.get_task_status = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_task_status/', - description=u'查询任务或任务节点执行状态' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_task_status/", + description="查询任务或任务节点执行状态", ) self.get_tasks_status = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/get_tasks_status/', - description=u'批量查询任务状态' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/get_tasks_status/", + description="批量查询任务状态", ) self.get_template_info = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_template_info/', - description=u'查询单个模板详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_template_info/", + description="查询单个模板详情", ) self.get_template_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_template_list/', - description=u'查询模板列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_template_list/", + description="查询模板列表", ) self.get_template_schemes = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_template_schemes/', - description=u'获取模板执行方案列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_template_schemes/", + description="获取模板执行方案列表", ) self.get_user_project_detail = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_user_project_detail/', - description=u'获取项目详情' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_user_project_detail/", + description="获取项目详情", ) self.get_user_project_list = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/sops/get_user_project_list/', - description=u'获取用户有权限的项目列表' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/sops/get_user_project_list/", + description="获取用户有权限的项目列表", ) self.import_common_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/import_common_template/', - description=u'导入公共流程' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/import_common_template/", + description="导入公共流程", ) self.import_project_template = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/import_project_template/', - description=u'导入业务流程模板' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/import_project_template/", + description="导入业务流程模板", ) self.modify_constants_for_periodic_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/modify_constants_for_periodic_task/', - description=u'修改周期任务的全局参数' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/modify_constants_for_periodic_task/", + description="修改周期任务的全局参数", ) self.modify_constants_for_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/modify_constants_for_task/', - description=u'修改任务的全局参数' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/modify_constants_for_task/", + description="修改任务的全局参数", ) self.modify_cron_for_periodic_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/modify_cron_for_periodic_task/', - description=u'修改周期任务的调度策略' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/modify_cron_for_periodic_task/", + description="修改周期任务的调度策略", ) self.node_callback = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/node_callback/', - description=u'回调任务节点' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/node_callback/", + description="回调任务节点", ) self.operate_node = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/operate_node/', - description=u'操作任务中的节点' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/operate_node/", + description="操作任务中的节点", ) self.operate_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/operate_task/', - description=u'操作任务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/operate_task/", + description="操作任务", ) self.preview_task_tree = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/preview_task_tree/', - description=u'获取节点选择后新的任务树' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/preview_task_tree/", + description="获取节点选择后新的任务树", ) self.query_task_count = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/query_task_count/', - description=u'查询任务分类统计总数' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/query_task_count/", + description="查询任务分类统计总数", ) self.set_periodic_task_enabled = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/set_periodic_task_enabled/', - description=u'设置周期任务是否激活' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/set_periodic_task_enabled/", + description="设置周期任务是否激活", ) self.start_task = ComponentAPI( - client=self.client, method='POST', - path='/api/c/compapi{bk_api_ver}/sops/start_task/', - description=u'开始执行任务' + client=self.client, + method="POST", + path="/api/c/compapi{bk_api_ver}/sops/start_task/", + description="开始执行任务", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/usermanage.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/usermanage.py index 0c9abc1..1cc4a0f 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/usermanage.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/apis/usermanage.py @@ -1,45 +1,51 @@ -# -*- coding: utf-8 -*- from ..base import ComponentAPI -class CollectionsUSERMANAGE(object): +class CollectionsUSERMANAGE: """Collections of USERMANAGE APIS""" def __init__(self, client): self.client = client self.department_ancestor = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/usermanage/department_ancestor/', - description=u'查询部门全部祖先 (旧版接口,不推荐使用,后续会下架,请尽快迁移)' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/usermanage/department_ancestor/", + description="查询部门全部祖先 (旧版接口,不推荐使用,后续会下架,请尽快迁移)", ) self.list_department_profiles = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/usermanage/list_department_profiles/', - description=u'查询部门的用户信息 (v2)' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/usermanage/list_department_profiles/", + description="查询部门的用户信息 (v2)", ) self.list_departments = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/usermanage/list_departments/', - description=u'查询部门 (v2)' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/usermanage/list_departments/", + description="查询部门 (v2)", ) self.list_profile_departments = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/usermanage/list_profile_departments/', - description=u'查询用户的部门信息 (v2)' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/usermanage/list_profile_departments/", + description="查询用户的部门信息 (v2)", ) self.list_users = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/usermanage/list_users/', - description=u'查询用户 (v2)' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/usermanage/list_users/", + description="查询用户 (v2)", ) self.retrieve_department = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/usermanage/retrieve_department/', - description=u'查询单个部门信息 (v2)' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/usermanage/retrieve_department/", + description="查询单个部门信息 (v2)", ) self.retrieve_user = ComponentAPI( - client=self.client, method='GET', - path='/api/c/compapi{bk_api_ver}/usermanage/retrieve_user/', - description=u'查询单个用户信息 (v2)' + client=self.client, + method="GET", + path="/api/c/compapi{bk_api_ver}/usermanage/retrieve_user/", + description="查询单个用户信息 (v2)", ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/base.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/base.py index 3398599..b31af41 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/base.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/base.py @@ -1,15 +1,13 @@ -# -*- coding: utf-8 -*- import json import logging -from .exceptions import ComponentAPIException from .conf import COMPONENT_SYSTEM_HOST - +from .exceptions import ComponentAPIException logger = logging.getLogger("component") -class ComponentAPI(object): +class ComponentAPI: """Single API for Component""" HTTP_STATUS_OK = 200 @@ -38,7 +36,7 @@ def __call__(self, *args, **kwargs): log_message = [ e.error_message, ] - log_message.append("url=%(url)s" % {"url": e.api_obj.url}) + log_message.append("url={url}".format(url=e.api_obj.url)) if e.resp: log_message.append("content: %s" % e.resp.text) @@ -72,7 +70,7 @@ def _call(self, *args, **kwargs): resp = self.client.request(self.method, self.url, params=params, data=data) except Exception as e: logger.exception("Error occurred when requesting method=%s url=%s", self.method, self.url) - raise ComponentAPIException(self, u"Request component error, Exception: %s" % str(e)) + raise ComponentAPIException(self, "Request component error, Exception: %s" % str(e)) # Parse result if resp.status_code != self.HTTP_STATUS_OK: @@ -84,8 +82,8 @@ def _call(self, *args, **kwargs): if not json_resp["result"]: # 组件返回错误时,记录相应的 request_id log_message = ( - u"Component return error message: %(message)s, request_id=%(request_id)s, " - u"url=%(url)s, params=%(params)s, data=%(data)s, response=%(response)s" + "Component return error message: %(message)s, request_id=%(request_id)s, " + "url=%(url)s, params=%(params)s, data=%(data)s, response=%(response)s" ) % { "request_id": json_resp.get("request_id"), "message": json_resp["message"], diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/client.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/client.py index e2d3dba..01cc5bd 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/client.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/client.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -"""Component API Client -""" +"""Component API Client""" + import json import logging import random @@ -22,7 +21,7 @@ logger = logging.getLogger("component") -class BaseComponentClient(object): +class BaseComponentClient: """Base client class for component""" @classmethod @@ -107,7 +106,7 @@ def request(self, method, url, params=None, data=None, **kwargs): def __getattr__(self, key): if key not in self.available_collections: - return getattr(super(BaseComponentClient, self), key) + return getattr(super(), key) if key not in self._cached_collections: collection = self.available_collections[key] diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/collections.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/collections.py index 619901d..f20daf8 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/collections.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/collections.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- """Collections for component client""" + from .apis.bk_login import CollectionsBkLogin from .apis.bk_paas import CollectionsBkPaas from .apis.cc import CollectionsCC @@ -12,18 +12,17 @@ from .apis.sops import CollectionsSOPS from .apis.usermanage import CollectionsUSERMANAGE - # Available components AVAILABLE_COLLECTIONS = { - 'bk_login': CollectionsBkLogin, - 'bk_paas': CollectionsBkPaas, - 'cc': CollectionsCC, - 'cmsi': CollectionsCMSI, - 'gse': CollectionsGSE, - 'itsm': CollectionsITSM, - 'job': CollectionsJOB, - 'jobv3': CollectionsJOBV3, - 'monitor_v3': CollectionsMonitorV3, - 'sops': CollectionsSOPS, - 'usermanage': CollectionsUSERMANAGE, + "bk_login": CollectionsBkLogin, + "bk_paas": CollectionsBkPaas, + "cc": CollectionsCC, + "cmsi": CollectionsCMSI, + "gse": CollectionsGSE, + "itsm": CollectionsITSM, + "job": CollectionsJOB, + "jobv3": CollectionsJOBV3, + "monitor_v3": CollectionsMonitorV3, + "sops": CollectionsSOPS, + "usermanage": CollectionsUSERMANAGE, } diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/compat.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/compat.py index 0426fa2..d8ad1ad 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/compat.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/compat.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import sys _ver = sys.version_info diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/conf.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/conf.py index 84a9f80..a4e9e06 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/conf.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/conf.py @@ -1,7 +1,4 @@ -# -*- coding: utf-8 -*- -"""Django project settings -""" - +"""Django project settings""" try: from django.conf import settings diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/exceptions.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/exceptions.py index 6d9a852..b509289 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/exceptions.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/exceptions.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - - class ComponentBaseException(Exception): pass @@ -14,5 +11,5 @@ def __init__(self, api_obj, error_message, resp=None): self.resp = resp if self.resp is not None: - error_message = "%s, resp=%s" % (error_message, self.resp.text) - super(ComponentAPIException, self).__init__(error_message) + error_message = "{}, resp={}".format(error_message, self.resp.text) + super().__init__(error_message) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/shortcuts.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/shortcuts.py index f042112..e725275 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/shortcuts.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/shortcuts.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- import logging -from .client import ComponentClient from . import conf +from .client import ComponentClient logger = logging.getLogger("component") diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/utils.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/utils.py index 46fd0a7..bc75899 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/utils.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/utils.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- -import json import base64 -import hmac import hashlib +import hmac +import json from .compat import str @@ -15,8 +14,8 @@ def get_signature(method, path, app_secret, params=None, data=None): if data: data = json.dumps(data) if isinstance(data, dict) else data kwargs["data"] = data - kwargs = "&".join(["%s=%s" % (k, v) for k, v in sorted(kwargs.items(), key=lambda x: x[0])]) - orignal = "%s%s?%s" % (method, path, kwargs) + kwargs = "&".join(["{}={}".format(k, v) for k, v in sorted(kwargs.items(), key=lambda x: x[0])]) + orignal = "{}{}?{}".format(method, path, kwargs) app_secret = app_secret.encode("utf-8") if isinstance(app_secret, str) else app_secret orignal = orignal.encode("utf-8") if isinstance(orignal, str) else orignal signature = base64.b64encode(hmac.new(app_secret, orignal, hashlib.sha1).digest()) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_client.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_client.py index 759824b..2f041c5 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_client.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_client.py @@ -1,11 +1,9 @@ -# -*- coding: utf-8 -*- import json -from django.test import TestCase - from blueking.component import collections from blueking.component.client import BaseComponentClient, ComponentClientWithSignature from blueking.tests.utils.utils import tests_settings as TS # noqa +from django.test import TestCase class TestBaseComponentClient(TestCase): @@ -17,40 +15,40 @@ def setUpTestData(cls): # noqa def test_api_get(self): client = self.ComponentClient( - TS['valid_app']['bk_app_code'], - TS['valid_app']['bk_app_secret'], + TS["valid_app"]["bk_app_code"], + TS["valid_app"]["bk_app_secret"], common_args={ - 'bk_username': TS['bk_user']['bk_username'], - } + "bk_username": TS["bk_user"]["bk_username"], + }, ) result = client.bk_login.get_user() - self.assertTrue(result['result'], json.dumps(result)) - self.assertTrue(result['data']['bk_username'], TS['bk_user']['bk_username']) + self.assertTrue(result["result"], json.dumps(result)) + self.assertTrue(result["data"]["bk_username"], TS["bk_user"]["bk_username"]) def test_api_post(self): client = self.ComponentClient( - TS['valid_app']['bk_app_code'], - TS['valid_app']['bk_app_secret'], + TS["valid_app"]["bk_app_code"], + TS["valid_app"]["bk_app_secret"], common_args={ - 'bk_username': TS['bk_user']['bk_username'], - } + "bk_username": TS["bk_user"]["bk_username"], + }, ) - result = client.bk_login.get_batch_users({'bk_username_list': [TS['bk_user']['bk_username']]}) - self.assertTrue(result['result'], json.dumps(result)) - self.assertTrue(result['data'][TS['bk_user']['bk_username']]['bk_username'], TS['bk_user']['bk_username']) + result = client.bk_login.get_batch_users({"bk_username_list": [TS["bk_user"]["bk_username"]]}) + self.assertTrue(result["result"], json.dumps(result)) + self.assertTrue(result["data"][TS["bk_user"]["bk_username"]]["bk_username"], TS["bk_user"]["bk_username"]) def test_set_bk_api_ver(self): client = self.ComponentClient( - TS['valid_app']['bk_app_code'], - TS['valid_app']['bk_app_secret'], + TS["valid_app"]["bk_app_code"], + TS["valid_app"]["bk_app_secret"], common_args={ - 'bk_username': TS['bk_user']['bk_username'], - } + "bk_username": TS["bk_user"]["bk_username"], + }, ) - client.set_bk_api_ver('') - result = client.bk_login.get_user({'username': TS['bk_user']['bk_username']}) - self.assertTrue(result['result'], json.dumps(result)) - self.assertTrue(result['data']['username'], TS['bk_user']['bk_username']) + client.set_bk_api_ver("") + result = client.bk_login.get_user({"username": TS["bk_user"]["bk_username"]}) + self.assertTrue(result["result"], json.dumps(result)) + self.assertTrue(result["data"]["username"], TS["bk_user"]["bk_username"]) class TestComponentClientWithSignature(TestCase): @@ -62,24 +60,24 @@ def setUpTestData(cls): # noqa def test_api(self): client = self.ComponentClient( - TS['valid_app']['bk_app_code'], - TS['valid_app']['bk_app_secret'], + TS["valid_app"]["bk_app_code"], + TS["valid_app"]["bk_app_secret"], common_args={ - 'bk_username': TS['bk_user']['bk_username'], - } + "bk_username": TS["bk_user"]["bk_username"], + }, ) result = client.bk_login.get_user() - self.assertTrue(result['result'], json.dumps(result)) - self.assertTrue(result['data']['bk_username'], TS['bk_user']['bk_username']) + self.assertTrue(result["result"], json.dumps(result)) + self.assertTrue(result["data"]["bk_username"], TS["bk_user"]["bk_username"]) def test_api_post(self): client = self.ComponentClient( - TS['valid_app']['bk_app_code'], - TS['valid_app']['bk_app_secret'], + TS["valid_app"]["bk_app_code"], + TS["valid_app"]["bk_app_secret"], common_args={ - 'bk_username': TS['bk_user']['bk_username'], - } + "bk_username": TS["bk_user"]["bk_username"], + }, ) - result = client.bk_login.get_batch_users({'bk_username_list': [TS['bk_user']['bk_username']]}) - self.assertTrue(result['result'], json.dumps(result)) - self.assertTrue(result['data'][TS['bk_user']['bk_username']]['bk_username'], TS['bk_user']['bk_username']) + result = client.bk_login.get_batch_users({"bk_username_list": [TS["bk_user"]["bk_username"]]}) + self.assertTrue(result["result"], json.dumps(result)) + self.assertTrue(result["data"][TS["bk_user"]["bk_username"]]["bk_username"], TS["bk_user"]["bk_username"]) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_shortcuts.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_shortcuts.py index 4b2494b..942377d 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_shortcuts.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_shortcuts.py @@ -1,11 +1,9 @@ -# -*- coding: utf-8 -*- import json -from django.test import TestCase, RequestFactory - -from blueking.component.shortcuts import get_client_by_user, get_client_by_request -from blueking.tests.utils.utils import tests_settings as TS # noqa +from blueking.component.shortcuts import get_client_by_request, get_client_by_user from blueking.tests.utils.utils import get_user_model +from blueking.tests.utils.utils import tests_settings as TS # noqa +from django.test import RequestFactory, TestCase class TestShortcuts(TestCase): @@ -15,23 +13,23 @@ def setUp(self): self.user_model = get_user_model() def test_get_client_by_request(self): - request = self.factory.get('/') - request.user = self.user_model(username=TS['bk_user']['bk_username']) - request.COOKIES = {'bk_token': TS['bk_user']['bk_token']} + request = self.factory.get("/") + request.user = self.user_model(username=TS["bk_user"]["bk_username"]) + request.COOKIES = {"bk_token": TS["bk_user"]["bk_token"]} client = get_client_by_request(request) result = client.bk_login.get_user() - self.assertTrue(result['result'], json.dumps(result)) - self.assertEqual(result['data']['bk_username'], TS['bk_user']['bk_username']) + self.assertTrue(result["result"], json.dumps(result)) + self.assertEqual(result["data"]["bk_username"], TS["bk_user"]["bk_username"]) def test_get_client_by_user(self): - user = self.user_model(username=TS['bk_user']['bk_username']) + user = self.user_model(username=TS["bk_user"]["bk_username"]) client = get_client_by_user(user) result = client.bk_login.get_user() - self.assertTrue(result['result'], json.dumps(result)) - self.assertEqual(result['data']['bk_username'], TS['bk_user']['bk_username']) + self.assertTrue(result["result"], json.dumps(result)) + self.assertEqual(result["data"]["bk_username"], TS["bk_user"]["bk_username"]) - client = get_client_by_user(TS['bk_user']['bk_username']) + client = get_client_by_user(TS["bk_user"]["bk_username"]) result = client.bk_login.get_user() - self.assertTrue(result['result'], json.dumps(result)) - self.assertEqual(result['data']['bk_username'], TS['bk_user']['bk_username']) + self.assertTrue(result["result"], json.dumps(result)) + self.assertEqual(result["data"]["bk_username"], TS["bk_user"]["bk_username"]) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_utils.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_utils.py index 369b5b2..5b5049c 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_utils.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/test_utils.py @@ -1,27 +1,25 @@ -# -*- coding: utf-8 -*- -from django.test import TestCase - from blueking.component.utils import get_signature +from django.test import TestCase class TestUtils(TestCase): def test_get_signature(self): params = { - 'method': 'GET', - 'path': '/blueking/component/', - 'app_secret': 'test', - 'params': {'p1': 1, 'p2': 'abc'}, + "method": "GET", + "path": "/blueking/component/", + "app_secret": "test", + "params": {"p1": 1, "p2": "abc"}, } signature = get_signature(**params) - self.assertEqual(signature, 'S73XVZx3HvPRcak1z3k7jUkA7FM=') + self.assertEqual(signature, "S73XVZx3HvPRcak1z3k7jUkA7FM=") params = { - 'method': 'POST', - 'path': '/blueking/component/', - 'app_secret': 'test', - 'data': {'p1': 1, 'p2': 'abc'}, + "method": "POST", + "path": "/blueking/component/", + "app_secret": "test", + "data": {"p1": 1, "p2": "abc"}, } # python3 could sort the dict signature = get_signature(**params) - self.assertIn(signature, ['qTzporCDYXqaWKuk/MNUXPT3A5U=', 'PnmqLk/8PVpsLHDFkolCQoi5lmg=']) + self.assertIn(signature, ["qTzporCDYXqaWKuk/MNUXPT3A5U=", "PnmqLk/8PVpsLHDFkolCQoi5lmg="]) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/utils/utils.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/utils/utils.py index 369df94..cc34d20 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/utils/utils.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/tests/utils/utils.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - - def get_user_model(): try: from account.models import BkUser as User @@ -11,14 +8,14 @@ def get_user_model(): def load_tests_settings(): return { - 'valid_app': { - 'bk_app_code': '', - 'bk_app_secret': '', + "valid_app": { + "bk_app_code": "", + "bk_app_secret": "", + }, + "bk_user": { + "bk_username": "admin", + "bk_token": "", }, - 'bk_user': { - 'bk_username': 'admin', - 'bk_token': '', - } } diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/settings.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/settings.py index dda19d4..aef4098 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/settings.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/settings.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -11,6 +10,7 @@ """ import os + import pymysql pymysql.install_as_MySQLdb() @@ -33,7 +33,7 @@ try: _module = __import__(DJANGO_CONF_MODULE, globals(), locals(), ["*"]) except ImportError as e: - raise ImportError("Could not import config '%s' (Is it on sys.path?): %s" % (DJANGO_CONF_MODULE, e)) + raise ImportError("Could not import config '{}' (Is it on sys.path?): {}".format(DJANGO_CONF_MODULE, e)) for _setting in dir(_module): if _setting == _setting.upper(): diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/urls.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/urls.py index 8a88d0c..032a00b 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/urls.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. @@ -11,11 +10,11 @@ """ from django.conf import settings -from django.urls import include, re_path from django.contrib import admin -from rest_framework import permissions -from drf_yasg.views import get_schema_view +from django.urls import include, re_path from drf_yasg import openapi +from drf_yasg.views import get_schema_view +from rest_framework import permissions schema_view = get_schema_view( openapi.Info( diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/wsgi.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/wsgi.py index 6c0d6da..13c3e82 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/wsgi.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/wsgi.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/template/{{cookiecutter.project_name}}/bin/manage.py b/template/{{cookiecutter.project_name}}/bin/manage.py index aa5c1d4..8d808e1 100644 --- a/template/{{cookiecutter.project_name}}/bin/manage.py +++ b/template/{{cookiecutter.project_name}}/bin/manage.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/template/{{cookiecutter.project_name}}/bk_plugin/__init__.py b/template/{{cookiecutter.project_name}}/bk_plugin/__init__.py index 872e779..a7d8957 100644 --- a/template/{{cookiecutter.project_name}}/bk_plugin/__init__.py +++ b/template/{{cookiecutter.project_name}}/bk_plugin/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. diff --git a/template/{{cookiecutter.project_name}}/bk_plugin/versions/v1_0_0.py b/template/{{cookiecutter.project_name}}/bk_plugin/versions/v1_0_0.py index 95a8004..fb91918 100644 --- a/template/{{cookiecutter.project_name}}/bk_plugin/versions/v1_0_0.py +++ b/template/{{cookiecutter.project_name}}/bk_plugin/versions/v1_0_0.py @@ -1,12 +1,12 @@ import logging from bk_plugin_framework.kit import ( - Plugin, + Context, + ContextRequire, + Field, InputsModel, OutputsModel, - Field, - ContextRequire, - Context, + Plugin, ) logger = logging.getLogger("bk_plugin") From 1054d0761a671bf3e354175236f8ad313baa9aae Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Tue, 30 Dec 2025 17:04:48 +0800 Subject: [PATCH 02/17] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E@extend=5Fschem?= =?UTF-8?q?a=E8=A3=85=E9=A5=B0=E5=99=A8=E5=A3=B0=E6=98=8E=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BB=A5=E6=94=AF=E6=8C=81=E8=87=AA=E5=8A=A8=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=E8=93=9D=E9=B2=B8API=E7=BD=91=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bk_plugin_framework/serializers.py | 2 +- .../services/bpf_service/api/callback.py | 20 +++++++++++++++---- .../services/bpf_service/api/invoke.py | 12 +++++------ .../bpf_service/api/plugin_api_dispatch.py | 12 +++++------ .../services/bpf_service/api/schedule.py | 15 +++++++++----- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/bk-plugin-framework/bk_plugin_framework/serializers.py b/bk-plugin-framework/bk_plugin_framework/serializers.py index 36bcc49..3bc24cb 100644 --- a/bk-plugin-framework/bk_plugin_framework/serializers.py +++ b/bk-plugin-framework/bk_plugin_framework/serializers.py @@ -3,7 +3,7 @@ def enveloper(serializer_class, many: bool = False): - """统一响应包装器(参考您的模式)""" + """统一响应包装器""" component_name = "Enveloped{}{}".format( serializer_class.__name__.replace("Serializer", ""), "List" if many else "", diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py index a1d1e42..b12e4d1 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py @@ -15,9 +15,11 @@ from apigw_manager.apigw.decorators import apigw_require from bk_plugin_framework.runtime.callback.api import callback, parse_callback_token +from bk_plugin_framework.serializers import enveloper from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator -from drf_yasg.utils import swagger_auto_schema +from drf_spectacular.utils import extend_schema +from rest_framework import serializers from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView @@ -25,14 +27,24 @@ logger = logging.getLogger("bk_plugin") +class PluginCallbackParamsSerializer(serializers.Serializer): + token = serializers.CharField(help_text="插件回调token", required=True) + + +class PluginCallbackResponseSerializer(serializers.Serializer): + result = serializers.BooleanField(help_text="回调结果,True表示成功,False表示失败") + message = serializers.CharField(help_text="回调结果信息", required=False) + + @method_decorator(login_exempt, name="dispatch") @method_decorator(apigw_require, name="dispatch") class PluginCallback(APIView): authentication_classes = [] # csrf exempt - @swagger_auto_schema( - method="POST", - operation_summary="plugin callback", + @extend_schema( + summary="插件回调", + request=PluginCallbackParamsSerializer, + responses={200: enveloper(PluginCallbackResponseSerializer)}, ) @action(methods=["POST"], detail=True) def post(self, request, token): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py index 78f7221..97d7297 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py @@ -14,6 +14,7 @@ from apigw_manager.apigw.decorators import apigw_require from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.runtime.executor import BKPluginExecutor +from bk_plugin_framework.serializers import enveloper from bk_plugin_framework.services.bpf_service.api.permissions import ( ScopeAllowPermission, ) @@ -22,7 +23,7 @@ ) from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator -from drf_yasg.utils import swagger_auto_schema +from drf_spectacular.utils import extend_schema from rest_framework import serializers, status from rest_framework.decorators import action from rest_framework.exceptions import ValidationError @@ -55,11 +56,10 @@ class Invoke(APIView): authentication_classes = [] # csrf exempt permission_classes = [ScopeAllowPermission] - @swagger_auto_schema( - method="POST", - operation_summary="Invoke specific version plugin", - request_body=InvokeParamsSerializer, - responses={200: InvokeResponseSerializer}, + @extend_schema( + summary="插件调用", + request=InvokeParamsSerializer, + responses={200: enveloper(InvokeResponseSerializer)}, ) @action(methods=["POST"], detail=True) def post(self, request, version): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py index 716daaa..e5a3217 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py @@ -15,6 +15,7 @@ from urllib.parse import urlsplit from apigw_manager.apigw.decorators import apigw_require +from bk_plugin_framework.serializers import enveloper from bk_plugin_framework.services.bpf_service.api.permissions import ( ScopeAllowPermission, ) @@ -25,7 +26,7 @@ from django.test import RequestFactory from django.urls import Resolver404, resolve from django.utils.decorators import method_decorator -from drf_yasg.utils import swagger_auto_schema +from drf_spectacular.utils import extend_schema from rest_framework import serializers, status from rest_framework.decorators import action from rest_framework.exceptions import ValidationError @@ -76,11 +77,10 @@ class PluginAPIDispatch(APIView): authentication_classes = [] # csrf exempt permission_classes = [ScopeAllowPermission] - @swagger_auto_schema( - method="POST", - operation_summary="Plugin API dispatch", - request_body=PluginAPIDispatchParamsSerializer, - responses={200: PluginAPIDispatchResponseSerializer}, + @extend_schema( + summary="插件API分发", + request=PluginAPIDispatchParamsSerializer, + responses={200: enveloper(PluginAPIDispatchResponseSerializer)}, ) @action(methods=["POST"], detail=True) def post(self, request): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py index dd1c804..d9ff7e0 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py @@ -13,12 +13,13 @@ import logging from bk_plugin_framework.runtime.schedule.models import Schedule as ScheduleModel +from bk_plugin_framework.serializers import enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator -from drf_yasg.utils import swagger_auto_schema +from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers from rest_framework.decorators import action from rest_framework.response import Response @@ -27,6 +28,10 @@ logger = logging.getLogger("root") +class ScheduleParamsSerializer(serializers.Serializer): + trace_id = serializers.CharField(help_text="插件调用 trace id") + + class ScheduleResponseSerializer(StandardResponseSerializer): class ScheduleDataSerializer(serializers.Serializer): class Meta: @@ -48,10 +53,10 @@ class Schedule(APIView): permission_classes = [permissions.AllowAny] - @swagger_auto_schema( - method="GET", - operation_summary="Get plugin schedule detail with trace_id", - responses={200: ScheduleResponseSerializer}, + @extend_schema( + summary="获取插件调度详情", + request=ScheduleParamsSerializer, + responses={200: enveloper(ScheduleResponseSerializer)}, ) @action(methods=["GET"], detail=True) def get(self, request, trace_id): From b6bb861dcaa2c9a3265a8d753a57614ed28e39a8 Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Tue, 6 Jan 2026 20:09:38 +0800 Subject: [PATCH 03/17] =?UTF-8?q?feat:=20=E8=93=9D=E9=B2=B8=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=A1=86=E6=9E=B6=E9=9B=86=E6=88=90=E5=8F=AF=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E7=BD=91=E5=85=B3=E5=AE=9E=E7=8E=B0=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E5=8D=B3=E5=8F=91=E5=B8=83=E7=BD=91=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/bpf_service/api/callback.py | 10 ++ .../services/bpf_service/api/detail.py | 20 ++- .../services/bpf_service/api/invoke.py | 10 ++ .../services/bpf_service/api/logs.py | 20 ++- .../services/bpf_service/api/meta.py | 20 ++- .../bpf_service/api/plugin_api_dispatch.py | 10 ++ .../services/bpf_service/api/schedule.py | 10 ++ .../bpf_service/management/__init__.py | 10 -- .../management/commands/__init__.py | 10 -- .../commands/data/api-definition.yml | 35 ----- .../commands/data/api-resources.yml | 146 ------------------ .../commands/data/api-strategy-cors.yml | 13 -- .../management/commands/sync_plugin_apigw.py | 40 ----- .../bk_plugin_runtime/config/default.py | 105 ++++++++++++- .../app_desc.yml | 20 ++- .../bin/manage.py | 6 + .../bin/post_compile | 7 - .../bin/sync_apigateway.sh | 57 +++++++ .../requirements.txt | 82 +++++++++- 19 files changed, 336 insertions(+), 295 deletions(-) delete mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py delete mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py delete mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-definition.yml delete mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-resources.yml delete mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-strategy-cors.yml delete mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_plugin_apigw.py delete mode 100644 template/{{cookiecutter.project_name}}/bin/post_compile create mode 100755 template/{{cookiecutter.project_name}}/bin/sync_apigateway.sh diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py index b12e4d1..3271ea2 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py @@ -14,6 +14,7 @@ import traceback from apigw_manager.apigw.decorators import apigw_require +from apigw_manager.drf.utils import gen_apigateway_resource_config from bk_plugin_framework.runtime.callback.api import callback, parse_callback_token from bk_plugin_framework.serializers import enveloper from blueapps.account.decorators import login_exempt @@ -45,6 +46,15 @@ class PluginCallback(APIView): summary="插件回调", request=PluginCallbackParamsSerializer, responses={200: enveloper(PluginCallbackResponseSerializer)}, + extensions=gen_apigateway_resource_config( + is_public=True, + allow_apply_permission=True, + user_verified_required=True, + app_verified_required=True, + resource_permission_required=True, + description_en="插件调用", + match_subpath=False, + ), ) @action(methods=["POST"], detail=True) def post(self, request, token): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py index e3ff05b..a5ad39b 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py @@ -11,13 +11,15 @@ import logging +from apigw_manager.drf.utils import gen_apigateway_resource_config from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.serializers import enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator -from drf_yasg.utils import swagger_auto_schema +from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers, status from rest_framework.decorators import action from rest_framework.response import Response @@ -65,10 +67,18 @@ class DetailFormsSerializer(serializers.Serializer): class Detail(APIView): permission_classes = [permissions.AllowAny] - @swagger_auto_schema( - method="GET", - operation_summary="Get plugin detail for specific version", - responses={200: DetailResponseSerializer}, + @extend_schema( + summary="Get plugin detail for specific version", + responses={200: enveloper(DetailResponseSerializer)}, + extensions=gen_apigateway_resource_config( + is_public=True, + allow_apply_permission=True, + user_verified_required=True, + app_verified_required=True, + resource_permission_required=True, + description_en="插件调用", + match_subpath=False, + ), ) @action(methods=["GET"], detail=True) def get(self, request, version): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py index 97d7297..5a60e71 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py @@ -12,6 +12,7 @@ import logging from apigw_manager.apigw.decorators import apigw_require +from apigw_manager.drf.utils import gen_apigateway_resource_config from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.runtime.executor import BKPluginExecutor from bk_plugin_framework.serializers import enveloper @@ -60,6 +61,15 @@ class Invoke(APIView): summary="插件调用", request=InvokeParamsSerializer, responses={200: enveloper(InvokeResponseSerializer)}, + extensions=gen_apigateway_resource_config( + is_public=True, + allow_apply_permission=True, + user_verified_required=True, + app_verified_required=True, + resource_permission_required=True, + description_en="插件调用", + match_subpath=False, + ), ) @action(methods=["POST"], detail=True) def post(self, request, version): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py index 8726ffc..047ddf9 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py @@ -11,13 +11,15 @@ import logging +from apigw_manager.drf.utils import gen_apigateway_resource_config from bk_plugin_framework.runtime.loghub.models import LogEntry +from bk_plugin_framework.serializers import enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator -from drf_yasg.utils import swagger_auto_schema +from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers from rest_framework.decorators import action from rest_framework.response import Response @@ -41,10 +43,18 @@ class Logs(APIView): permission_classes = [permissions.AllowAny] - @swagger_auto_schema( - method="GET", - operation_summary="Get plugin execution log with trace_id", - responses={200: LogsResponseSerializer}, + @extend_schema( + summary="Get plugin execution log with trace_id", + responses={200: enveloper(LogsResponseSerializer)}, + extensions=gen_apigateway_resource_config( + is_public=True, + allow_apply_permission=True, + user_verified_required=True, + app_verified_required=True, + resource_permission_required=True, + description_en="插件调用", + match_subpath=False, + ), ) @action(methods=["GET"], detail=True) def get(self, request, trace_id): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py index 5f82b60..69dd691 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py @@ -12,15 +12,17 @@ import logging from importlib import import_module +from apigw_manager.drf.utils import gen_apigateway_resource_config from bk_plugin_framework import __version__ as bpf_version from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.serializers import enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) from blueapps.account.decorators import login_exempt from django.conf import settings from django.utils.decorators import method_decorator -from drf_yasg.utils import swagger_auto_schema +from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers from rest_framework.decorators import action from rest_framework.response import Response @@ -59,10 +61,18 @@ class Meta(APIView): permission_classes = [permissions.AllowAny] - @swagger_auto_schema( - method="GET", - operation_summary="Get plugin meta info", - responses={200: MetaResponseSerializer}, + @extend_schema( + summary="Get plugin meta info", + responses={200: enveloper(MetaResponseSerializer)}, + extensions=gen_apigateway_resource_config( + is_public=True, + allow_apply_permission=True, + user_verified_required=True, + app_verified_required=True, + resource_permission_required=True, + description_en="插件调用", + match_subpath=False, + ), ) @action(methods=["GET"], detail=True) def get(self, request): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py index e5a3217..62e3347 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py @@ -15,6 +15,7 @@ from urllib.parse import urlsplit from apigw_manager.apigw.decorators import apigw_require +from apigw_manager.drf.utils import gen_apigateway_resource_config from bk_plugin_framework.serializers import enveloper from bk_plugin_framework.services.bpf_service.api.permissions import ( ScopeAllowPermission, @@ -81,6 +82,15 @@ class PluginAPIDispatch(APIView): summary="插件API分发", request=PluginAPIDispatchParamsSerializer, responses={200: enveloper(PluginAPIDispatchResponseSerializer)}, + extensions=gen_apigateway_resource_config( + is_public=True, + allow_apply_permission=True, + user_verified_required=True, + app_verified_required=True, + resource_permission_required=True, + description_en="插件调用", + match_subpath=False, + ), ) @action(methods=["POST"], detail=True) def post(self, request): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py index d9ff7e0..cf05dec 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py @@ -12,6 +12,7 @@ import json import logging +from apigw_manager.drf.utils import gen_apigateway_resource_config from bk_plugin_framework.runtime.schedule.models import Schedule as ScheduleModel from bk_plugin_framework.serializers import enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( @@ -57,6 +58,15 @@ class Schedule(APIView): summary="获取插件调度详情", request=ScheduleParamsSerializer, responses={200: enveloper(ScheduleResponseSerializer)}, + extensions=gen_apigateway_resource_config( + is_public=True, + allow_apply_permission=True, + user_verified_required=True, + app_verified_required=True, + resource_permission_required=True, + description_en="插件调用", + match_subpath=False, + ), ) @action(methods=["GET"], detail=True) def get(self, request, trace_id): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py deleted file mode 100644 index a7d8957..0000000 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. -Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. -Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. -You may obtain a copy of the License at -http://opensource.org/licenses/MIT -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. -""" diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py deleted file mode 100644 index a7d8957..0000000 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. -Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. -Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. -You may obtain a copy of the License at -http://opensource.org/licenses/MIT -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. -""" diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-definition.yml b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-definition.yml deleted file mode 100644 index 3bfdd5d..0000000 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-definition.yml +++ /dev/null @@ -1,35 +0,0 @@ -stage: - name: {{ settings.BK_PLUGIN_APIGW_STAGE_NAME }} - {% if settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH %} - vars: - api_sub_path: {{ settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH }} - {% else %} - vars: {} - {% endif %} - proxy_http: - timeout: {{ settings.BK_APIGW_DEFAULT_TIMEOUT }} - upstreams: - loadbalance: "roundrobin" - hosts: - - host: "{{ settings.BK_PLUGIN_APIGW_BACKEND_SCHEME }}://{{ settings.BK_PLUGIN_APIGW_BACKEND_NETLOC }}/" - weight: 100 - plugin_configs: - - type: bk-cors - yaml: |- - allow_origins: '{{ settings.BK_APIGW_CORS_ALLOW_ORIGINS }}' - allow_methods: '{{ settings.BK_APIGW_CORS_ALLOW_METHODS }}' - allow_headers: '{{ settings.BK_APIGW_CORS_ALLOW_HEADERS }}' - expose_headers: '' - max_age: 86400 - allow_credential: true - -{% if settings.BK_APIGW_GRANTED_APPS %} -grant_permissions: - {% for app_code in settings.BK_APIGW_GRANTED_APPS %} - - bk_app_code: {{ app_code }} - grant_dimension: "gateway" - {% endfor %} -{% endif %} - -release: - comment: "auto release by bk-plugin-runtime" diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-resources.yml b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-resources.yml deleted file mode 100644 index edf3422..0000000 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-resources.yml +++ /dev/null @@ -1,146 +0,0 @@ -swagger: '2.0' -basePath: / -info: - version: '0.1' - title: API Gateway Resources - description: '' -schemes: -- http -paths: - /invoke/{version}/: - post: - operationId: invoke - description: invoke plugin - tags: [] - responses: - default: - description: '' - x-bk-apigateway-resource: - isPublic: true - allowApplyPermission: true - matchSubpath: false - backend: - type: HTTP - method: post - {% if settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH %} - path: /{env.api_sub_path}bk_plugin/invoke/{version} - {% else %} - path: /bk_plugin/invoke/{version} - {% endif %} - matchSubpath: false - timeout: 0 - upstreams: {} - transformHeaders: {} - authConfig: - userVerifiedRequired: false - disabledStages: [] - /plugin_api_dispatch: - post: - operationId: plugin_api_dispatch - description: '' - tags: [] - responses: - default: - description: '' - x-bk-apigateway-resource: - isPublic: true - allowApplyPermission: true - matchSubpath: false - backend: - type: HTTP - method: post - {% if settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH %} - path: /{env.api_sub_path}bk_plugin/plugin_api_dispatch/ - {% else %} - path: /bk_plugin/plugin_api_dispatch/ - {% endif %} - matchSubpath: false - timeout: 0 - upstreams: {} - transformHeaders: {} - authConfig: - userVerifiedRequired: false - disabledStages: [] - /bk_plugin/plugin_api/: - x-bk-apigateway-method-any: - operationId: plugin_api - description: '' - tags: [] - responses: - default: - description: '' - x-bk-apigateway-resource: - isPublic: true - allowApplyPermission: true - matchSubpath: true - backend: - type: HTTP - method: any - {% if settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH %} - path: /{env.api_sub_path}bk_plugin/plugin_api/ - {% else %} - path: /bk_plugin/plugin_api/ - {% endif %} - matchSubpath: true - timeout: 0 - upstreams: {} - transformHeaders: {} - authConfig: - userVerifiedRequired: true - appVerifiedRequired: false - disabledStages: [] - /bk_plugin/openapi/: - x-bk-apigateway-method-any: - operationId: plugin_openapi - description: '' - tags: [] - responses: - default: - description: '' - x-bk-apigateway-resource: - isPublic: true - allowApplyPermission: true - matchSubpath: true - backend: - type: HTTP - method: any - {% if settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH %} - path: /{env.api_sub_path}bk_plugin/openapi/ - {% else %} - path: /bk_plugin/openapi/ - {% endif %} - matchSubpath: true - timeout: 0 - upstreams: {} - transformHeaders: {} - authConfig: - userVerifiedRequired: false - appVerifiedRequired: true - disabledStages: [] - /callback/{token}/: - post: - operationId: callback - description: callback plugin - tags: [] - responses: - default: - description: '' - x-bk-apigateway-resource: - isPublic: true - allowApplyPermission: true - matchSubpath: false - backend: - type: HTTP - method: post - {% if settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH %} - path: /{env.api_sub_path}bk_plugin/callback/{token}/ - {% else %} - path: /bk_plugin/callback/{token}/ - {% endif %} - matchSubpath: false - timeout: 0 - upstreams: {} - transformHeaders: {} - authConfig: - userVerifiedRequired: false - disabledStages: [] diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-strategy-cors.yml b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-strategy-cors.yml deleted file mode 100644 index 01ad279..0000000 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/data/api-strategy-cors.yml +++ /dev/null @@ -1,13 +0,0 @@ -strategies: - - type: "cors" - comment: "" - name: "跨域资源共享(CORS)" - - config: - allowed_origins: {{ settings.BK_APIGW_CORS_ALLOW_ORIGINS }} - allowed_methods: {{ settings.BK_APIGW_CORS_ALLOW_METHODS }} - allowed_headers: {{ settings.BK_APIGW_CORS_ALLOW_HEADERS }} - exposed_headers: [] - max_age: 86400 - allow_credentials: true - option_passthrough: false \ No newline at end of file diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_plugin_apigw.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_plugin_apigw.py deleted file mode 100644 index 46c246b..0000000 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_plugin_apigw.py +++ /dev/null @@ -1,40 +0,0 @@ -""" -Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. -Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. -Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. -You may obtain a copy of the License at -http://opensource.org/licenses/MIT -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 os - -from django.conf import settings -from django.core.management import call_command -from django.core.management.base import BaseCommand - - -class Command(BaseCommand): - def handle(self, *args, **kwargs): - definition_file_path = os.path.join(__file__.rsplit("/", 1)[0], "data/api-definition.yml") - resources_file_path = os.path.join(__file__.rsplit("/", 1)[0], "data/api-resources.yml") - print("[bk-plugin-framework]call sync_apigw_stage with definition: %s" % definition_file_path) - call_command("sync_apigw_stage", file=definition_file_path) - print("[bk-plugin-framework]call sync_apigw_resources with resources: %s" % resources_file_path) - call_command("sync_apigw_resources", file=resources_file_path) - print("[bk-plugin-framework]call sync_apigw_strategies with definition: %s" % definition_file_path) - call_command("sync_apigw_strategies", file=definition_file_path) - print("[bk-plugin-framework]call grant_apigw_permissions with definition: %s" % definition_file_path) - call_command("grant_apigw_permissions", file=definition_file_path) - - # if getattr(settings, "BK_APIGW_CORS_ALLOW_ORIGINS"): - # strategy_cors_file_path = os.path.join(__file__.rsplit("/", 1)[0], "data/api-strategy-cors.yml") - # print("[bk-plugin-framework]call sync_apigw_strategies cors with strategy: %s" % strategy_cors_file_path) - # call_command("sync_apigw_strategies", file=strategy_cors_file_path) - - print("[bk-plugin-framework]call create_version_and_release_apigw with definition: %s" % definition_file_path) - call_command( - "create_version_and_release_apigw", file=definition_file_path, stage=[settings.BK_PLUGIN_APIGW_STAGE_NAME] - ) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py index 8ebe066..a704239 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py @@ -12,24 +12,33 @@ import json import os import urllib +from urllib.parse import urlparse +# 必须在导入 blueapps 之前导入 django-environ,避免与 blueapps.conf.environ 模块冲突 +import environ as django_environ from blueapps.conf.default_settings import * # noqa from blueapps.conf.log import get_logging_config_dict +# environ +env = django_environ.Env() +# load environment variables from .env file +django_environ.Env.read_env() + BKPAAS_ENVIRONMENT = os.getenv("BKPAAS_ENVIRONMENT", "dev") -# 默认关闭可观侧性 +# 默认关闭可观测性 ENABLE_OTEL_METRICS = os.getenv("ENABLE_METRICS", False) # 请在这里加入你的自定义 APP INSTALLED_APPS += ( # noqa - "rest_framework", - "drf_yasg", "bk_plugin_framework.runtime.loghub", "bk_plugin_framework.runtime.schedule", "bk_plugin_framework.runtime.callback", "bk_plugin_framework.services.bpf_service", - "apigw_manager.apigw", + "rest_framework", + "drf_spectacular", "django_dbconn_retry", + "apigw_manager.drf", + "apigw_manager.apigw", ) if ENABLE_OTEL_METRICS: INSTALLED_APPS += ("blueapps.opentelemetry.instrument_app",) # noqa @@ -80,8 +89,10 @@ ) # 用户认证 -AUTHENTICATION_BACKENDS += ("bk_plugin_runtime.packages.apigw.backends.APIGWUserModelBackend",) # noqa - +AUTHENTICATION_BACKENDS += ( + "bk_plugin_runtime.packages.apigw.backends.APIGWUserModelBackend", + "apigw_manager.apigw.authentication.UserModelBackend", +) # noqa # 所有环境的日志级别可以在这里配置 # LOG_LEVEL = 'INFO' @@ -222,6 +233,88 @@ def logging_addition_settings(logging_dict): break +# drf settings +REST_FRAMEWORK = { + "DEFAULT_AUTHENTICATION_CLASSES": [ + "apigw_manager.drf.authentication.ApiGatewayJWTAuthentication", + ], + "DEFAULT_PERMISSION_CLASSES": [ + "apigw_manager.drf.permission.ApiGatewayPermission", + ], + "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", +} + + +def preprocessing_filter_internal_apis(endpoints): + """ + 预处理钩子:排除不需要注册到 API 网关的内部 API + """ + # 需要排除的 API 路径模式 + excluded_patterns = [ + "/bk_plugin/detail", + "/bk_plugin/meta", + "/bk_plugin/logs", + ] + 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-` +BK_APIGW_IS_OFFICIAL = 1 if env.bool("BK_APIGW_IS_OFFICIAL", default=False) else 10 +# 网关管理员,请将负责人加入列表中 +BK_APIGW_MAINTAINERS = env.list("BK_APIGW_MAINTAINERS", default=["admin"]) +# 网关接口最大超时时间 +BK_APIGW_STAG_BACKEND_TIMEOUT = 60 + + +# analysis the app environment and address via bkpaas env vars +bkpaas_default_preallocated_urls = env.json("BKPAAS_DEFAULT_PREALLOCATED_URLS") +bkpaas_environment = env.str("BKPAAS_ENVIRONMENT") +app_address = bkpaas_default_preallocated_urls.get(bkpaas_environment) +parsed_url = urlparse(app_address) +app_scheme = parsed_url.scheme +app_domain = parsed_url.netloc +app_subpath = parsed_url.path.rstrip("/") + +BK_APIGW_STAGE_BACKEND_HOST = f"{app_scheme}://{app_domain}" +BK_APIGW_STAGE_BACKEND_SUBPATH = app_subpath + + +# while deploy app on staging env, it would sync to the stage=stag of the gateway +# while deploy app on production env, it would sync to the stage=prod of the gateway +BK_APIGW_STAGE_NAME = bkpaas_environment +BK_APIGW_STAGE_DESCRIPTION = "生产环境" if bkpaas_environment == "prod" else "预发布环境" +BK_APIGW_STAGE_DESCRIPTION_EN = "Production Env" if bkpaas_environment == "prod" else "Staging Env" +# 声明网关不同环境的环境变量 +stag_env_vars = {"foo": "bar"} +prod_env_vars = { + # "foo": "bar" +} +BK_APIGW_STAGE_ENV_VARS = prod_env_vars if bkpaas_environment == "prod" else stag_env_vars + +# 网关同步 API 文档语言, zh/en, 如果配置了BK_APIGW_RESOURCE_DOCS_BASE_DIR(使用自定义文档), 那么必须将这个变量置空 +BK_APIGW_RELEASE_DOC_LANGUAGE = env.str("BK_APIGW_RELEASE_DOC_LANGUAGE", default="") +# 在项目 docs目录下,通过 markdown文档自动化导入中英文文档; 注意markdown文件名必须等于接口的 operation_id; 见 demo 示例 +# BK_APIGW_RESOURCE_DOCS_BASE_DIR = env.str("BK_APIGW_RESOURCE_DOCS_BASE_DIR", default=BASE_DIR / "docs") + # BK SOPS RELATE BK_SOPS_APP_CODE = os.getenv("BK_SOPS_APP_CODE") diff --git a/template/{{cookiecutter.project_name}}/app_desc.yml b/template/{{cookiecutter.project_name}}/app_desc.yml index cb71b87..0839ea4 100644 --- a/template/{{cookiecutter.project_name}}/app_desc.yml +++ b/template/{{cookiecutter.project_name}}/app_desc.yml @@ -4,6 +4,9 @@ modules: isDefault: true language: python spec: + hooks: + preRelease: + procCommand: "bash bin/sync_apigateway.sh" processes: - name: web procCommand: gunicorn bk_plugin_runtime.wsgi --timeout 120 -k gthread --threads 16 -w 8 --max-requests=1000 --env prometheus_multiproc_dir=/tmp/ @@ -21,17 +24,20 @@ modules: procCommand: celery-prometheus-exporter --broker amqp://$RABBITMQ_USER:$RABBITMQ_PASSWORD@$RABBITMQ_HOST:$RABBITMQ_PORT/$RABBITMQ_VHOST --addr 0.0.0.0:5001 --queue-list plugin_schedule plugin_callback schedule_delete configuration: env: + - name: PYTHONPATH + value: /app + description: 将项目根目录添加到Python路径,使Python能直接引用本地的bk_plugin_runtime和bk_plugin_framework - name: PIP_VERSION value: 21.2.2 description: pip version control - name: BK_APIGW_MANAGER_URL_TMPL - value: {{cookiecutter.apigw_manager_url_tmpl}} + value: http://{api_name}.apigw.o.woa.com description: pip version control - name: BK_APIGW_MANAGER_MAINTAINERS - value: {{cookiecutter.init_apigw_maintainer}} + value: simonyi description: plugin apigw managers - name: BK_INIT_SUPERUSER - value: {{cookiecutter.init_admin}} + value: simonyi description: plugin admin panel init superuser - name: BK_SOPS_APP_CODE value: bksops @@ -43,14 +49,14 @@ modules: value: bk_plugin_runtime.config description: blueapps config path - name: BK_APIGW_CORS_ALLOW_ORIGINS - value: {{cookiecutter.apigw_cors_allow_origins}} + value: '' description: apigw cors strategie allow origins - name: BK_APIGW_CORS_ALLOW_METHODS - value: {{cookiecutter.apigw_cors_allow_methods}} + value: GET,POST,PUT,PATCH,HEAD,DELETE,OPTIONS description: apigw cors strategie allow methods - name: BK_APIGW_CORS_ALLOW_HEADERS - value: {{cookiecutter.apigw_cors_allow_headers}} + value: Accept,Cache-Control,Content-Type,Keep-Alive,Origin,User-Agent,X-Requested-With description: apigw cors strategie allow headers - name: BK_APIGW_DEFAULT_TIMEOUT - value: {{cookiecutter.bk_apigw_default_timeout}} + value: 60 description: apigw default timeout diff --git a/template/{{cookiecutter.project_name}}/bin/manage.py b/template/{{cookiecutter.project_name}}/bin/manage.py index 8d808e1..abb810f 100644 --- a/template/{{cookiecutter.project_name}}/bin/manage.py +++ b/template/{{cookiecutter.project_name}}/bin/manage.py @@ -14,6 +14,12 @@ import os import sys +# 将项目根目录添加到 Python 路径,使 Python 能直接引用本地的 bk_plugin_runtime 和 bk_plugin_framework +# 部署时代码在 /app 目录,bin/manage.py 在 /app/bin/ 下,所以取上级目录 +PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +if PROJECT_ROOT not in sys.path: + sys.path.insert(0, PROJECT_ROOT) + if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bk_plugin_runtime.settings") os.environ.setdefault("BK_APP_CONFIG_PATH", "bk_plugin_runtime.config") diff --git a/template/{{cookiecutter.project_name}}/bin/post_compile b/template/{{cookiecutter.project_name}}/bin/post_compile deleted file mode 100644 index 19c7a3c..0000000 --- a/template/{{cookiecutter.project_name}}/bin/post_compile +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# DO NOT MODIFY THIS SECTION !!! -env -python bin/manage.py migrate -python bin/manage.py sync_plugin_apigw -python bin/manage.py fetch_apigw_public_key -# DO NOT MODIFY THIS SECTION !!! \ No newline at end of file diff --git a/template/{{cookiecutter.project_name}}/bin/sync_apigateway.sh b/template/{{cookiecutter.project_name}}/bin/sync_apigateway.sh new file mode 100755 index 0000000..95e18da --- /dev/null +++ b/template/{{cookiecutter.project_name}}/bin/sync_apigateway.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# DO NOT MODIFY THIS SECTION !!! +echo "do migrate" +python bin/manage.py migrate --no-input + +echo "[Sync] BEGIN =====================" +echo "[Sync] generate definition.yaml" +python bin/manage.py generate_definition_yaml +if [ $? -ne 0 ] +then + echo "run generate_definition_yaml fail, please run this command on your development env to find out the reason" + exit 1 +fi + + +if [ -f /app/definition.yaml ] +then + echo "[Sync] the /app/definition.yaml content:" + cat /app/definition.yaml + echo "====================" +fi + + +echo "[Sync] generate resources.yaml" +python bin/manage.py generate_resources_yaml +if [ $? -ne 0 ] +then + echo "run generate_resources_yaml fail, please run this command on your development env to find out the reason" + exit 1 +fi + +if [ -f /app/resources.yaml ] +then + echo "[Sync] the /app/resources.yaml content:" + cat /app/resources.yaml + echo "====================" +fi + +echo "[Sync] sync to apigateway" +python bin/manage.py sync_drf_apigateway +if [ $? -ne 0 ] +then + echo "run sync_drf_apigateway fail" + exit 1 +fi + +echo "[Sync] fetch the public key" +python bin/manage.py fetch_apigw_public_key +if [ $? -ne 0 ] +then + echo "run fetch_apigw_public_key fail" + exit 1 +fi + +echo "[Sync] DONE =====================" +# DO NOT MODIFY THIS SECTION !!! + diff --git a/template/{{cookiecutter.project_name}}/requirements.txt b/template/{{cookiecutter.project_name}}/requirements.txt index 5dd69ee..a2980b1 100644 --- a/template/{{cookiecutter.project_name}}/requirements.txt +++ b/template/{{cookiecutter.project_name}}/requirements.txt @@ -1,9 +1,47 @@ -# base -# DO NOT DELETE ANY PACKAGE IN base SECTION !!! -bk-plugin-framework==2.2.9 -# opentelemetry +amqp==2.6.1 +annotated-types==0.7.0 +apigw-manager==3.1.2 +asgiref==3.11.0 +async-timeout==5.0.1 +attrs==25.4.0 +billiard==3.6.4.0 +bkapi-bk-apigateway==1.1.1 +bkapi-client-core==1.2.0 +bkoauth==0.1.0 +blueapps==4.15.8 +celery==4.4.7 celery-prometheus-exporter==1.7.0 -celery>=4.4.0,<5.0.0 # Explicit celery version constraint to resolve pip 25.x dependency conflict +certifi==2026.1.4 +cffi==2.0.0 +charset-normalizer==3.4.4 +cryptography==46.0.3 +curlify==3.0.0 +ddtrace==0.14.1 +Deprecated==1.3.1 +Django==3.2.25 +django-celery-beat==2.2.0 +django-celery-results==1.2.1 +django-cors-headers==3.14.0 +django-dbconn-retry==0.1.9 +django-prometheus==2.4.0 +django-timezone-field==4.2.3 +djangorestframework==3.15.1 +drf-spectacular==0.27.1 +drf-yasg==1.21.10 +django-environ==0.11.2 +future==1.0.0 +googleapis-common-protos==1.59.1 +grpcio==1.76.0 +gunicorn==23.0.0 +idna==3.11 +importlib_metadata==7.1.0 +inflection==0.5.1 +jsonschema==4.25.1 +jsonschema-specifications==2025.9.1 +kombu==4.6.11 +Mako==1.3.10 +MarkupSafe==2.1.5 +msgpack-python==0.5.6 opentelemetry-api==1.25.0 opentelemetry-exporter-jaeger==1.21.0 opentelemetry-exporter-jaeger-proto-grpc==1.21.0 @@ -25,4 +63,36 @@ 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 +packaging==25.0 +pip==22.2.2 +prometheus_client==0.23.1 +protobuf==4.25.8 +pycparser==2.23 +pycryptodome==3.23.0 +pydantic==2.12.5 +pydantic_core==2.41.5 +PyJWT==2.10.1 +PyMySQL==1.1.2 +python-crontab==3.3.0 +python-json-logger==4.0.0 +pytz==2025.2 +PyYAML==6.0.3 +raven==6.10.0 +redis==5.3.1 +referencing==0.37.0 +requests==2.32.5 +rpds-py==0.30.0 +setuptools==60.10.0 +six==1.17.0 +sqlparse==0.5.5 +thrift==0.22.0 +typing_extensions==4.15.0 +typing-inspection==0.4.2 +uritemplate==4.2.0 +urllib3==2.6.2 +vine==1.3.0 +Werkzeug==3.1.4 +wheel==0.37.1 +whitenoise==6.11.0 +wrapt==1.17.3 +zipp==3.23.0 \ No newline at end of file From 8ff4a377715071770b1e33a1cad6105900aab117 Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Tue, 6 Jan 2026 20:13:05 +0800 Subject: [PATCH 04/17] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E6=A8=A1=E5=9D=97=E5=92=8C=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=9C=A8=E5=90=8C=E4=B8=80=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=9D=97=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3bc2b4c..c3188d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,6 +25,8 @@ repos: args: - "--profile" - "black" + - "--known-first-party" + - "bk_plugin_framework,bk_plugin_runtime" - repo: https://github.com/pycqa/flake8 rev: 7.3.0 From fe9550abf189aa9e4a478529eef1b8b682c2f22d Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Tue, 6 Jan 2026 20:16:13 +0800 Subject: [PATCH 05/17] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E6=A8=A1=E5=9D=97=E5=92=8C=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=9C=A8=E5=90=8C=E4=B8=80=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=9D=97=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .isort.cfg | 4 ++++ .pre-commit-config.yaml | 5 ----- .../bk_plugin_framework/kit/api.py | 7 ++++--- .../bk_plugin_framework/runtime/callback/api.py | 7 ++++--- .../runtime/callback/celery/tasks.py | 3 ++- .../bk_plugin_framework/runtime/executor.py | 3 ++- .../bk_plugin_framework/runtime/loghub/admin.py | 3 ++- .../bk_plugin_framework/runtime/loghub/log.py | 3 ++- .../runtime/schedule/admin.py | 3 ++- .../runtime/schedule/celery/tasks.py | 3 ++- .../services/bpf_service/api/callback.py | 5 +++-- .../services/bpf_service/api/detail.py | 11 ++++++----- .../services/bpf_service/api/invoke.py | 17 +++++++++-------- .../services/bpf_service/api/logs.py | 11 ++++++----- .../services/bpf_service/api/meta.py | 13 +++++++------ .../services/bpf_service/api/permissions.py | 3 ++- .../bpf_service/api/plugin_api_dispatch.py | 15 ++++++++------- .../services/bpf_service/api/schedule.py | 11 ++++++----- .../services/bpf_service/apps.py | 3 ++- .../services/bpf_service/urls.py | 3 ++- bk-plugin-framework/tests/conftest.py | 1 + bk-plugin-framework/tests/kit/test_plugin.py | 1 + .../tests/runtime/callback/celery/test_tasks.py | 1 + .../tests/runtime/callback/test_utils.py | 1 + .../tests/runtime/schedule/celery/test_tasks.py | 1 + .../tests/runtime/schedule/test_utils.py | 1 + .../tests/runtime/test_executor.py | 1 + .../bk_plugin_runtime/config/default.py | 11 ++++------- .../bk_plugin_runtime/config/dev.py | 1 + 29 files changed, 87 insertions(+), 65 deletions(-) create mode 100644 .isort.cfg diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..cc794c3 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,4 @@ +[settings] +profile = black +known_first_party = bk_plugin_framework,bk_plugin_runtime +line_length = 120 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c3188d7..a38357b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,11 +22,6 @@ repos: rev: 7.0.0 hooks: - id: isort - args: - - "--profile" - - "black" - - "--known-first-party" - - "bk_plugin_framework,bk_plugin_runtime" - repo: https://github.com/pycqa/flake8 rev: 7.3.0 diff --git a/bk-plugin-framework/bk_plugin_framework/kit/api.py b/bk-plugin-framework/bk_plugin_framework/kit/api.py index cde5165..24757e1 100644 --- a/bk-plugin-framework/bk_plugin_framework/kit/api.py +++ b/bk-plugin-framework/bk_plugin_framework/kit/api.py @@ -12,15 +12,16 @@ import json from apigw_manager.apigw.decorators import apigw_require -from bk_plugin_framework.envs import settings -from bk_plugin_framework.kit.authentication import CsrfExemptSessionAuthentication -from bk_plugin_framework.kit.decorators import inject_user_token, login_exempt from bkoauth import get_app_access_token from django.conf import settings as default_settings from django.utils.decorators import method_decorator from rest_framework.request import Request from rest_framework.views import APIView +from bk_plugin_framework.envs import settings +from bk_plugin_framework.kit.authentication import CsrfExemptSessionAuthentication +from bk_plugin_framework.kit.decorators import inject_user_token, login_exempt + custom_authentication_classes = ( [ CsrfExemptSessionAuthentication, diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py index b95ecde..5f3540c 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py @@ -14,13 +14,14 @@ import time import uuid -from bk_plugin_framework.constants import State -from bk_plugin_framework.envs import settings -from bk_plugin_framework.runtime.schedule.models import Schedule from celery import current_app from cryptography.fernet import Fernet from django.conf import settings as default_settings +from bk_plugin_framework.constants import State +from bk_plugin_framework.envs import settings +from bk_plugin_framework.runtime.schedule.models import Schedule + logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py index 34fa830..b7510f6 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py @@ -14,6 +14,8 @@ import random import time +from celery import current_app, shared_task + from bk_plugin_framework.envs import settings from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.kit import State @@ -26,7 +28,6 @@ from bk_plugin_framework.runtime.schedule.models import Schedule from bk_plugin_framework.runtime.schedule.utils import get_schedule_lock from bk_plugin_framework.utils import local -from celery import current_app, shared_task logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/executor.py b/bk-plugin-framework/bk_plugin_framework/runtime/executor.py index 6363f8e..6f6938a 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/executor.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/executor.py @@ -20,6 +20,8 @@ except ImportError: from pydantic import ValidationError +from django.utils.timezone import now + from bk_plugin_framework.kit import ( Callback, Context, @@ -44,7 +46,6 @@ ) from bk_plugin_framework.runtime.callbacker import PluginCallbacker from bk_plugin_framework.runtime.schedule.models import Schedule -from django.utils.timezone import now logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/admin.py b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/admin.py index c6e7966..4a99ab9 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/admin.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/admin.py @@ -9,9 +9,10 @@ specific language governing permissions and limitations under the License. """ -from bk_plugin_framework.runtime.loghub import models from django.contrib import admin +from bk_plugin_framework.runtime.loghub import models + @admin.register(models.LogEntry) class LogEntryAdmin(admin.ModelAdmin): diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/log.py b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/log.py index 21dbaa1..a02653f 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/loghub/log.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/loghub/log.py @@ -12,9 +12,10 @@ import logging from logging import LogRecord -from bk_plugin_framework.utils import local from django.core.exceptions import AppRegistryNotReady +from bk_plugin_framework.utils import local + class TraceContextLogHandler(logging.Handler): def emit(self, record: LogRecord): diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/admin.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/admin.py index 367c311..f5179ba 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/admin.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/admin.py @@ -9,9 +9,10 @@ specific language governing permissions and limitations under the License. """ -from bk_plugin_framework.runtime.schedule import models from django.contrib import admin +from bk_plugin_framework.runtime.schedule import models + @admin.register(models.Schedule) class ScheduleAdmin(admin.ModelAdmin): diff --git a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/tasks.py b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/tasks.py index f5a9836..f579023 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/tasks.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/schedule/celery/tasks.py @@ -11,13 +11,14 @@ import logging +from celery import shared_task + from bk_plugin_framework.envs import settings from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.kit import State from bk_plugin_framework.runtime.executor import BKPluginExecutor from bk_plugin_framework.runtime.schedule.models import Schedule from bk_plugin_framework.utils import local -from celery import shared_task logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py index 3271ea2..d543bb6 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py @@ -15,8 +15,6 @@ from apigw_manager.apigw.decorators import apigw_require from apigw_manager.drf.utils import gen_apigateway_resource_config -from bk_plugin_framework.runtime.callback.api import callback, parse_callback_token -from bk_plugin_framework.serializers import enveloper from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema @@ -25,6 +23,9 @@ from rest_framework.response import Response from rest_framework.views import APIView +from bk_plugin_framework.runtime.callback.api import callback, parse_callback_token +from bk_plugin_framework.serializers import enveloper + logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py index a5ad39b..6ac4723 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py @@ -12,11 +12,6 @@ import logging from apigw_manager.drf.utils import gen_apigateway_resource_config -from bk_plugin_framework.hub import VersionHub -from bk_plugin_framework.serializers import enveloper -from bk_plugin_framework.services.bpf_service.api.serializers import ( - StandardResponseSerializer, -) from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema @@ -25,6 +20,12 @@ from rest_framework.response import Response from rest_framework.views import APIView +from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) + logger = logging.getLogger("root") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py index 5a60e71..8d4d2fe 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py @@ -13,6 +13,15 @@ from apigw_manager.apigw.decorators import apigw_require from apigw_manager.drf.utils import gen_apigateway_resource_config +from blueapps.account.decorators import login_exempt +from django.utils.decorators import method_decorator +from drf_spectacular.utils import extend_schema +from rest_framework import serializers, status +from rest_framework.decorators import action +from rest_framework.exceptions import ValidationError +from rest_framework.response import Response +from rest_framework.views import APIView + from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.runtime.executor import BKPluginExecutor from bk_plugin_framework.serializers import enveloper @@ -22,14 +31,6 @@ from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) -from blueapps.account.decorators import login_exempt -from django.utils.decorators import method_decorator -from drf_spectacular.utils import extend_schema -from rest_framework import serializers, status -from rest_framework.decorators import action -from rest_framework.exceptions import ValidationError -from rest_framework.response import Response -from rest_framework.views import APIView logger = logging.getLogger("bk_plugin") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py index 047ddf9..b373dda 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py @@ -12,11 +12,6 @@ import logging from apigw_manager.drf.utils import gen_apigateway_resource_config -from bk_plugin_framework.runtime.loghub.models import LogEntry -from bk_plugin_framework.serializers import enveloper -from bk_plugin_framework.services.bpf_service.api.serializers import ( - StandardResponseSerializer, -) from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema @@ -25,6 +20,12 @@ from rest_framework.response import Response from rest_framework.views import APIView +from bk_plugin_framework.runtime.loghub.models import LogEntry +from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) + logger = logging.getLogger("root") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py index 69dd691..1a4b38f 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py @@ -13,12 +13,6 @@ from importlib import import_module from apigw_manager.drf.utils import gen_apigateway_resource_config -from bk_plugin_framework import __version__ as bpf_version -from bk_plugin_framework.hub import VersionHub -from bk_plugin_framework.serializers import enveloper -from bk_plugin_framework.services.bpf_service.api.serializers import ( - StandardResponseSerializer, -) from blueapps.account.decorators import login_exempt from django.conf import settings from django.utils.decorators import method_decorator @@ -28,6 +22,13 @@ from rest_framework.response import Response from rest_framework.views import APIView +from bk_plugin_framework import __version__ as bpf_version +from bk_plugin_framework.hub import VersionHub +from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) + logger = logging.getLogger("root") FRAMEWORK_VERSION = bpf_version.__version__ diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/permissions.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/permissions.py index 8e776aa..d2da9bf 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/permissions.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/permissions.py @@ -1,9 +1,10 @@ from importlib import import_module -from bk_plugin_framework.utils.validations import validate_allow_scope from rest_framework.permissions import BasePermission from rest_framework.request import Request +from bk_plugin_framework.utils.validations import validate_allow_scope + try: meta_module = import_module("bk_plugin.meta") except ImportError: diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py index 62e3347..c33e0de 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py @@ -16,13 +16,6 @@ from apigw_manager.apigw.decorators import apigw_require from apigw_manager.drf.utils import gen_apigateway_resource_config -from bk_plugin_framework.serializers import enveloper -from bk_plugin_framework.services.bpf_service.api.permissions import ( - ScopeAllowPermission, -) -from bk_plugin_framework.services.bpf_service.api.serializers import ( - StandardResponseSerializer, -) from blueapps.account.decorators import login_exempt from django.test import RequestFactory from django.urls import Resolver404, resolve @@ -34,6 +27,14 @@ from rest_framework.response import Response from rest_framework.views import APIView +from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.services.bpf_service.api.permissions import ( + ScopeAllowPermission, +) +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) + logger = logging.getLogger("bk_plugin") CUSTOM_REQUEST_HEADER_REGEX = re.compile("HTTP_BK_PLUGIN_*") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py index cf05dec..945d112 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py @@ -13,11 +13,6 @@ import logging from apigw_manager.drf.utils import gen_apigateway_resource_config -from bk_plugin_framework.runtime.schedule.models import Schedule as ScheduleModel -from bk_plugin_framework.serializers import enveloper -from bk_plugin_framework.services.bpf_service.api.serializers import ( - StandardResponseSerializer, -) from blueapps.account.decorators import login_exempt from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema @@ -26,6 +21,12 @@ from rest_framework.response import Response from rest_framework.views import APIView +from bk_plugin_framework.runtime.schedule.models import Schedule as ScheduleModel +from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.services.bpf_service.api.serializers import ( + StandardResponseSerializer, +) + logger = logging.getLogger("root") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/apps.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/apps.py index 8cfee1a..33a27cc 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/apps.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/apps.py @@ -11,9 +11,10 @@ from importlib import import_module -from bk_plugin_framework.utils.module_load import discover_plugins from django.apps import AppConfig +from bk_plugin_framework.utils.module_load import discover_plugins + class BpfServiceConfig(AppConfig): name = "bk_plugin_framework.services.bpf_service" diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py index ecdeaaa..07c8dec 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/urls.py @@ -12,9 +12,10 @@ import importlib import sys +from django.urls import include, path + from bk_plugin_framework.envs import settings from bk_plugin_framework.services.bpf_service import api -from django.urls import include, path PLUGIN_API_URLS_MODULE = "bk_plugin.apis.urls" PLUGIN_OPENAPI_URLS_MODULE = "bk_plugin.openapi.urls" diff --git a/bk-plugin-framework/tests/conftest.py b/bk-plugin-framework/tests/conftest.py index fb2a38f..75b1040 100644 --- a/bk-plugin-framework/tests/conftest.py +++ b/bk-plugin-framework/tests/conftest.py @@ -10,6 +10,7 @@ """ import pytest + from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.utils import local diff --git a/bk-plugin-framework/tests/kit/test_plugin.py b/bk-plugin-framework/tests/kit/test_plugin.py index 6f3b434..935f432 100644 --- a/bk-plugin-framework/tests/kit/test_plugin.py +++ b/bk-plugin-framework/tests/kit/test_plugin.py @@ -12,6 +12,7 @@ from unittest.mock import MagicMock, patch import pytest + from bk_plugin_framework.kit import ( Callback, Context, diff --git a/bk-plugin-framework/tests/runtime/callback/celery/test_tasks.py b/bk-plugin-framework/tests/runtime/callback/celery/test_tasks.py index a6461b1..d75df63 100644 --- a/bk-plugin-framework/tests/runtime/callback/celery/test_tasks.py +++ b/bk-plugin-framework/tests/runtime/callback/celery/test_tasks.py @@ -14,6 +14,7 @@ from unittest.mock import MagicMock, patch import pytest + from bk_plugin_framework.kit import State from bk_plugin_framework.runtime.callback.celery import tasks from bk_plugin_framework.utils import local diff --git a/bk-plugin-framework/tests/runtime/callback/test_utils.py b/bk-plugin-framework/tests/runtime/callback/test_utils.py index 88f677b..a3f8d2f 100644 --- a/bk-plugin-framework/tests/runtime/callback/test_utils.py +++ b/bk-plugin-framework/tests/runtime/callback/test_utils.py @@ -12,6 +12,7 @@ import uuid import pytest + from bk_plugin_framework.runtime.callback.api import ( CallbackPreparation, parse_callback_token, diff --git a/bk-plugin-framework/tests/runtime/schedule/celery/test_tasks.py b/bk-plugin-framework/tests/runtime/schedule/celery/test_tasks.py index e115461..b4cf471 100644 --- a/bk-plugin-framework/tests/runtime/schedule/celery/test_tasks.py +++ b/bk-plugin-framework/tests/runtime/schedule/celery/test_tasks.py @@ -13,6 +13,7 @@ from unittest.mock import MagicMock, patch import pytest + from bk_plugin_framework.kit import State from bk_plugin_framework.runtime.schedule.celery import tasks from bk_plugin_framework.utils import local diff --git a/bk-plugin-framework/tests/runtime/schedule/test_utils.py b/bk-plugin-framework/tests/runtime/schedule/test_utils.py index 7610822..04a1d6d 100644 --- a/bk-plugin-framework/tests/runtime/schedule/test_utils.py +++ b/bk-plugin-framework/tests/runtime/schedule/test_utils.py @@ -13,6 +13,7 @@ from unittest.mock import MagicMock, patch import pytest + from bk_plugin_framework.runtime.schedule.utils import get_schedule_lock diff --git a/bk-plugin-framework/tests/runtime/test_executor.py b/bk-plugin-framework/tests/runtime/test_executor.py index a9eb20d..77eebb4 100644 --- a/bk-plugin-framework/tests/runtime/test_executor.py +++ b/bk-plugin-framework/tests/runtime/test_executor.py @@ -13,6 +13,7 @@ from unittest.mock import MagicMock, patch import pytest + from bk_plugin_framework.kit import ( Context, ContextRequire, diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py index a704239..26998af 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py @@ -46,12 +46,8 @@ if BKPAAS_ENVIRONMENT == "dev": INSTALLED_APPS += ("bk_plugin_framework.services.debug_panel",) # noqa -from bk_plugin_framework.runtime.callback.celery import ( # noqa - queues as callback_queues, -) -from bk_plugin_framework.runtime.schedule.celery import ( # noqa - queues as schedule_queues, -) +from bk_plugin_framework.runtime.callback.celery import queues as callback_queues # noqa +from bk_plugin_framework.runtime.schedule.celery import queues as schedule_queues # noqa CELERY_QUEUES = schedule_queues.CELERY_QUEUES CELERY_QUEUES.extend(callback_queues.CELERY_QUEUES) @@ -185,9 +181,10 @@ ROOT_URLCONF = "bk_plugin_runtime.urls" -from bk_plugin_framework.runtime.schedule.celery.beat import SCHEDULE # noqa from blueapps.core.celery import celery_app # noqa +from bk_plugin_framework.runtime.schedule.celery.beat import SCHEDULE # noqa + celery_app.conf.beat_schedule = SCHEDULE diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py index 727b933..0ec02c3 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py @@ -12,6 +12,7 @@ import os import MySQLdb + from bk_plugin_runtime.config import RUN_VER if RUN_VER == "open": From 7f2c0c24673637cec14cd90be7907bcb8f34b8b5 Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Tue, 6 Jan 2026 20:43:29 +0800 Subject: [PATCH 06/17] =?UTF-8?q?delete:=20=E5=88=A0=E9=99=A4runtime?= =?UTF-8?q?=E4=B8=AD=E5=A4=9A=E4=BD=99=E7=9A=84=E7=94=A8=E6=88=B7=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bk-plugin-runtime/bk_plugin_runtime/config/default.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py index 26998af..68d13bf 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py @@ -84,11 +84,7 @@ "apigw_manager.apigw.authentication.ApiGatewayJWTUserMiddleware", # JWT 透传的用户信息 ) -# 用户认证 -AUTHENTICATION_BACKENDS += ( - "bk_plugin_runtime.packages.apigw.backends.APIGWUserModelBackend", - "apigw_manager.apigw.authentication.UserModelBackend", -) # noqa + # 所有环境的日志级别可以在这里配置 # LOG_LEVEL = 'INFO' From 9c8ebaff9fd6c50b86f71eb74b123a76c4134c6b Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Wed, 7 Jan 2026 10:48:38 +0800 Subject: [PATCH 07/17] =?UTF-8?q?feat:=20=E6=81=A2=E5=A4=8Dapp=5Fdesc.yml?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{{cookiecutter.project_name}}/app_desc.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/template/{{cookiecutter.project_name}}/app_desc.yml b/template/{{cookiecutter.project_name}}/app_desc.yml index 0839ea4..d433cb4 100644 --- a/template/{{cookiecutter.project_name}}/app_desc.yml +++ b/template/{{cookiecutter.project_name}}/app_desc.yml @@ -24,20 +24,17 @@ modules: procCommand: celery-prometheus-exporter --broker amqp://$RABBITMQ_USER:$RABBITMQ_PASSWORD@$RABBITMQ_HOST:$RABBITMQ_PORT/$RABBITMQ_VHOST --addr 0.0.0.0:5001 --queue-list plugin_schedule plugin_callback schedule_delete configuration: env: - - name: PYTHONPATH - value: /app - description: 将项目根目录添加到Python路径,使Python能直接引用本地的bk_plugin_runtime和bk_plugin_framework - name: PIP_VERSION value: 21.2.2 description: pip version control - name: BK_APIGW_MANAGER_URL_TMPL - value: http://{api_name}.apigw.o.woa.com + value: {{cookiecutter.apigw_manager_url_tmpl}} description: pip version control - name: BK_APIGW_MANAGER_MAINTAINERS - value: simonyi + value: {{cookiecutter.init_apigw_maintainer}} description: plugin apigw managers - name: BK_INIT_SUPERUSER - value: simonyi + value: {{cookiecutter.init_admin}} description: plugin admin panel init superuser - name: BK_SOPS_APP_CODE value: bksops @@ -49,14 +46,14 @@ modules: value: bk_plugin_runtime.config description: blueapps config path - name: BK_APIGW_CORS_ALLOW_ORIGINS - value: '' + value: {{cookiecutter.apigw_cors_allow_origins}} description: apigw cors strategie allow origins - name: BK_APIGW_CORS_ALLOW_METHODS - value: GET,POST,PUT,PATCH,HEAD,DELETE,OPTIONS + value: {{cookiecutter.apigw_cors_allow_methods}} description: apigw cors strategie allow methods - name: BK_APIGW_CORS_ALLOW_HEADERS - value: Accept,Cache-Control,Content-Type,Keep-Alive,Origin,User-Agent,X-Requested-With + value: {{cookiecutter.apigw_cors_allow_headers}} description: apigw cors strategie allow headers - name: BK_APIGW_DEFAULT_TIMEOUT - value: 60 + value: {{cookiecutter.bk_apigw_default_timeout}} description: apigw default timeout From 361571866fed0299ddb0b8ba604d52ff7531abad Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Wed, 7 Jan 2026 11:10:57 +0800 Subject: [PATCH 08/17] =?UTF-8?q?revert:=20=E6=81=A2=E5=A4=8Dapp=5Fdesc.ya?= =?UTF-8?q?ml=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{{cookiecutter.project_name}}/app_desc.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/template/{{cookiecutter.project_name}}/app_desc.yml b/template/{{cookiecutter.project_name}}/app_desc.yml index d433cb4..0839ea4 100644 --- a/template/{{cookiecutter.project_name}}/app_desc.yml +++ b/template/{{cookiecutter.project_name}}/app_desc.yml @@ -24,17 +24,20 @@ modules: procCommand: celery-prometheus-exporter --broker amqp://$RABBITMQ_USER:$RABBITMQ_PASSWORD@$RABBITMQ_HOST:$RABBITMQ_PORT/$RABBITMQ_VHOST --addr 0.0.0.0:5001 --queue-list plugin_schedule plugin_callback schedule_delete configuration: env: + - name: PYTHONPATH + value: /app + description: 将项目根目录添加到Python路径,使Python能直接引用本地的bk_plugin_runtime和bk_plugin_framework - name: PIP_VERSION value: 21.2.2 description: pip version control - name: BK_APIGW_MANAGER_URL_TMPL - value: {{cookiecutter.apigw_manager_url_tmpl}} + value: http://{api_name}.apigw.o.woa.com description: pip version control - name: BK_APIGW_MANAGER_MAINTAINERS - value: {{cookiecutter.init_apigw_maintainer}} + value: simonyi description: plugin apigw managers - name: BK_INIT_SUPERUSER - value: {{cookiecutter.init_admin}} + value: simonyi description: plugin admin panel init superuser - name: BK_SOPS_APP_CODE value: bksops @@ -46,14 +49,14 @@ modules: value: bk_plugin_runtime.config description: blueapps config path - name: BK_APIGW_CORS_ALLOW_ORIGINS - value: {{cookiecutter.apigw_cors_allow_origins}} + value: '' description: apigw cors strategie allow origins - name: BK_APIGW_CORS_ALLOW_METHODS - value: {{cookiecutter.apigw_cors_allow_methods}} + value: GET,POST,PUT,PATCH,HEAD,DELETE,OPTIONS description: apigw cors strategie allow methods - name: BK_APIGW_CORS_ALLOW_HEADERS - value: {{cookiecutter.apigw_cors_allow_headers}} + value: Accept,Cache-Control,Content-Type,Keep-Alive,Origin,User-Agent,X-Requested-With description: apigw cors strategie allow headers - name: BK_APIGW_DEFAULT_TIMEOUT - value: {{cookiecutter.bk_apigw_default_timeout}} + value: 60 description: apigw default timeout From 16e57a02c2844a86096632653a995d8a7aa8b62f Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Wed, 7 Jan 2026 11:16:43 +0800 Subject: [PATCH 09/17] =?UTF-8?q?fix:=20=E6=81=A2=E5=A4=8Drequirements.txt?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../requirements.txt | 83 ++----------------- 1 file changed, 7 insertions(+), 76 deletions(-) diff --git a/template/{{cookiecutter.project_name}}/requirements.txt b/template/{{cookiecutter.project_name}}/requirements.txt index a2980b1..1934066 100644 --- a/template/{{cookiecutter.project_name}}/requirements.txt +++ b/template/{{cookiecutter.project_name}}/requirements.txt @@ -1,47 +1,10 @@ -amqp==2.6.1 -annotated-types==0.7.0 -apigw-manager==3.1.2 -asgiref==3.11.0 -async-timeout==5.0.1 -attrs==25.4.0 -billiard==3.6.4.0 -bkapi-bk-apigateway==1.1.1 -bkapi-client-core==1.2.0 -bkoauth==0.1.0 -blueapps==4.15.8 -celery==4.4.7 +# base +# DO NOT DELETE ANY PACKAGE IN base SECTION !!! +bk-plugin-framework==2.3.3 +bk-plugin-runtime==2.1.2 +# opentelemetry celery-prometheus-exporter==1.7.0 -certifi==2026.1.4 -cffi==2.0.0 -charset-normalizer==3.4.4 -cryptography==46.0.3 -curlify==3.0.0 -ddtrace==0.14.1 -Deprecated==1.3.1 -Django==3.2.25 -django-celery-beat==2.2.0 -django-celery-results==1.2.1 -django-cors-headers==3.14.0 -django-dbconn-retry==0.1.9 -django-prometheus==2.4.0 -django-timezone-field==4.2.3 -djangorestframework==3.15.1 -drf-spectacular==0.27.1 -drf-yasg==1.21.10 -django-environ==0.11.2 -future==1.0.0 -googleapis-common-protos==1.59.1 -grpcio==1.76.0 -gunicorn==23.0.0 -idna==3.11 -importlib_metadata==7.1.0 -inflection==0.5.1 -jsonschema==4.25.1 -jsonschema-specifications==2025.9.1 -kombu==4.6.11 -Mako==1.3.10 -MarkupSafe==2.1.5 -msgpack-python==0.5.6 +celery>=4.4.0,<5.0.0 # Explicit celery version constraint to resolve pip 25.x dependency conflict opentelemetry-api==1.25.0 opentelemetry-exporter-jaeger==1.21.0 opentelemetry-exporter-jaeger-proto-grpc==1.21.0 @@ -63,36 +26,4 @@ opentelemetry-proto==1.25.0 opentelemetry-sdk==1.25.0 opentelemetry-semantic-conventions==0.46b0 opentelemetry-util-http==0.46b0 -packaging==25.0 -pip==22.2.2 -prometheus_client==0.23.1 -protobuf==4.25.8 -pycparser==2.23 -pycryptodome==3.23.0 -pydantic==2.12.5 -pydantic_core==2.41.5 -PyJWT==2.10.1 -PyMySQL==1.1.2 -python-crontab==3.3.0 -python-json-logger==4.0.0 -pytz==2025.2 -PyYAML==6.0.3 -raven==6.10.0 -redis==5.3.1 -referencing==0.37.0 -requests==2.32.5 -rpds-py==0.30.0 -setuptools==60.10.0 -six==1.17.0 -sqlparse==0.5.5 -thrift==0.22.0 -typing_extensions==4.15.0 -typing-inspection==0.4.2 -uritemplate==4.2.0 -urllib3==2.6.2 -vine==1.3.0 -Werkzeug==3.1.4 -wheel==0.37.1 -whitenoise==6.11.0 -wrapt==1.17.3 -zipp==3.23.0 \ No newline at end of file +# add your custom requirements below this line \ No newline at end of file From 6445e46f13009aa00b2d78d13fdf6d98f3b99076 Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Wed, 7 Jan 2026 11:39:22 +0800 Subject: [PATCH 10/17] =?UTF-8?q?fix:=20=E6=81=A2=E5=A4=8Dapp=5Fdesc.yaml?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app_desc.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/template/{{cookiecutter.project_name}}/app_desc.yml b/template/{{cookiecutter.project_name}}/app_desc.yml index 0839ea4..91ff509 100644 --- a/template/{{cookiecutter.project_name}}/app_desc.yml +++ b/template/{{cookiecutter.project_name}}/app_desc.yml @@ -24,20 +24,17 @@ modules: procCommand: celery-prometheus-exporter --broker amqp://$RABBITMQ_USER:$RABBITMQ_PASSWORD@$RABBITMQ_HOST:$RABBITMQ_PORT/$RABBITMQ_VHOST --addr 0.0.0.0:5001 --queue-list plugin_schedule plugin_callback schedule_delete configuration: env: - - name: PYTHONPATH - value: /app - description: 将项目根目录添加到Python路径,使Python能直接引用本地的bk_plugin_runtime和bk_plugin_framework - name: PIP_VERSION value: 21.2.2 description: pip version control - name: BK_APIGW_MANAGER_URL_TMPL - value: http://{api_name}.apigw.o.woa.com + value: {{cookiecutter.apigw_manager_url_tmpl}} description: pip version control - name: BK_APIGW_MANAGER_MAINTAINERS - value: simonyi + value: {{cookiecutter.init_apigw_maintainer}} description: plugin apigw managers - name: BK_INIT_SUPERUSER - value: simonyi + value: {{cookiecutter.init_admin}} description: plugin admin panel init superuser - name: BK_SOPS_APP_CODE value: bksops @@ -49,14 +46,14 @@ modules: value: bk_plugin_runtime.config description: blueapps config path - name: BK_APIGW_CORS_ALLOW_ORIGINS - value: '' + value: {{cookiecutter.apigw_cors_allow_origins}} description: apigw cors strategie allow origins - name: BK_APIGW_CORS_ALLOW_METHODS - value: GET,POST,PUT,PATCH,HEAD,DELETE,OPTIONS + value: {{cookiecutter.apigw_cors_allow_methods}} description: apigw cors strategie allow methods - name: BK_APIGW_CORS_ALLOW_HEADERS - value: Accept,Cache-Control,Content-Type,Keep-Alive,Origin,User-Agent,X-Requested-With + value: {{cookiecutter.apigw_cors_allow_headers}} description: apigw cors strategie allow headers - name: BK_APIGW_DEFAULT_TIMEOUT - value: 60 - description: apigw default timeout + value: {{cookiecutter.bk_apigw_default_timeout}} + description: apigw default timeout \ No newline at end of file From e65b01c1ffc978839efd63e5bcadb812683952ef Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Thu, 8 Jan 2026 10:00:29 +0800 Subject: [PATCH 11/17] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Ebk=5Fplugin?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=8B=E7=9A=84apis=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bk-plugin-framework/bk_plugin_framework/serializers.py | 2 +- .../services/bpf_service/api/callback.py | 7 +++---- .../bk_plugin_framework/services/bpf_service/api/detail.py | 6 ++---- .../bk_plugin_framework/services/bpf_service/api/invoke.py | 7 +++---- .../bk_plugin_framework/services/bpf_service/api/logs.py | 6 ++---- .../bk_plugin_framework/services/bpf_service/api/meta.py | 6 ++---- .../services/bpf_service/api/plugin_api_dispatch.py | 7 +++---- .../services/bpf_service/api/schedule.py | 6 ++---- 8 files changed, 18 insertions(+), 29 deletions(-) diff --git a/bk-plugin-framework/bk_plugin_framework/serializers.py b/bk-plugin-framework/bk_plugin_framework/serializers.py index 3bc24cb..817f64b 100644 --- a/bk-plugin-framework/bk_plugin_framework/serializers.py +++ b/bk-plugin-framework/bk_plugin_framework/serializers.py @@ -2,7 +2,7 @@ from rest_framework import serializers -def enveloper(serializer_class, many: bool = False): +def standard_response_enveloper(serializer_class, many: bool = False): """统一响应包装器""" component_name = "Enveloped{}{}".format( serializer_class.__name__.replace("Serializer", ""), diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py index d543bb6..5baded3 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py @@ -19,12 +19,11 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import serializers -from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView from bk_plugin_framework.runtime.callback.api import callback, parse_callback_token -from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.serializers import standard_response_enveloper logger = logging.getLogger("bk_plugin") @@ -45,8 +44,9 @@ class PluginCallback(APIView): @extend_schema( summary="插件回调", + operation_id="callback", request=PluginCallbackParamsSerializer, - responses={200: enveloper(PluginCallbackResponseSerializer)}, + responses={200: standard_response_enveloper(PluginCallbackResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, allow_apply_permission=True, @@ -57,7 +57,6 @@ class PluginCallback(APIView): match_subpath=False, ), ) - @action(methods=["POST"], detail=True) def post(self, request, token): logger.info("[plugin callback]token=({}),body={}".format(token, request.body)) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py index 6ac4723..15e806f 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py @@ -16,12 +16,11 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers, status -from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView from bk_plugin_framework.hub import VersionHub -from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.serializers import standard_response_enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) @@ -70,7 +69,7 @@ class Detail(APIView): @extend_schema( summary="Get plugin detail for specific version", - responses={200: enveloper(DetailResponseSerializer)}, + responses={200: standard_response_enveloper(DetailResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, allow_apply_permission=True, @@ -81,7 +80,6 @@ class Detail(APIView): match_subpath=False, ), ) - @action(methods=["GET"], detail=True) def get(self, request, version): plugin_cls = VersionHub.all_plugins().get(version) if not plugin_cls: diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py index 8d4d2fe..44fcda5 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py @@ -17,14 +17,13 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import serializers, status -from rest_framework.decorators import action from rest_framework.exceptions import ValidationError from rest_framework.response import Response from rest_framework.views import APIView from bk_plugin_framework.hub import VersionHub from bk_plugin_framework.runtime.executor import BKPluginExecutor -from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.serializers import standard_response_enveloper from bk_plugin_framework.services.bpf_service.api.permissions import ( ScopeAllowPermission, ) @@ -60,8 +59,9 @@ class Invoke(APIView): @extend_schema( summary="插件调用", + operation_id="invoke", request=InvokeParamsSerializer, - responses={200: enveloper(InvokeResponseSerializer)}, + responses={200: standard_response_enveloper(InvokeResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, allow_apply_permission=True, @@ -72,7 +72,6 @@ class Invoke(APIView): match_subpath=False, ), ) - @action(methods=["POST"], detail=True) def post(self, request, version): plugin_cls = VersionHub.all_plugins().get(version) if not plugin_cls: diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py index b373dda..07a960d 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py @@ -16,12 +16,11 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers -from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView from bk_plugin_framework.runtime.loghub.models import LogEntry -from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.serializers import standard_response_enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) @@ -46,7 +45,7 @@ class Logs(APIView): @extend_schema( summary="Get plugin execution log with trace_id", - responses={200: enveloper(LogsResponseSerializer)}, + responses={200: standard_response_enveloper(LogsResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, allow_apply_permission=True, @@ -57,6 +56,5 @@ class Logs(APIView): match_subpath=False, ), ) - @action(methods=["GET"], detail=True) def get(self, request, trace_id): return Response({"result": True, "data": {"log": LogEntry.objects.get_plain_log(trace_id)}, "message": ""}) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py index 1a4b38f..0839d75 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py @@ -18,13 +18,12 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers -from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView from bk_plugin_framework import __version__ as bpf_version from bk_plugin_framework.hub import VersionHub -from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.serializers import standard_response_enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) @@ -64,7 +63,7 @@ class Meta(APIView): @extend_schema( summary="Get plugin meta info", - responses={200: enveloper(MetaResponseSerializer)}, + responses={200: standard_response_enveloper(MetaResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, allow_apply_permission=True, @@ -75,7 +74,6 @@ class Meta(APIView): match_subpath=False, ), ) - @action(methods=["GET"], detail=True) def get(self, request): try: meta_module = import_module("bk_plugin.meta") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py index c33e0de..fe32215 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py @@ -22,12 +22,11 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import serializers, status -from rest_framework.decorators import action from rest_framework.exceptions import ValidationError from rest_framework.response import Response from rest_framework.views import APIView -from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.serializers import standard_response_enveloper from bk_plugin_framework.services.bpf_service.api.permissions import ( ScopeAllowPermission, ) @@ -81,8 +80,9 @@ class PluginAPIDispatch(APIView): @extend_schema( summary="插件API分发", + operation_id="plugin_api_dispatch", request=PluginAPIDispatchParamsSerializer, - responses={200: enveloper(PluginAPIDispatchResponseSerializer)}, + responses={200: standard_response_enveloper(PluginAPIDispatchResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, allow_apply_permission=True, @@ -93,7 +93,6 @@ class PluginAPIDispatch(APIView): match_subpath=False, ), ) - @action(methods=["POST"], detail=True) def post(self, request): data_serializer = PluginAPIDispatchParamsSerializer(data=request.data) try: diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py index 945d112..d85f7df 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py @@ -17,12 +17,11 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers -from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView from bk_plugin_framework.runtime.schedule.models import Schedule as ScheduleModel -from bk_plugin_framework.serializers import enveloper +from bk_plugin_framework.serializers import standard_response_enveloper from bk_plugin_framework.services.bpf_service.api.serializers import ( StandardResponseSerializer, ) @@ -58,7 +57,7 @@ class Schedule(APIView): @extend_schema( summary="获取插件调度详情", request=ScheduleParamsSerializer, - responses={200: enveloper(ScheduleResponseSerializer)}, + responses={200: standard_response_enveloper(ScheduleResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, allow_apply_permission=True, @@ -69,7 +68,6 @@ class Schedule(APIView): match_subpath=False, ), ) - @action(methods=["GET"], detail=True) def get(self, request, trace_id): try: s = ScheduleModel.objects.get(trace_id=trace_id) From 77f32ddcf7768cf61acba617b478ded879e4cb6a Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Thu, 8 Jan 2026 15:45:33 +0800 Subject: [PATCH 12/17] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E5=AF=B9=E6=AF=94resource.yaml=E6=96=87=E4=BB=B6hash?= =?UTF-8?q?=E5=80=BC=E7=9A=84=E6=96=B9=E5=BC=8F=E5=AE=9E=E7=8E=B0=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E9=83=A8=E7=BD=B2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpf_service/management/__init__.py | 10 ++ .../management/commands/__init__.py | 10 ++ .../commands/sync_apigateway_if_changed.py | 150 ++++++++++++++++++ .../services/bpf_service/models.py | 35 ++++ 4 files changed, 205 insertions(+) create mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py create mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py create mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py create mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/models.py diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py new file mode 100644 index 0000000..a7d8957 --- /dev/null +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/__init__.py @@ -0,0 +1,10 @@ +""" +Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. +Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://opensource.org/licenses/MIT +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. +""" diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py new file mode 100644 index 0000000..a7d8957 --- /dev/null +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/__init__.py @@ -0,0 +1,10 @@ +""" +Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. +Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://opensource.org/licenses/MIT +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. +""" diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py new file mode 100644 index 0000000..cb8c31c --- /dev/null +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py @@ -0,0 +1,150 @@ +""" +Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. +Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://opensource.org/licenses/MIT +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 hashlib +import os + +from django.core.management import call_command +from django.core.management.base import BaseCommand + + +class Command(BaseCommand): + help = "仅在接口定义发生变化时同步到API网关" + + def add_arguments(self, parser): + parser.add_argument( + "--force", + action="store_true", + default=False, + help="强制同步,忽略哈希值对比", + ) + + def handle(self, *args, **options): + force_sync = options.get("force", False) + + # 1. 生成 yaml 文件 + self.stdout.write("[Sync] generate definition.yaml") + try: + call_command("generate_definition_yaml") + except Exception as e: + self.stderr.write( + self.style.ERROR( + f"run generate_definition_yaml fail: {e}, " + "please run this command on your development env to find out the reason" + ) + ) + raise SystemExit(1) + + self.stdout.write("[Sync] generate resources.yaml") + try: + call_command("generate_resources_yaml") + except Exception as e: + self.stderr.write( + self.style.ERROR( + f"run generate_resources_yaml fail: {e}, " + "please run this command on your development env to find out the reason" + ) + ) + raise SystemExit(1) + + # 2. 计算当前哈希值(仅计算 resources.yaml) + current_hash = self._calculate_resources_hash() + self.stdout.write(f"[Sync] Current resources.yaml hash: {current_hash[:16]}...") + + # 3. 获取上次同步的哈希值 + last_hash = self._get_last_sync_hash() + if last_hash: + self.stdout.write(f"[Sync] Last sync hash: {last_hash[:16]}...") + else: + self.stdout.write("[Sync] No previous sync record found") + + # 4. 对比决定是否同步 + if not force_sync and current_hash == last_hash: + self.stdout.write(self.style.SUCCESS("[Sync] API definition unchanged, skip sync to apigateway")) + # 仍然获取公钥,确保公钥是最新的 + self._fetch_public_key() + return + + if force_sync: + self.stdout.write(self.style.WARNING("[Sync] Force sync enabled")) + else: + self.stdout.write(self.style.WARNING("[Sync] API definition changed, start syncing...")) + + # 5. 执行同步 + self.stdout.write("[Sync] sync to apigateway") + try: + call_command("sync_drf_apigateway") + except Exception as e: + self.stderr.write(self.style.ERROR(f"run sync_drf_apigateway fail: {e}")) + # 同步失败时更新状态 + self._save_sync_hash(current_hash, success=False) + raise SystemExit(1) + + # 6. 获取公钥 + self._fetch_public_key() + + # 7. 更新哈希值 + self._save_sync_hash(current_hash, success=True) + self.stdout.write(self.style.SUCCESS("[Sync] API gateway sync completed successfully")) + + def _print_yaml_content(self, filepath, name): + """打印 YAML 文件内容""" + if os.path.exists(filepath): + self.stdout.write(f"[Sync] the {filepath} content:") + with open(filepath) as f: + self.stdout.write(f.read()) + self.stdout.write("====================") + + def _calculate_resources_hash(self): + """计算 resources.yaml 的哈希值""" + filepath = "/app/bk_plugin_runtime/resources.yaml" + if os.path.exists(filepath): + with open(filepath) as f: + content = f.read() + return hashlib.sha256(content.encode()).hexdigest() + return "" + + def _get_last_sync_hash(self): + """从数据库获取上次同步的哈希值""" + try: + from bk_plugin_framework.services.bpf_service.models import ( + APIGatewaySyncState, + ) + + state = APIGatewaySyncState.objects.filter(sync_success=True).first() + return state.api_hash if state else "" + except Exception as e: + self.stdout.write(self.style.WARNING(f"[Sync] Failed to get last sync hash: {e}")) + return "" + + def _save_sync_hash(self, hash_value, success=True): + """保存哈希值到数据库""" + try: + from bk_plugin_framework.services.bpf_service.models import ( + APIGatewaySyncState, + ) + + # 使用 update_or_create,保证只有一条记录 + APIGatewaySyncState.objects.update_or_create( + pk=1, defaults={"api_hash": hash_value, "sync_success": success} + ) + self.stdout.write(f"[Sync] Sync state saved (success={success})") + except Exception as e: + self.stdout.write(self.style.WARNING(f"[Sync] Failed to save sync hash: {e}")) + + def _fetch_public_key(self): + """获取 API 网关公钥""" + self.stdout.write("[Sync] fetch the public key") + try: + call_command("fetch_apigw_public_key") + except Exception as e: + self.stderr.write(self.style.ERROR(f"run fetch_apigw_public_key fail: {e}")) + raise SystemExit(1) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/models.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/models.py new file mode 100644 index 0000000..330845c --- /dev/null +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/models.py @@ -0,0 +1,35 @@ +""" +Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. +Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://opensource.org/licenses/MIT +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. +""" + +from django.db import models + + +class APIGatewaySyncState(models.Model): + """API网关同步状态记录 + + 用于存储上次成功同步时的接口定义哈希值, + 通过对比哈希值判断是否需要重新同步。 + """ + + # resources.yaml 的哈希值 + api_hash = models.CharField(max_length=64, default="", verbose_name="接口定义哈希值") + # 上次同步时间 + last_sync_at = models.DateTimeField(auto_now=True, verbose_name="上次同步时间") + # 同步是否成功 + sync_success = models.BooleanField(default=False, verbose_name="同步是否成功") + + class Meta: + db_table = "bpf_apigateway_sync_state" + verbose_name = "API网关同步状态" + verbose_name_plural = "API网关同步状态" + + def __str__(self): + return f"APIGatewaySyncState(hash={self.api_hash[:16]}..., success={self.sync_success})" From 46d6fa622389c08207801ae60756e8b222b3fb5a Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Thu, 8 Jan 2026 21:15:00 +0800 Subject: [PATCH 13/17] =?UTF-8?q?fix:=20=E8=BF=BD=E5=8A=A0plugin=5Fapi?= =?UTF-8?q?=E7=9A=84=E4=BF=A1=E6=81=AF=E5=88=B0resources.yaml=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E8=A7=A3=E5=86=B3method=E4=B8=BAANY=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/bpf_service/api/callback.py | 2 + .../services/bpf_service/api/detail.py | 2 + .../services/bpf_service/api/invoke.py | 2 + .../services/bpf_service/api/logs.py | 2 + .../services/bpf_service/api/meta.py | 2 + .../bpf_service/api/plugin_api_dispatch.py | 2 + .../services/bpf_service/api/schedule.py | 2 + .../commands/sync_apigateway_if_changed.py | 70 +++++++++++++++++++ .../bpf_service/migrations/0001_initial.py | 63 +++++++++++++++++ .../bin/sync_apigateway.sh | 59 ++++------------ 10 files changed, 161 insertions(+), 45 deletions(-) create mode 100644 bk-plugin-framework/bk_plugin_framework/services/bpf_service/migrations/0001_initial.py diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py index 5baded3..365400f 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py @@ -19,6 +19,7 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import serializers +from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView @@ -57,6 +58,7 @@ class PluginCallback(APIView): match_subpath=False, ), ) + @action(methods=["POST"], detail=True) def post(self, request, token): logger.info("[plugin callback]token=({}),body={}".format(token, request.body)) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py index 15e806f..6893f21 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py @@ -16,6 +16,7 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers, status +from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView @@ -80,6 +81,7 @@ class Detail(APIView): match_subpath=False, ), ) + @action(methods=["GET"], detail=True) def get(self, request, version): plugin_cls = VersionHub.all_plugins().get(version) if not plugin_cls: diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py index 44fcda5..9bd3f2d 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py @@ -17,6 +17,7 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import serializers, status +from rest_framework.decorators import action from rest_framework.exceptions import ValidationError from rest_framework.response import Response from rest_framework.views import APIView @@ -72,6 +73,7 @@ class Invoke(APIView): match_subpath=False, ), ) + @action(methods=["POST"], detail=True) def post(self, request, version): plugin_cls = VersionHub.all_plugins().get(version) if not plugin_cls: diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py index 07a960d..e1cf6e4 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py @@ -16,6 +16,7 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers +from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView @@ -56,5 +57,6 @@ class Logs(APIView): match_subpath=False, ), ) + @action(methods=["GET"], detail=True) def get(self, request, trace_id): return Response({"result": True, "data": {"log": LogEntry.objects.get_plain_log(trace_id)}, "message": ""}) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py index 0839d75..e75a675 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py @@ -18,6 +18,7 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers +from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView @@ -74,6 +75,7 @@ class Meta(APIView): match_subpath=False, ), ) + @action(methods=["GET"], detail=True) def get(self, request): try: meta_module = import_module("bk_plugin.meta") diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py index fe32215..363bfd7 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py @@ -22,6 +22,7 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import serializers, status +from rest_framework.decorators import action from rest_framework.exceptions import ValidationError from rest_framework.response import Response from rest_framework.views import APIView @@ -93,6 +94,7 @@ class PluginAPIDispatch(APIView): match_subpath=False, ), ) + @action(methods=["POST"], detail=True) def post(self, request): data_serializer = PluginAPIDispatchParamsSerializer(data=request.data) try: diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py index d85f7df..70d09d2 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py @@ -17,6 +17,7 @@ from django.utils.decorators import method_decorator from drf_spectacular.utils import extend_schema from rest_framework import permissions, serializers +from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.views import APIView @@ -68,6 +69,7 @@ class Schedule(APIView): match_subpath=False, ), ) + @action(methods=["GET"], detail=True) def get(self, request, trace_id): try: s = ScheduleModel.objects.get(trace_id=trace_id) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py index cb8c31c..4a7eb19 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py @@ -12,6 +12,8 @@ import hashlib import os +import yaml +from django.conf import settings from django.core.management import call_command from django.core.management.base import BaseCommand @@ -55,6 +57,9 @@ def handle(self, *args, **options): ) raise SystemExit(1) + # 1.1 追加 plugin_api 资源配置 + self._append_plugin_api_resource() + # 2. 计算当前哈希值(仅计算 resources.yaml) current_hash = self._calculate_resources_hash() self.stdout.write(f"[Sync] Current resources.yaml hash: {current_hash[:16]}...") @@ -95,6 +100,71 @@ def handle(self, *args, **options): self._save_sync_hash(current_hash, success=True) self.stdout.write(self.style.SUCCESS("[Sync] API gateway sync completed successfully")) + def _append_plugin_api_resource(self): + """在 resources.yaml 的 paths 节点下追加 plugin_api 资源配置""" + filepath = "/app/bk_plugin_runtime/resources.yaml" + if not os.path.exists(filepath): + self.stdout.write(self.style.WARNING(f"[Sync] {filepath} not found, skip appending plugin_api")) + return + + try: + # 读取现有内容,检查是否已存在 + with open(filepath) as f: + content = f.read() + + plugin_api_path = "/bk_plugin/plugin_api/:" + if plugin_api_path in content: + self.stdout.write("[Sync] plugin_api resource already exists, skip appending") + return + + # 根据 settings.BK_PLUGIN_APIGW_BACKEND_SUB_PATH 决定 backend path + if getattr(settings, "BK_PLUGIN_APIGW_BACKEND_SUB_PATH", False): + backend_path = "/{env.api_sub_path}bk_plugin/plugin_api/" + else: + backend_path = "/bk_plugin/plugin_api/" + + # 使用 YAML 解析来正确插入 + data = yaml.safe_load(content) + + if "paths" not in data: + self.stdout.write(self.style.WARNING("[Sync] 'paths' not found in resources.yaml, skip appending")) + return + + # 在 paths 下添加 plugin_api 路径 + data["paths"]["/bk_plugin/plugin_api/"] = { + "x-bk-apigateway-method-any": { + "operationId": "plugin_api", + "description": "", + "tags": [], + "responses": {"default": {"description": ""}}, + "x-bk-apigateway-resource": { + "isPublic": True, + "allowApplyPermission": True, + "matchSubpath": True, + "backend": { + "type": "HTTP", + "method": "any", + "path": backend_path, + "matchSubpath": True, + "timeout": 0, + "upstreams": {}, + "transformHeaders": {}, + }, + "authConfig": {"userVerifiedRequired": True, "appVerifiedRequired": False}, + "disabledStages": [], + }, + } + } + + # 写回文件(使用 yaml.dump 保持格式) + with open(filepath, "w") as f: + yaml.dump(data, f, default_flow_style=False, allow_unicode=True, sort_keys=False) + + self.stdout.write(self.style.SUCCESS("[Sync] plugin_api resource appended to resources.yaml")) + + except Exception as e: + self.stderr.write(self.style.ERROR(f"[Sync] Failed to append plugin_api resource: {e}")) + def _print_yaml_content(self, filepath, name): """打印 YAML 文件内容""" if os.path.exists(filepath): diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/migrations/0001_initial.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/migrations/0001_initial.py new file mode 100644 index 0000000..1ac1731 --- /dev/null +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/migrations/0001_initial.py @@ -0,0 +1,63 @@ +""" +Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available. +Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://opensource.org/licenses/MIT +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. +""" + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="APIGatewaySyncState", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "api_hash", + models.CharField( + default="", + max_length=64, + verbose_name="接口定义哈希值", + ), + ), + ( + "last_sync_at", + models.DateTimeField( + auto_now=True, + verbose_name="上次同步时间", + ), + ), + ( + "sync_success", + models.BooleanField( + default=False, + verbose_name="同步是否成功", + ), + ), + ], + options={ + "verbose_name": "API网关同步状态", + "verbose_name_plural": "API网关同步状态", + "db_table": "bpf_apigateway_sync_state", + }, + ), + ] diff --git a/template/{{cookiecutter.project_name}}/bin/sync_apigateway.sh b/template/{{cookiecutter.project_name}}/bin/sync_apigateway.sh index 95e18da..f4c3fa2 100755 --- a/template/{{cookiecutter.project_name}}/bin/sync_apigateway.sh +++ b/template/{{cookiecutter.project_name}}/bin/sync_apigateway.sh @@ -4,54 +4,23 @@ echo "do migrate" python bin/manage.py migrate --no-input echo "[Sync] BEGIN =====================" -echo "[Sync] generate definition.yaml" -python bin/manage.py generate_definition_yaml -if [ $? -ne 0 ] -then - echo "run generate_definition_yaml fail, please run this command on your development env to find out the reason" - exit 1 -fi - -if [ -f /app/definition.yaml ] -then - echo "[Sync] the /app/definition.yaml content:" - cat /app/definition.yaml - echo "====================" -fi - - -echo "[Sync] generate resources.yaml" -python bin/manage.py generate_resources_yaml +# 使用智能同步命令,仅在接口定义发生变化时才同步到API网关 +# 该命令会自动: +# 1. 生成 definition.yaml 和 resources.yaml +# 2. 计算文件哈希值并与上次同步的哈希值对比 +# 3. 仅在哈希值变化时执行 sync_drf_apigateway +# 4. 获取 API 网关公钥 +# +# 如需强制同步,可添加 --force 参数: +# python bin/manage.py sync_apigateway_if_changed --force + +python bin/manage.py sync_apigateway_if_changed if [ $? -ne 0 ] then - echo "run generate_resources_yaml fail, please run this command on your development env to find out the reason" - exit 1 -fi - -if [ -f /app/resources.yaml ] -then - echo "[Sync] the /app/resources.yaml content:" - cat /app/resources.yaml - echo "====================" -fi - -echo "[Sync] sync to apigateway" -python bin/manage.py sync_drf_apigateway -if [ $? -ne 0 ] -then - echo "run sync_drf_apigateway fail" - exit 1 -fi - -echo "[Sync] fetch the public key" -python bin/manage.py fetch_apigw_public_key -if [ $? -ne 0 ] -then - echo "run fetch_apigw_public_key fail" - exit 1 + echo "sync_apigateway_if_changed fail" + exit 1 fi echo "[Sync] DONE =====================" -# DO NOT MODIFY THIS SECTION !!! - +# DO NOT MODIFY THIS SECTION !!! \ No newline at end of file From 7f129dffa5320dbd5be815d1cf927f93c03a81e8 Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Thu, 8 Jan 2026 21:21:18 +0800 Subject: [PATCH 14/17] =?UTF-8?q?fix:=20=E5=B1=8F=E8=94=BDschedule?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=A1=E6=81=AF=E5=90=8C=E6=AD=A5=E5=88=B0?= =?UTF-8?q?=E7=BD=91=E5=85=B3apigw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py index 68d13bf..31111d1 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py @@ -247,6 +247,7 @@ def preprocessing_filter_internal_apis(endpoints): "/bk_plugin/detail", "/bk_plugin/meta", "/bk_plugin/logs", + "/bk_plugin/schedule", ] filtered = [] for path, path_regex, method, callback in endpoints: From 2b1c49c6fe5de7c22cebc0dc9951cd74aeafedaa Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Fri, 9 Jan 2026 15:24:25 +0800 Subject: [PATCH 15/17] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=8F=8F=E8=BF=B0=E4=B8=8D=E8=A7=84=E8=8C=83=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bk_plugin_framework/services/bpf_service/api/callback.py | 2 +- .../bk_plugin_framework/services/bpf_service/api/detail.py | 5 +++-- .../bk_plugin_framework/services/bpf_service/api/invoke.py | 4 ++-- .../bk_plugin_framework/services/bpf_service/api/logs.py | 5 +++-- .../bk_plugin_framework/services/bpf_service/api/meta.py | 5 +++-- .../services/bpf_service/api/plugin_api_dispatch.py | 2 +- .../bk_plugin_framework/services/bpf_service/api/schedule.py | 4 +++- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py index 365400f..b3c1fd5 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/callback.py @@ -54,7 +54,7 @@ class PluginCallback(APIView): user_verified_required=True, app_verified_required=True, resource_permission_required=True, - description_en="插件调用", + description_en="plugin callback", match_subpath=False, ), ) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py index 6893f21..fc17fd0 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/detail.py @@ -69,7 +69,8 @@ class Detail(APIView): permission_classes = [permissions.AllowAny] @extend_schema( - summary="Get plugin detail for specific version", + summary="获取指定版本的插件详情", + operation_id="plugin_detail", responses={200: standard_response_enveloper(DetailResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, @@ -77,7 +78,7 @@ class Detail(APIView): user_verified_required=True, app_verified_required=True, resource_permission_required=True, - description_en="插件调用", + description_en="Get plugin detail for specific version", match_subpath=False, ), ) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py index 9bd3f2d..1afb59f 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/invoke.py @@ -59,7 +59,7 @@ class Invoke(APIView): permission_classes = [ScopeAllowPermission] @extend_schema( - summary="插件调用", + summary="调用指定版本插件", operation_id="invoke", request=InvokeParamsSerializer, responses={200: standard_response_enveloper(InvokeResponseSerializer)}, @@ -69,7 +69,7 @@ class Invoke(APIView): user_verified_required=True, app_verified_required=True, resource_permission_required=True, - description_en="插件调用", + description_en="Invoke specific version plugin", match_subpath=False, ), ) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py index e1cf6e4..fa4acc1 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/logs.py @@ -45,7 +45,8 @@ class Logs(APIView): permission_classes = [permissions.AllowAny] @extend_schema( - summary="Get plugin execution log with trace_id", + summary="获取插件执行日志", + operation_id="plugin_logs", responses={200: standard_response_enveloper(LogsResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, @@ -53,7 +54,7 @@ class Logs(APIView): user_verified_required=True, app_verified_required=True, resource_permission_required=True, - description_en="插件调用", + description_en="Get plugin execution log with trace_id", match_subpath=False, ), ) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py index e75a675..2126a56 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/meta.py @@ -63,7 +63,8 @@ class Meta(APIView): permission_classes = [permissions.AllowAny] @extend_schema( - summary="Get plugin meta info", + summary="获取插件元信息", + operation_id="plugin_meta_info", responses={200: standard_response_enveloper(MetaResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True, @@ -71,7 +72,7 @@ class Meta(APIView): user_verified_required=True, app_verified_required=True, resource_permission_required=True, - description_en="插件调用", + description_en="Get plugin meta info", match_subpath=False, ), ) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py index 363bfd7..2ed6036 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/plugin_api_dispatch.py @@ -90,7 +90,7 @@ class PluginAPIDispatch(APIView): user_verified_required=True, app_verified_required=True, resource_permission_required=True, - description_en="插件调用", + description_en="Plugin API dispatch", match_subpath=False, ), ) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py index 70d09d2..4a6814b 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py @@ -57,6 +57,8 @@ class Schedule(APIView): @extend_schema( summary="获取插件调度详情", + operation_id="plugin_schedule", + parameters=[ScheduleParamsSerializer], request=ScheduleParamsSerializer, responses={200: standard_response_enveloper(ScheduleResponseSerializer)}, extensions=gen_apigateway_resource_config( @@ -65,7 +67,7 @@ class Schedule(APIView): user_verified_required=True, app_verified_required=True, resource_permission_required=True, - description_en="插件调用", + description_en="Get plugin schedule detail with trace_id", match_subpath=False, ), ) From 017fc7affe46dab9637d80083b28cba98bca503d Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Fri, 9 Jan 2026 15:26:45 +0800 Subject: [PATCH 16/17] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=20resources.yam?= =?UTF-8?q?l=E7=9A=84=E8=8E=B7=E5=8F=96=E8=B7=AF=E5=BE=84=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E4=B8=8E=20apigw=20=E4=BF=9D=E6=8C=81=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/commands/sync_apigateway_if_changed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py index 4a7eb19..e3d1dbe 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/management/commands/sync_apigateway_if_changed.py @@ -102,7 +102,7 @@ def handle(self, *args, **options): def _append_plugin_api_resource(self): """在 resources.yaml 的 paths 节点下追加 plugin_api 资源配置""" - filepath = "/app/bk_plugin_runtime/resources.yaml" + filepath = os.path.join(settings.BASE_DIR, "resources.yaml") if not os.path.exists(filepath): self.stdout.write(self.style.WARNING(f"[Sync] {filepath} not found, skip appending plugin_api")) return @@ -175,7 +175,7 @@ def _print_yaml_content(self, filepath, name): def _calculate_resources_hash(self): """计算 resources.yaml 的哈希值""" - filepath = "/app/bk_plugin_runtime/resources.yaml" + filepath = os.path.join(settings.BASE_DIR, "resources.yaml") if os.path.exists(filepath): with open(filepath) as f: content = f.read() From 6aea9f87ca8e6760d3b55120c0d2b34ef63d2f94 Mon Sep 17 00:00:00 2001 From: Xinkai Yi Date: Fri, 9 Jan 2026 15:55:52 +0800 Subject: [PATCH 17/17] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4Schedule?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=8E=A5=E5=8F=A3=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bk_plugin_framework/services/bpf_service/api/schedule.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py index 4a6814b..1d05161 100644 --- a/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py +++ b/bk-plugin-framework/bk_plugin_framework/services/bpf_service/api/schedule.py @@ -59,7 +59,6 @@ class Schedule(APIView): summary="获取插件调度详情", operation_id="plugin_schedule", parameters=[ScheduleParamsSerializer], - request=ScheduleParamsSerializer, responses={200: standard_response_enveloper(ScheduleResponseSerializer)}, extensions=gen_apigateway_resource_config( is_public=True,