diff --git a/bk-plugin-framework/bk_plugin_framework/__version__.py b/bk-plugin-framework/bk_plugin_framework/__version__.py index 2c7edca..87cc64b 100644 --- a/bk-plugin-framework/bk_plugin_framework/__version__.py +++ b/bk-plugin-framework/bk_plugin_framework/__version__.py @@ -10,4 +10,4 @@ specific language governing permissions and limitations under the License. """ -__version__ = "2.3.2" +__version__ = "2.4.0rc0" diff --git a/bk-plugin-framework/bk_plugin_framework/kit/__init__.py b/bk-plugin-framework/bk_plugin_framework/kit/__init__.py index 9f86e23..1eecd0e 100644 --- a/bk-plugin-framework/bk_plugin_framework/kit/__init__.py +++ b/bk-plugin-framework/bk_plugin_framework/kit/__init__.py @@ -23,4 +23,6 @@ State, Callback, FormModel, + Credential, + CredentialModel, ) diff --git a/bk-plugin-framework/bk_plugin_framework/kit/plugin.py b/bk-plugin-framework/bk_plugin_framework/kit/plugin.py index 0fc951e..2432bba 100644 --- a/bk-plugin-framework/bk_plugin_framework/kit/plugin.py +++ b/bk-plugin-framework/bk_plugin_framework/kit/plugin.py @@ -50,6 +50,26 @@ class ContextRequire(BaseModel): pass +class CredentialModel: + """凭证模型基类,用于声明插件需要的凭证""" + + pass + + +class Credential(BaseModel): + """凭证定义类,用于声明插件需要的凭证""" + + key: str + name: str = "" + description: str = "" + + def __init__(self, key: str, name: str = "", description: str = "", **kwargs): + # 如果 name 为空,使用 key 作为 name + if not name: + name = key + super().__init__(key=key, name=name, description=description, **kwargs) + + class Callback(object): def __init__(self, callback_id: str = "", callback_data: dict = {}): self.id = callback_id @@ -66,6 +86,7 @@ def __init__( callback: Callback = None, outputs: typing.Optional[dict] = None, storage: typing.Optional[dict] = None, + credentials: typing.Optional[dict] = None, ): self.trace_id = trace_id self.data = data @@ -74,6 +95,7 @@ def __init__( self.callback = callback self.storage = storage or {} self.outputs = outputs or {} + self.credentials = credentials or {} @property def schedule_context(self) -> dict: @@ -140,6 +162,28 @@ def __new__(cls, name, bases, dct): "plugin deinition error, {}'s ContextInputs is not subclass of {}".format(new_cls, ContextRequire) ) + # credentials validation (class attribute, similar to ContextInputs) + credentials_cls = getattr(new_cls, "Credentials", None) + if credentials_cls: + # Check if Credentials class inherits from CredentialModel + if not issubclass(credentials_cls, CredentialModel): + raise TypeError( + "plugin deinition error, {}'s Credentials is not subclass of {}".format(new_cls, CredentialModel) + ) + + # Validate each Credential instance in the Credentials class + for attr_name in dir(credentials_cls): + if attr_name.startswith("_"): + continue + attr_value = getattr(credentials_cls, attr_name) + if isinstance(attr_value, Credential): + if not attr_value.key: + raise ValueError( + "plugin deinition error, Credentials.{}.key cannot be empty in {}".format( + attr_name, new_cls + ) + ) + # inputs form check inputs_form_cls = getattr(new_cls, "InputsForm", None) if inputs_form_cls and not issubclass(inputs_form_cls, FormModel): @@ -200,6 +244,7 @@ def dict(cls) -> dict: "desc": getattr(cls.Meta, "desc", ""), "version": cls.Meta.version, "enable_plugin_callback": getattr(cls.Meta, "enable_plugin_callback", False), + "credentials": cls._EMPTY_SCHEMA, "inputs": cls._EMPTY_SCHEMA, "outputs": cls._EMPTY_SCHEMA, "context_inputs": cls._EMPTY_SCHEMA, @@ -227,4 +272,18 @@ def dict(cls) -> dict: if context_cls: data["context_inputs"] = cls._trim_schema(context_cls.schema()) + # Extract credentials from Credentials class + credentials_cls = getattr(cls, "Credentials", None) + if credentials_cls: + credentials_list = [] + for attr_name in dir(credentials_cls): + if attr_name.startswith("_"): + continue + attr_value = getattr(credentials_cls, attr_name) + if isinstance(attr_value, Credential): + credentials_list.append(attr_value) + + data["credentials"] = [ + {"key": c.key, "name": c.name, "description": c.description} for c in credentials_list + ] return data diff --git a/bk-plugin-framework/bk_plugin_framework/metrics.py b/bk-plugin-framework/bk_plugin_framework/metrics.py index eb00914..ed03625 100644 --- a/bk-plugin-framework/bk_plugin_framework/metrics.py +++ b/bk-plugin-framework/bk_plugin_framework/metrics.py @@ -129,14 +129,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/callback/celery/tasks.py b/bk-plugin-framework/bk_plugin_framework/runtime/callback/celery/tasks.py index 4b3d03b..bb1bcf4 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 @@ -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/executor.py b/bk-plugin-framework/bk_plugin_framework/runtime/executor.py index 2cc2031..b0852ab 100644 --- a/bk-plugin-framework/bk_plugin_framework/runtime/executor.py +++ b/bk-plugin-framework/bk_plugin_framework/runtime/executor.py @@ -90,7 +90,11 @@ def _plugin_finish_callback(self, plugin_cls: Plugin, plugin_callback_info: typi @setup_gauge(BK_PLUGIN_EXECUTE_RUNNING_PROCESSES) @setup_histogram(BK_PLUGIN_EXECUTE_TIME) def execute( - self, plugin_cls: Plugin, inputs: typing.Dict[str, typing.Any], context_inputs: typing.Dict[str, typing.Any] + self, + plugin_cls: Plugin, + inputs: typing.Dict[str, typing.Any], + context_inputs: typing.Dict[str, typing.Any], + credentials: typing.Optional[typing.Dict[str, typing.Any]] = None, ) -> ExecuteResult: # user inputs validation @@ -109,7 +113,12 @@ def execute( # domain object initialization context = Context( - trace_id=self.trace_id, data=valid_context_inputs, state=State.EMPTY, invoke_count=1, outputs={} + trace_id=self.trace_id, + data=valid_context_inputs, + state=State.EMPTY, + invoke_count=1, + outputs={}, + credentials=credentials or {}, ) plugin = plugin_cls() # run execute method @@ -141,8 +150,10 @@ def execute( # prepare persistent data for schedule try: + schedule_context = context.schedule_context.copy() + schedule_context["credentials"] = context.credentials schedule_data = self._dump_schedule_data( - inputs=inputs, context=context.schedule_context, outputs=context.outputs + inputs=inputs, context=schedule_context, outputs=context.outputs ) except Exception as e: logger.exception("[execute] schedule data json dumps error") @@ -235,6 +246,7 @@ def schedule(self, plugin_cls: Plugin, schedule: Schedule, callback_info: dict = ), outputs=schedule_data["context"]["outputs"], storage=schedule_data["context"]["storage"], + credentials=schedule_data["context"].get("credentials", {}), ) plugin = plugin_cls() err = "" @@ -256,8 +268,10 @@ def schedule(self, plugin_cls: Plugin, schedule: Schedule, callback_info: dict = context.data = context_inputs_cls(**schedule_data["context"]["data"]) try: + schedule_context = context.schedule_context.copy() + schedule_context["credentials"] = context.credentials schedule_data = self._dump_schedule_data( - inputs=schedule_data["inputs"], context=context.schedule_context, outputs=context.outputs + inputs=schedule_data["inputs"], context=schedule_context, outputs=context.outputs ) except Exception: logger.exception("[execute] schedule data json dumps error") 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..1f1c348 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 @@ -28,6 +28,7 @@ from bk_plugin_framework.runtime.executor import BKPluginExecutor from bk_plugin_framework.services.bpf_service.api.permissions import ScopeAllowPermission from bk_plugin_framework.services.bpf_service.api.serializers import StandardResponseSerializer +from bk_plugin_framework.kit.plugin import Credential logger = logging.getLogger("bk_plugin") @@ -35,6 +36,54 @@ class InvokeParamsSerializer(serializers.Serializer): inputs = serializers.DictField(help_text="插件调用参数", required=True) context = serializers.DictField(help_text="插件执行上下文", required=True) + credentials = serializers.DictField(help_text="插件凭证", required=False, allow_null=True) + + def validate(self, attrs): + """验证凭证是否提供""" + plugin_cls = self.context.get("plugin_cls") + if not plugin_cls: + return attrs + + # Check if plugin requires credentials (class attribute, similar to ContextInputs) + credentials_list = [] + credentials_cls = getattr(plugin_cls, "Credentials", None) + if credentials_cls: + # Extract all Credential instances from Credentials class + for attr_name in dir(credentials_cls): + if attr_name.startswith("_"): + continue + attr_value = getattr(credentials_cls, attr_name) + if isinstance(attr_value, Credential): + credentials_list.append(attr_value) + + if credentials_list: + # Verify that credentials is provided at top level + credentials = attrs.get("credentials") + + # Check if credentials is a dict + if not isinstance(credentials, dict): + credential_names = [c.name or c.key for c in credentials_list] + raise serializers.ValidationError( + f"该插件需要凭证({', '.join(credential_names)}),请在请求中提供 credentials 字典" + ) + + # Check each required credential + missing_credentials = [] + for cred_def in credentials_list: + # Check if key exists and value is not None or empty string + if ( + cred_def.key not in credentials + or credentials.get(cred_def.key) is None + or credentials.get(cred_def.key) == "" + ): + missing_credentials.append(cred_def.name or cred_def.key) + + if missing_credentials: + raise serializers.ValidationError( + f"该插件需要以下凭证:{', '.join(missing_credentials)},请在 credentials 中提供这些字段" + ) + + return attrs class InvokeResponseSerializer(StandardResponseSerializer): @@ -67,21 +116,27 @@ def post(self, request, version): if not plugin_cls: return Response(status=status.HTTP_404_NOT_FOUND) - data_serializer = InvokeParamsSerializer(data=request.data) + data_serializer = InvokeParamsSerializer(data=request.data, context={"plugin_cls": plugin_cls}) try: data_serializer.is_valid(raise_exception=True) except ValidationError as e: return Response( - data={"result": False, "data": None, "message": "输入不合法: %s" % e}, + data={"result": False, "data": None, "message": "输入不合法: %s" % e, "trace_id": request.trace_id}, status=status.HTTP_400_BAD_REQUEST, ) request_data = data_serializer.validated_data + # Extract credentials from request data + credentials = request_data.get("credentials") or {} + executor = BKPluginExecutor(trace_id=request.trace_id) try: execute_result = executor.execute( - plugin_cls=plugin_cls, inputs=request_data["inputs"], context_inputs=request_data["context"] + plugin_cls=plugin_cls, + inputs=request_data["inputs"], + context_inputs=request_data["context"], + credentials=credentials, ) except Exception as e: logging.exception("executor execute raise error") diff --git a/bk-plugin-framework/poetry.lock b/bk-plugin-framework/poetry.lock index 661b9a3..149fd81 100644 --- a/bk-plugin-framework/poetry.lock +++ b/bk-plugin-framework/poetry.lock @@ -200,14 +200,14 @@ files = [ [[package]] name = "bk-plugin-runtime" -version = "2.1.1" +version = "2.2.0rc0" description = "bk plugin python django runtime" optional = false python-versions = "<4.0.0,>=3.8.0" groups = ["main"] files = [ - {file = "bk_plugin_runtime-2.1.1-py3-none-any.whl", hash = "sha256:258bc6acd9f3041d8c78eac7c5b409bf498a2b34686d9553c6f8fd3444f31876"}, - {file = "bk_plugin_runtime-2.1.1.tar.gz", hash = "sha256:0db0d4ec7c4e6f58f1327e1c4235ac815f939bf6715c9a2bc43bb757a17fbacc"}, + {file = "bk_plugin_runtime-2.2.0rc0-py3-none-any.whl", hash = "sha256:efdbcf97cd4e6bb7c25453e59969ce33681b7683656e4978adb3729a58a6e6cc"}, + {file = "bk_plugin_runtime-2.2.0rc0.tar.gz", hash = "sha256:d5620405afcc6e58ef402e704927a073b3157c6b715053d49ab3bf5f649b87f9"}, ] [package.dependencies] @@ -4404,4 +4404,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.8.0,<4.0" -content-hash = "23f8fc59423edbe6e5f25359943ed2b2b3b431aaf70a923de49bb3ca7a51c61b" +content-hash = "78c877eac4295113dcd0ba8ee232c16bc233305fd063a0de663ec1813ecda0ad" diff --git a/bk-plugin-framework/pyproject.toml b/bk-plugin-framework/pyproject.toml index 325c11e..1ed2b83 100644 --- a/bk-plugin-framework/pyproject.toml +++ b/bk-plugin-framework/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bk-plugin-framework" -version = "2.3.2" +version = "2.4.0rc0" description = "bk plugin python framework" authors = ["Your Name "] license = "MIT" @@ -10,7 +10,7 @@ python = "^3.8.0,<4.0" pydantic = ">=1.0,<3" werkzeug = ">=2.0.0, <4.0" apigw-manager = {version = ">=1.0.6, <4", extras = ["extra"]} -bk-plugin-runtime = "2.1.1" +bk-plugin-runtime = "2.2.0rc0" jsonschema = ">=2.5.0,<5.0.0" [tool.poetry.dev-dependencies] diff --git a/bk-plugin-framework/tests/kit/test_plugin.py b/bk-plugin-framework/tests/kit/test_plugin.py index 4d95a04..4069c3b 100644 --- a/bk-plugin-framework/tests/kit/test_plugin.py +++ b/bk-plugin-framework/tests/kit/test_plugin.py @@ -21,6 +21,8 @@ Callback, Context, State, + Credential, + CredentialModel, ) from bk_plugin_framework.runtime.callback.api import CallbackPreparation @@ -153,6 +155,7 @@ def test_dict(self, my_plugin_cls): "desc": "", "version": my_plugin_cls.Meta.version, "enable_plugin_callback": False, + "credentials": my_plugin_cls._EMPTY_SCHEMA, "inputs": { "type": my_plugin_cls.Inputs.schema()["type"], "properties": my_plugin_cls.Inputs.schema()["properties"], @@ -177,6 +180,7 @@ def test_dict_pass_outputs_model(self, my_plugin_cls_v101): "desc": "", "version": my_plugin_cls.Meta.version, "enable_plugin_callback": False, + "credentials": my_plugin_cls._EMPTY_SCHEMA, "inputs": { "type": my_plugin_cls.Inputs.schema()["type"], "properties": my_plugin_cls.Inputs.schema()["properties"], @@ -194,3 +198,77 @@ def test_dict_pass_outputs_model(self, my_plugin_cls_v101): "renderform": my_plugin_cls.renderform, }, } + + @patch("bk_plugin_framework.hub.load_form_module_path", MagicMock(return_value="tests")) + def test_dict_with_credentials(self): + class PluginWithCredentials(Plugin): + class Meta: + version = "1.0.2" + + class Inputs(InputsModel): + a: int + + class ContextInputs(ContextRequire): + b: str + + class Credentials(CredentialModel): + api_key = Credential(key="api_key", name="API Key", description="API Key for authentication") + api_secret = Credential(key="api_secret", name="API Secret", description="API Secret") + + result = PluginWithCredentials.dict() + assert "credentials" in result + assert isinstance(result["credentials"], list) + assert len(result["credentials"]) == 2 + assert result["credentials"][0]["key"] == "api_key" + assert result["credentials"][0]["name"] == "API Key" + assert result["credentials"][1]["key"] == "api_secret" + + @patch("bk_plugin_framework.hub.load_form_module_path", MagicMock(return_value="tests")) + def test_credentials_validation_invalid_subclass(self): + with pytest.raises(TypeError, match="Credentials is not subclass of"): + class InvalidCredentialsPlugin(Plugin): + class Meta: + version = "1.0.3" + + class Credentials: # Not inheriting from CredentialModel + api_key = Credential(key="api_key") + + @patch("bk_plugin_framework.hub.load_form_module_path", MagicMock(return_value="tests")) + def test_credentials_validation_empty_key(self): + with pytest.raises(ValueError, match="key cannot be empty"): + class EmptyKeyPlugin(Plugin): + class Meta: + version = "1.0.4" + + class Credentials(CredentialModel): + api_key = Credential(key="") # Empty key + + def test_context_with_credentials(self): + class ContextInputs(ContextRequire): + a: int + + credentials = {"api_key": "test_key", "api_secret": "test_secret"} + context = Context( + trace_id="test_trace", + data=ContextInputs(a=1), + state=State.EMPTY, + invoke_count=1, + credentials=credentials, + ) + + assert context.credentials == credentials + assert context.credentials.get("api_key") == "test_key" + assert context.credentials.get("api_secret") == "test_secret" + + def test_context_without_credentials(self): + class ContextInputs(ContextRequire): + a: int + + context = Context( + trace_id="test_trace", + data=ContextInputs(a=1), + state=State.EMPTY, + invoke_count=1, + ) + + assert context.credentials == {} diff --git a/bk-plugin-framework/tests/runtime/test_executor.py b/bk-plugin-framework/tests/runtime/test_executor.py index 8c3c096..db2b703 100644 --- a/bk-plugin-framework/tests/runtime/test_executor.py +++ b/bk-plugin-framework/tests/runtime/test_executor.py @@ -20,6 +20,8 @@ ContextRequire, Context, State, + Credential, + CredentialModel, ) from bk_plugin_framework.runtime.executor import BKPluginExecutor @@ -181,7 +183,7 @@ def test_execute__waiting_poll(self, executor, plugin_cls): trace_id=executor.trace_id, state=State.POLL.value, plugin_version=plugin_cls.Meta.version, - data='{"inputs": {"success": true, "poll": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}', # noqa + data='{"inputs": {"success": true, "poll": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}', # noqa ) current_app.tasks[executor.SCHEDULE_TASK_NAME].apply_async.assert_called_once_with( kwargs={"trace_id": executor.trace_id}, @@ -200,7 +202,7 @@ def test_schedule__load_schedule_data_err(self, executor_1, plugin_cls): def test_schedule__plugin_inputs_validation_err(self, executor_1, plugin_cls): schedule = MagicMock() schedule.data = ( - '{"inputs": {}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}' # noqa + '{"inputs": {}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}' # noqa ) executor_1.schedule(plugin_cls, schedule) @@ -209,7 +211,7 @@ def test_schedule__plugin_inputs_validation_err(self, executor_1, plugin_cls): def test_schedule__plugin_context_validation_err(self, executor_1, plugin_cls): schedule = MagicMock() - schedule.data = '{"inputs": {"success": true, "poll": true}, "context": {"storage": {}, "outputs": {}, "data": {}}, "outputs": {}}' # noqa + schedule.data = '{"inputs": {"success": true, "poll": true}, "context": {"storage": {}, "outputs": {}, "data": {}, "credentials": {}}, "outputs": {}}' # noqa executor_1.schedule(plugin_cls, schedule) @@ -218,7 +220,7 @@ def test_schedule__plugin_context_validation_err(self, executor_1, plugin_cls): def test_schedule__plugin_execute_raise_expected_err(self, executor, plugin_cls): schedule = MagicMock() schedule.invoke_count = 1 - schedule.data = '{"inputs": {"success": false, "poll": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}' # noqa + schedule.data = '{"inputs": {"success": false, "poll": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}' # noqa Schedule = MagicMock() now = MagicMock(return_value="now") @@ -227,18 +229,21 @@ def test_schedule__plugin_execute_raise_expected_err(self, executor, plugin_cls) executor.schedule(plugin_cls, schedule) Schedule.objects.filter.assert_called_once_with(trace_id=schedule.trace_id) - Schedule.objects.filter(trace_id=schedule.trace_id).update.assert_called_once_with( - state=State.FAIL.value, - invoke_count=2, - data=schedule.data, - finish_at="now", - err="plugin schedule failed: fail", - ) + # The data will be updated with credentials included + update_call = Schedule.objects.filter(trace_id=schedule.trace_id).update.call_args + assert update_call is not None + assert update_call.kwargs["state"] == State.FAIL.value + assert update_call.kwargs["invoke_count"] == 2 + assert update_call.kwargs["finish_at"] == "now" + assert update_call.kwargs["err"] == "plugin schedule failed: fail" + # Verify credentials is included in the data + updated_data = json.loads(update_call.kwargs["data"]) + assert "credentials" in updated_data["context"] def test_schedule__plugin_execute_raise_unexpected_err(self, executor, plugin_cls): schedule = MagicMock() schedule.invoke_count = 1 - schedule.data = '{"inputs": {"success": true, "poll": true, "raise_unexpected_err": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}' # noqa + schedule.data = '{"inputs": {"success": true, "poll": true, "raise_unexpected_err": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}' # noqa Schedule = MagicMock() now = MagicMock(return_value="now") @@ -254,7 +259,7 @@ def test_schedule__plugin_execute_raise_unexpected_err(self, executor, plugin_cl def test_schedule__plugin_execute_waiting_poll(self, executor, plugin_cls): schedule = MagicMock() schedule.invoke_count = 1 - schedule.data = '{"inputs": {"success": true, "poll": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}' # noqa + schedule.data = '{"inputs": {"success": true, "poll": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}' # noqa Schedule = MagicMock() current_app = MagicMock() @@ -263,9 +268,13 @@ def test_schedule__plugin_execute_waiting_poll(self, executor, plugin_cls): executor.schedule(plugin_cls, schedule) Schedule.objects.filter.assert_called_once_with(trace_id=schedule.trace_id) - Schedule.objects.filter(trace_id=schedule.trace_id).update.assert_called_once_with( - state=State.POLL.value, invoke_count=2, data=schedule.data - ) + # The data will be updated with credentials included + update_call = Schedule.objects.filter(trace_id=schedule.trace_id).update.call_args + assert update_call is not None + assert update_call.kwargs["state"] == State.POLL.value + assert update_call.kwargs["invoke_count"] == 2 + updated_data = json.loads(update_call.kwargs["data"]) + assert "credentials" in updated_data["context"] current_app.tasks[executor.SCHEDULE_TASK_NAME].apply_async.assert_called_once_with( kwargs={"trace_id": executor.trace_id}, countdown=1, @@ -276,7 +285,7 @@ def test_schedule__plugin_execute_waiting_callback(self, executor, plugin_cls): schedule = MagicMock() schedule.invoke_count = 1 schedule.state = State.CALLBACK.value - schedule.data = '{"inputs": {"success": true, "poll": true, "callback": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}' # noqa + schedule.data = '{"inputs": {"success": true, "poll": true, "callback": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}' # noqa Schedule = MagicMock() current_app = MagicMock() callback_info = {"callback_id": "callback_id", "callback_data": {"result": True, "data": {}}} @@ -285,14 +294,18 @@ def test_schedule__plugin_execute_waiting_callback(self, executor, plugin_cls): executor.schedule(plugin_cls, schedule, callback_info) Schedule.objects.filter.assert_called_once_with(trace_id=schedule.trace_id) - Schedule.objects.filter(trace_id=schedule.trace_id).update.assert_called_once_with( - state=State.CALLBACK.value, invoke_count=2, data=schedule.data - ) + # The data will be updated with credentials included + update_call = Schedule.objects.filter(trace_id=schedule.trace_id).update.call_args + assert update_call is not None + assert update_call.kwargs["state"] == State.CALLBACK.value + assert update_call.kwargs["invoke_count"] == 2 + updated_data = json.loads(update_call.kwargs["data"]) + assert "credentials" in updated_data["context"] def test_schedule__plugin_execute_success(self, executor, plugin_cls): schedule = MagicMock() schedule.invoke_count = 1 - schedule.data = '{"inputs": {"success": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}' # noqa + schedule.data = '{"inputs": {"success": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}' # noqa Schedule = MagicMock() now = MagicMock(return_value="now") @@ -301,13 +314,18 @@ def test_schedule__plugin_execute_success(self, executor, plugin_cls): executor.schedule(plugin_cls, schedule) Schedule.objects.filter.assert_called_once_with(trace_id=schedule.trace_id) - Schedule.objects.filter(trace_id=schedule.trace_id).update.assert_called_once_with( - state=State.SUCCESS.value, invoke_count=2, data=schedule.data, finish_at="now" - ) + # The data will be updated with credentials included + update_call = Schedule.objects.filter(trace_id=schedule.trace_id).update.call_args + assert update_call is not None + assert update_call.kwargs["state"] == State.SUCCESS.value + assert update_call.kwargs["invoke_count"] == 2 + assert update_call.kwargs["finish_at"] == "now" + updated_data = json.loads(update_call.kwargs["data"]) + assert "credentials" in updated_data["context"] def test_schedule__plugin_execute_success_dump_data_err(self, executor_2, plugin_cls): schedule = MagicMock() - schedule.data = '{"inputs": {"success": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}' # noqa + schedule.data = '{"inputs": {"success": true}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}' # noqa executor_2.schedule(plugin_cls, schedule) @@ -323,7 +341,7 @@ def test_execute__plugin_inputs_and_context_not_define(self, executor, empty_plu def test_schedule__plugin_inputs_and_context_not_define(self, executor, empty_plugin_cls): schedule = MagicMock() schedule.invoke_count = 1 - schedule.data = '{"inputs": {}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}}, "outputs": {}}' + schedule.data = '{"inputs": {}, "context": {"storage": {}, "outputs": {}, "data": {"b": "1"}, "credentials": {}}, "outputs": {}}' Schedule = MagicMock() now = MagicMock(return_value="now") @@ -332,9 +350,121 @@ def test_schedule__plugin_inputs_and_context_not_define(self, executor, empty_pl executor.schedule(empty_plugin_cls, schedule) Schedule.objects.filter.assert_called_once_with(trace_id=schedule.trace_id) - Schedule.objects.filter(trace_id=schedule.trace_id).update.assert_called_once_with( - state=State.SUCCESS.value, - invoke_count=2, - data='{"inputs": {}, "context": {"storage": {}, "outputs": {}, "data": {}}, "outputs": {}}', - finish_at="now", + # The data will be updated with credentials included + update_call = Schedule.objects.filter(trace_id=schedule.trace_id).update.call_args + assert update_call is not None + assert update_call.kwargs["state"] == State.SUCCESS.value + assert update_call.kwargs["invoke_count"] == 2 + assert update_call.kwargs["finish_at"] == "now" + updated_data = json.loads(update_call.kwargs["data"]) + assert "credentials" in updated_data["context"] + assert updated_data["context"]["data"] == {} + + @patch("bk_plugin_framework.hub.load_form_module_path", MagicMock(return_value="tests")) + def test_execute__with_credentials(self, executor): + class PluginWithCredentials(Plugin): + class Meta: + version = "1.0.5" + + class Inputs(InputsModel): + success: bool + + class ContextInputs(ContextRequire): + b: str + + class Credentials(CredentialModel): + api_key = Credential(key="api_key", name="API Key") + + def execute(self, inputs: InputsModel, context: Context): + assert context.credentials.get("api_key") == "test_key" + if inputs.success: + return + else: + raise self.Error("fail") + + credentials = {"api_key": "test_key"} + result = executor.execute( + PluginWithCredentials, {"success": True}, {"b": "1"}, credentials=credentials + ) + + assert result.state is State.SUCCESS + assert result.outputs == {} + assert result.err is None + + @patch("bk_plugin_framework.hub.load_form_module_path", MagicMock(return_value="tests")) + def test_execute__credentials_passed_to_context(self, executor): + class PluginWithCredentials(Plugin): + class Meta: + version = "1.0.6" + + class Inputs(InputsModel): + success: bool + + class ContextInputs(ContextRequire): + b: str + + class Credentials(CredentialModel): + api_key = Credential(key="api_key") + api_secret = Credential(key="api_secret") + + def execute(self, inputs: InputsModel, context: Context): + assert "api_key" in context.credentials + assert "api_secret" in context.credentials + assert context.credentials["api_key"] == "key_value" + assert context.credentials["api_secret"] == "secret_value" + if inputs.success: + return + else: + raise self.Error("fail") + + credentials = {"api_key": "key_value", "api_secret": "secret_value"} + result = executor.execute( + PluginWithCredentials, {"success": True}, {"b": "1"}, credentials=credentials ) + + assert result.state is State.SUCCESS + + @patch("bk_plugin_framework.hub.load_form_module_path", MagicMock(return_value="tests")) + def test_schedule__credentials_persisted(self, executor): + class PluginWithCredentials(Plugin): + class Meta: + version = "1.0.7" + + class Inputs(InputsModel): + success: bool + poll: bool = False + + class ContextInputs(ContextRequire): + b: str + + class Credentials(CredentialModel): + api_key = Credential(key="api_key") + + def execute(self, inputs: InputsModel, context: Context): + assert context.credentials.get("api_key") == "persisted_key" + if inputs.success: + if inputs.poll: + self.wait_poll(1) + return + else: + raise self.Error("fail") + + credentials = {"api_key": "persisted_key"} + schedule_obj = MagicMock() + Schedule = MagicMock() + Schedule.objects.create = MagicMock(return_value=schedule_obj) + current_app = MagicMock() + + with patch("bk_plugin_framework.runtime.executor.Schedule", Schedule): + with patch("bk_plugin_framework.runtime.executor.current_app", current_app): + result = executor.execute( + PluginWithCredentials, {"success": True, "poll": True}, {"b": "1"}, credentials=credentials + ) + + assert result.state is State.POLL + # Verify credentials are included in schedule data + create_call_args = Schedule.objects.create.call_args + assert create_call_args is not None + schedule_data = json.loads(create_call_args.kwargs["data"]) + assert "credentials" in schedule_data["context"] + assert schedule_data["context"]["credentials"]["api_key"] == "persisted_key" diff --git a/docs/require_user_login_example.md b/docs/require_user_login_example.md new file mode 100644 index 0000000..011e3b8 --- /dev/null +++ b/docs/require_user_login_example.md @@ -0,0 +1,264 @@ +# 插件凭证依赖声明 + +## 功能说明 + +插件框架支持插件声明依赖凭证。当插件声明需要凭证时,调用插件的平台需要在请求的顶层提供 `credentials` 字典,框架会在插件执行前检查请求中是否包含 `credentials` 字典,以及字典中是否包含所需的凭证字段,如果缺少则返回 400 错误。框架会将 `credentials` 作为 `Context` 对象的 `credentials` 属性传递给插件执行。 + +## 使用方式 + +### 在插件中声明依赖凭证 + +在插件类中定义 `Credentials` 类(继承自 `CredentialModel`,与 `ContextInputs` 并行)即可声明该插件需要凭证: + +```python +from bk_plugin_framework.kit import ( + Plugin, + InputsModel, + OutputsModel, + Field, + ContextRequire, + Context, + Credential, + CredentialModel, +) + +class MyPlugin(Plugin): + class Meta: + version = "1.0.0" + desc = "这是一个需要凭证的插件示例" + + class Inputs(InputsModel): + action: str = Field(title="操作", description="要执行的操作") + + class Outputs(OutputsModel): + result: str = Field(title="执行结果", description="操作执行的结果") + + class ContextInputs(ContextRequire): + executor: str = Field(title="任务执行人") + + class Credentials(CredentialModel): + bk_access_token = Credential( + key="bk_access_token", name="蓝鲸 access token", description="用于调用蓝鲸 API 的 access token" + ) + + def execute(self, inputs: Inputs, context: Context): + # 插件执行逻辑 + # 由于声明了 Credentials,框架会确保在执行到这里时 context.credentials 已经存在 + # 可以通过 credential key 访问具体的凭证值 + access_token = context.credentials.get("bk_access_token") + # 使用 access_token 调用蓝鲸 API... + context.outputs["result"] = f"操作 {inputs.action} 执行成功" +``` + +### 声明多个凭证 + +插件可以声明需要多个凭证: + +```python +class MyPlugin(Plugin): + class Meta: + version = "1.0.0" + desc = "这是一个需要多个凭证的插件示例" + + class ContextInputs(ContextRequire): + executor: str = Field(title="任务执行人") + + class Credentials(CredentialModel): + api_key = Credential(key="api_key", name="API 密钥", description="第三方服务的 API Key") + api_secret = Credential(key="api_secret", name="API 密钥", description="第三方服务的 API Secret") + + def execute(self, inputs: Inputs, context: Context): + api_key = context.credentials.get("api_key") + api_secret = context.credentials.get("api_secret") + # 使用 api_key 和 api_secret... +``` + +### 不声明凭证依赖(默认行为) + +如果插件不需要凭证,可以不定义 `Credentials` 类: + +```python +class MyPlugin(Plugin): + class Meta: + version = "1.0.0" + desc = "这是一个不需要凭证的插件示例" + + # Credentials 类可以不定义,默认为不需要凭证 + + # ... 其他代码 +``` + +## 工作原理 + +1. **插件注册时**:框架会验证 `Credentials` 类是否继承自 `CredentialModel` + - `Credentials` 是插件类的内部类,与 `ContextInputs` 并行 + - `Credentials` 类中的每个类属性必须是 `Credential` 类的实例 + - 每个 `Credential` 必须包含 `key` 字段(不能为空) + - `name` 和 `description` 为可选字段 +2. **插件调用时**:如果插件声明了 `Credentials` 类且包含凭证定义,框架会在执行插件前检查: + - 验证调用方是否在请求顶层提供了 `credentials` 字典 + - 验证 `credentials` 字典中是否包含所有 `Credentials` 类中声明的 `key` 字段 + - 如果缺少 `credentials` 或缺少任何必需的 key,框架会返回 400 错误 + - 框架会将 `credentials` 作为 `Context` 对象的 `credentials` 属性传递给插件执行 +3. **凭证访问**:插件可以通过 `context.credentials` 访问凭证字典,无需在 `ContextInputs` 中定义 `credentials` 字段 + +## CredentialModel 和 Credential 类说明 + +### CredentialModel + +`CredentialModel` 是凭证模型的基类,用于声明插件需要的凭证。插件需要定义一个继承自 `CredentialModel` 的 `Credentials` 类。 + +### Credential + +`Credential` 类用于定义单个凭证,包含以下字段: + +- **key**(必填):凭证在 `credentials` 字典中的 key +- **name**(可选):凭证的显示名称,用于错误提示,如果不设置则使用 `key` +- **description**(可选):凭证的描述信息 + +在 `Credentials` 类中,每个凭证作为类属性,值是 `Credential` 实例: + +```python +class Credentials(CredentialModel): + bk_access_token = Credential( + key="bk_access_token", # 必填:凭证的 key + name="蓝鲸 access token", # 可选:显示名称 + description="用于调用蓝鲸 API 的 access token" # 可选:描述信息 + ) +``` + +## 插件元数据 + +插件元数据接口会返回 `credentials` 列表,调用方可以根据该列表判断插件需要哪些凭证: + +```json +{ + "version": "1.0.0", + "desc": "这是一个需要凭证的插件示例", + "credentials": [ + { + "key": "bk_access_token", + "name": "蓝鲸 access token", + "description": "用于调用蓝鲸 API 的 access token" + } + ], + "inputs": {...}, + "outputs": {...}, + ... +} +``` + +## 调用方式 + +对于声明了 `credentials` 的插件,调用方需要在调用时在顶层提供 `credentials` 字典,且字典中必须包含插件声明的所有 `key`: + +```json +{ + "inputs": { + "action": "some_action" + }, + "context": { + "executor": "admin" + }, + "credentials": { + "bk_access_token": "your_access_token_here" + } +} +``` + +### 多个凭证的调用示例 + +```json +{ + "inputs": { + "action": "some_action" + }, + "context": { + "executor": "admin" + }, + "credentials": { + "api_key": "your_api_key_here", + "api_secret": "your_api_secret_here" + } +} +``` + +## 凭证类型示例 + +### 示例 1:蓝鲸 Access Token + +```python +class MyPlugin(Plugin): + class Meta: + version = "1.0.0" + + class ContextInputs(ContextRequire): + executor: str = Field(title="任务执行人") + + class Credentials(CredentialModel): + bk_access_token = Credential(key="bk_access_token", name="蓝鲸 access token") + + def execute(self, inputs: Inputs, context: Context): + access_token = context.credentials.get("bk_access_token") + # 使用 access_token... +``` + +调用时: +```json +{ + "context": { + "executor": "admin" + }, + "credentials": { + "bk_access_token": "token_value" + } +} +``` + +### 示例 2:API Key 和 Secret + +```python +class MyPlugin(Plugin): + class Meta: + version = "1.0.0" + + class ContextInputs(ContextRequire): + executor: str = Field(title="任务执行人") + + class Credentials(CredentialModel): + api_key = Credential(key="api_key", name="API 密钥") + api_secret = Credential(key="api_secret", name="API 密钥") + + def execute(self, inputs: Inputs, context: Context): + api_key = context.credentials.get("api_key") + api_secret = context.credentials.get("api_secret") + # 使用 api_key 和 api_secret... +``` + +调用时: +```json +{ + "context": { + "executor": "admin" + }, + "credentials": { + "api_key": "key_value", + "api_secret": "secret_value" + } +} +``` + +## 注意事项 + +1. `Credentials` 是插件类的内部类,与 `ContextInputs`、`Inputs`、`Outputs` 等并行 +2. `Credentials` 类可以不定义,即不声明时插件不需要凭证 +3. `Credentials` 类必须继承自 `CredentialModel` +4. 在 `Credentials` 类中,每个凭证作为类属性,值必须是 `Credential` 类的实例 +5. 对于声明了 `Credentials` 的插件: + - 每个 `Credential` 的 `key` 字段是必填的 + - `name` 和 `description` 是可选的 + - **不需要**在 `ContextInputs` 中定义 `credentials` 字段,凭证通过 `context.credentials` 访问 +6. 调用方需要确保在调用插件时,在顶层 `credentials` 字典中提供所有 `Credentials` 类中声明的 `key` +7. `credentials` 是一个字典结构,可以包含多个凭证字段,但至少必须包含插件声明的所有 `key` +8. 如果缺少 `credentials` 或缺少任何必需的 `key`,框架会在插件执行前返回 400 错误,错误信息会列出所有缺少的凭证 +9. 插件通过 `context.credentials` 访问凭证字典,例如:`context.credentials.get("bk_access_token")` diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/__version__.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/__version__.py index 939f4ad..a72339d 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/__version__.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/__version__.py @@ -10,4 +10,4 @@ specific language governing permissions and limitations under the License. """ -__version__ = "2.1.1" +__version__ = "2.2.0rc0" 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..0a8d90b 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/__init__.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/__init__.py @@ -30,9 +30,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 ed03fe5..2ed0700 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/default.py @@ -77,9 +77,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 +130,8 @@ LANGUAGE_CODE = "zh-hans" LANGUAGES = ( - ("en", u"English"), - ("zh-hans", u"简体中文"), + ("en", "English"), + ("zh-hans", "简体中文"), ) """ 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..658a88a 100644 --- a/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py +++ b/runtime/bk-plugin-runtime/bk_plugin_runtime/config/dev.py @@ -37,10 +37,7 @@ # 本地开发数据库默认使用sqlite3 DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": APP_CODE # noqa - }, + "default": {"ENGINE": "django.db.backends.sqlite3", "NAME": APP_CODE}, # noqa } # 本地开发是否使用mysql数据库 BK_PLUGIN_DEV_USE_MYSQL = os.getenv("BK_PLUGIN_DEV_USE_MYSQL") diff --git a/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/__init__.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/__init__.py index c2aedd9..0fda879 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,2 @@ # -*- coding: utf-8 -*- -__author__ = u"蓝鲸智云" +__author__ = "蓝鲸智云" 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..0c484e7 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 @@ -9,27 +9,32 @@ 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..c5047cb 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 @@ -9,7 +9,8 @@ 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..a87bbf8 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 @@ -9,637 +9,740 @@ 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..5fcc19e 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 @@ -9,42 +9,44 @@ 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..fdf47e7 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 @@ -9,27 +9,32 @@ 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..5b94936 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 @@ -9,52 +9,62 @@ 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..8f0ef4f 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 @@ -9,132 +9,158 @@ 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..41e7f84 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 @@ -9,122 +9,146 @@ 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..7772c21 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 @@ -9,372 +9,446 @@ 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..e4509ed 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 @@ -9,162 +9,194 @@ 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..5b02795 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 @@ -9,37 +9,44 @@ 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..d66d022 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 @@ -72,7 +72,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 +84,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..6db320b 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 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..f7e8f66 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 @@ -15,15 +15,15 @@ # 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/conf.py b/runtime/bk-plugin-runtime/bk_plugin_runtime/packages/open/blueking/component/conf.py index 84a9f80..0e948cf 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,6 +1,5 @@ # -*- coding: utf-8 -*- -"""Django project settings -""" +"""Django project settings""" try: 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..fa916b5 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 @@ -17,40 +17,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 +62,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..70f70d6 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 @@ -15,23 +15,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..7bd2b5a 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 @@ -8,20 +8,20 @@ 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..af21fe5 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 @@ -11,14 +11,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/pyproject.toml b/runtime/bk-plugin-runtime/pyproject.toml index 1cde935..d15267f 100644 --- a/runtime/bk-plugin-runtime/pyproject.toml +++ b/runtime/bk-plugin-runtime/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bk-plugin-runtime" -version = "2.1.1" +version = "2.2.0rc0" description = "bk plugin python django runtime" authors = ["Your Name "] license = "MIT" 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..02983b3 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 @@ -7,6 +7,8 @@ Field, ContextRequire, Context, + Credential, + CredentialModel, ) logger = logging.getLogger("bk_plugin") @@ -26,5 +28,11 @@ class Outputs(OutputsModel): class ContextInputs(ContextRequire): executor: str = Field(title="任务执行人") + # 如果需要凭证,取消注释以下类(与 ContextInputs 并行) + # class Credentials(CredentialModel): + # bk_access_token = Credential(key="bk_access_token", name="蓝鲸 access token", description="用于调用蓝鲸 API 的 access token") + def execute(self, inputs: Inputs, context: Context): + # 如果声明了 Credentials,可以通过 context.credentials 访问凭证 + # credential_value = context.credentials.get("bk_access_token") context.outputs["world"] = inputs.hello