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/.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 new file mode 100644 index 0000000..a38357b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +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 + + - 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/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..fe6e59a 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 Context # noqa from bk_plugin_framework.kit.plugin import ( # noqa - Plugin, + Callback, + ContextRequire, + FormModel, InputsModel, - Context, OutputsModel, - ContextRequire, + Plugin, State, - Callback, - FormModel, ) diff --git a/bk-plugin-framework/bk_plugin_framework/kit/api.py b/bk-plugin-framework/bk_plugin_framework/kit/api.py index fb38f9a..24757e1 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,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 -from django.utils.decorators import method_decorator +from apigw_manager.apigw.decorators import apigw_require +from bkoauth import get_app_access_token from django.conf import settings as default_settings -from rest_framework.views import APIView +from django.utils.decorators import method_decorator from rest_framework.request import Request -from bkoauth import get_app_access_token -from apigw_manager.apigw.decorators import apigw_require +from rest_framework.views import APIView 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 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..5d24958 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,18 @@ 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 +49,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..5f3540c 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,24 @@ 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 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 -from bk_plugin_framework.constants import State 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..52e21d4 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,22 @@ 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 celery import current_app, shared_task -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 logger = logging.getLogger("bk_plugin") @@ -60,7 +60,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 +80,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..1e07e0d 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,22 +19,23 @@ 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 @@ -179,7 +179,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 +317,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..4a99ab9 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,7 +9,6 @@ specific language governing permissions and limitations under the License. """ - from django.contrib import admin from bk_plugin_framework.runtime.loghub import models 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..a02653f 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. 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..f5179ba 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,7 +9,6 @@ specific language governing permissions and limitations under the License. """ - from django.contrib import admin from bk_plugin_framework.runtime.schedule import models 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..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 @@ -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,12 +13,12 @@ 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 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/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..0a10b6b 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,20 @@ 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 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 rest_framework.views import APIView -from bk_plugin_framework.runtime.callback.api import parse_callback_token, callback +from bk_plugin_framework.runtime.callback.api import callback, parse_callback_token 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..7adc250 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,15 +11,13 @@ import logging +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 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.services.bpf_service.api.serializers import StandardResponseSerializer 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..edc6221 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,17 +11,15 @@ import logging +from apigw_manager.apigw.decorators import apigw_require +from blueapps.account.decorators import login_exempt 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 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 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..289d7fa 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,15 +11,13 @@ import logging +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 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.services.bpf_service.api.serializers import StandardResponseSerializer 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..4377d06 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,16 +12,14 @@ import logging from importlib import import_module -from django.utils.decorators import method_decorator +from blueapps.account.decorators import login_exempt 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 django.utils.decorators import method_decorator from drf_yasg.utils import swagger_auto_schema -from blueapps.account.decorators import login_exempt - +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 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..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,4 +1,3 @@ -# -*- coding: utf-8 -*- from importlib import import_module from rest_framework.permissions import BasePermission 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..61697f2 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,24 +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 json import logging import re - from urllib.parse import urlsplit + +from apigw_manager.apigw.decorators import apigw_require +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 rest_framework.response import Response +from rest_framework.views import APIView from bk_plugin_framework.services.bpf_service.api.permissions import ScopeAllowPermission from bk_plugin_framework.services.bpf_service.api.serializers import StandardResponseSerializer @@ -64,7 +62,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 +95,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..2025097 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,15 +12,13 @@ import json import logging +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 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.services.bpf_service.api.serializers import StandardResponseSerializer @@ -77,7 +74,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..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 @@ -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 importlib import import_module from django.apps import 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..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 @@ -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,13 @@ specific language governing permissions and limitations under the License. """ -import sys import importlib +import sys + +from django.urls import include, path -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 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/tests/conftest.py b/bk-plugin-framework/tests/conftest.py index 51fa133..75b1040 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. @@ -12,8 +11,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..c6438c3 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,19 +8,12 @@ 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 -from bk_plugin_framework.kit import ( - Plugin, - InputsModel, - OutputsModel, - ContextRequire, - Callback, - Context, - State, -) +import pytest + +from bk_plugin_framework.kit import 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..d75df63 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,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 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 +35,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 +62,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..b91cee2 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,12 @@ 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..b4cf471 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,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 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..04a1d6d 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,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. """ + import uuid +from unittest.mock import MagicMock, patch import pytest -from unittest.mock import MagicMock, patch 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..b877d2a 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,18 +8,13 @@ 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 -from bk_plugin_framework.kit import ( - Plugin, - InputsModel, - ContextRequire, - Context, - State, -) +import pytest + +from bk_plugin_framework.kit import 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..9fb36b8 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,8 @@ 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.schedule.celery import queues as schedule_queues # noqa CELERY_QUEUES = schedule_queues.CELERY_QUEUES CELERY_QUEUES.extend(callback_queues.CELERY_QUEUES) @@ -77,9 +76,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 +129,8 @@ LANGUAGE_CODE = "zh-hans" LANGUAGES = ( - ("en", u"English"), - ("zh-hans", u"简体中文"), + ("en", "English"), + ("zh-hans", "简体中文"), ) """ @@ -174,6 +171,7 @@ 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 celery_app.conf.beat_schedule = SCHEDULE @@ -254,6 +252,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..0ec02c3 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,7 +10,9 @@ """ import os + import MySQLdb + from bk_plugin_runtime.config import RUN_VER if RUN_VER == "open": @@ -37,10 +38,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")