bkflow-sdk 0.0.42__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of bkflow-sdk might be problematic. Click here for more details.

bkflow/common/views.py ADDED
@@ -0,0 +1,50 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
11
+ import urllib
12
+
13
+ from django.conf import settings
14
+ from rest_framework import status
15
+ from rest_framework.renderers import JSONRenderer
16
+ from rest_framework.response import Response
17
+ from rest_framework.viewsets import GenericViewSet
18
+
19
+ from bkflow.config.default import BK_TOKEN_EXPIRED_CODE
20
+
21
+
22
+ class SimpleGenericViewSet(GenericViewSet):
23
+ """
24
+ 最基础的视图函数,不支持model, view_set 的 创建,查看,更新,删除方法,只支持用户自定义的action
25
+ """
26
+
27
+ renderer_classes = [JSONRenderer]
28
+ EXEMPT_STATUS_CODES = {status.HTTP_204_NO_CONTENT}
29
+ RESPONSE_WRAPPER = None
30
+
31
+ def default_response_wrapper(self, data):
32
+ return {"result": True, "data": data, "code": "0", "message": ""}
33
+
34
+ def finalize_response(self, request, response, *args, **kwargs):
35
+
36
+ if isinstance(response, Response):
37
+ res_data = {
38
+ "result": response.data.get("result"),
39
+ "code": response.data.get("code"),
40
+ "data": response.data.get("data"),
41
+ "message": response.data.get("message"),
42
+ }
43
+ if response.data.get("count"):
44
+ res_data["count"] = response.data.get("count")
45
+ response.data = res_data
46
+ if str(response.data.get("code")) == BK_TOKEN_EXPIRED_CODE:
47
+ response.status_code = 401
48
+ curl = urllib.parse.quote(request.build_absolute_uri())
49
+ res_data["data"] = {"login_url": f"{getattr(settings, 'BKPAAS_LOGIN_URL','')}?curl={curl}"}
50
+ return super(SimpleGenericViewSet, self).finalize_response(request, response, *args, **kwargs)
@@ -0,0 +1,10 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
@@ -0,0 +1,93 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
11
+ from django.conf import settings
12
+
13
+ BKFLOW_SDK_APIGW_HOST = getattr(settings, "BKFLOW_SDK_APIGW_HOST", "")
14
+ DEFAULT_SETTINGS = {
15
+ "BKFLOW_SDK_APIGW_HOST": BKFLOW_SDK_APIGW_HOST,
16
+ "BKFLOW_SDK_DEFAULT_SPACE_ID": "",
17
+ "BKFLOW_SDK_SPACE_TRANSFORMER": "", # 可执行函数路径,格式:module.path.function_name 或 module.path.ClassName.method_name
18
+ "BKFLOW_SDK_APIGW_HEADERS_GENERATOR": "", # 可执行函数路径,格式:module.path.function_name 或 module.path.ClassName.method_name # noqa: E501
19
+ "common_key1": "common_value2",
20
+ "interface": {"interface_key1": "interface_value1"},
21
+ }
22
+ REQUEST_TOKEN_HEADER_KEY = "HTTP_BKFLOW_TOKEN"
23
+ API_TOKEN_HEADER_KEY = "BKFLOW-TOKEN"
24
+ BK_TOKEN_EXPIRED_CODE = "1640001"
25
+
26
+
27
+ class BkflowSDKSettings:
28
+ SETTING_PREFIX = "BKFLOW_SDK"
29
+ NESTING_SEPARATOR = "_"
30
+
31
+ def __init__(self, default_settings=None):
32
+ # 从 settings.BKFLOW_SDK 字典中读取配置(向后兼容)
33
+ dict_settings = self.get_flatten_settings(getattr(settings, self.SETTING_PREFIX, {}))
34
+ # 从 Django settings 中收集所有以 BKFLOW_SDK 前缀开头的配置项
35
+ prefix_settings = self._collect_prefix_settings()
36
+ # 合并配置,字典中的配置优先级更高
37
+ self.project_settings = {**prefix_settings, **dict_settings}
38
+ self.default_settings = self.get_flatten_settings(default_settings or DEFAULT_SETTINGS)
39
+
40
+ def _collect_prefix_settings(self):
41
+ """
42
+ 收集 Django settings 中所有以 BKFLOW_SDK 前缀开头的配置项
43
+ """
44
+ prefix_settings = {}
45
+ prefix = self.SETTING_PREFIX
46
+
47
+ # 遍历 Django settings 的所有属性
48
+ for attr_name in dir(settings):
49
+ # 跳过私有属性和不以 BKFLOW_SDK 开头的属性
50
+ if attr_name.startswith("_") or not attr_name.startswith(prefix):
51
+ continue
52
+
53
+ try:
54
+ value = getattr(settings, attr_name)
55
+ # 只收集非字典类型和非可调用对象的配置
56
+ # 字典类型已经在 settings.BKFLOW_SDK 中处理
57
+ if not isinstance(value, dict) and not callable(value):
58
+ prefix_settings[attr_name] = value
59
+ except (AttributeError, TypeError):
60
+ # 某些属性可能无法访问或类型不匹配,跳过
61
+ continue
62
+
63
+ return prefix_settings
64
+
65
+ def __getattr__(self, key):
66
+ if key not in self.project_settings and key not in self.default_settings:
67
+ raise AttributeError
68
+
69
+ value = self.project_settings.get(key) or self.default_settings.get(key)
70
+ if value is not None:
71
+ setattr(self, key, value)
72
+ return value
73
+
74
+ def get_flatten_settings(self, inputted_settings: dict, cur_prefix: str = ""):
75
+ def get_cur_key(cur_key):
76
+ return f"{cur_prefix}{self.NESTING_SEPARATOR}{cur_key}" if cur_prefix else cur_key
77
+
78
+ flatten_settings = {}
79
+ for key, value in inputted_settings.items():
80
+ if isinstance(value, dict):
81
+ flatten_sub_settings = self.get_flatten_settings(value, key)
82
+ flatten_settings.update(
83
+ {
84
+ get_cur_key(flatten_key): flatten_value
85
+ for flatten_key, flatten_value in flatten_sub_settings.items()
86
+ }
87
+ )
88
+ else:
89
+ flatten_settings[get_cur_key(key)] = value
90
+ return flatten_settings
91
+
92
+
93
+ bkflow_sdk_settings = BkflowSDKSettings(DEFAULT_SETTINGS)
@@ -0,0 +1,10 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
@@ -0,0 +1,18 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
11
+ from django.apps import AppConfig
12
+
13
+
14
+ class BkflowInterfaceConfig(AppConfig):
15
+ name = "bkflow.interface"
16
+
17
+ def ready(self):
18
+ pass
@@ -0,0 +1,263 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
11
+
12
+ from django.utils.translation import gettext_lazy as _
13
+ from rest_framework import serializers
14
+
15
+
16
+ class ScopeSerializer(serializers.Serializer):
17
+ """流程范围序列化器,用于指定流程的作用域"""
18
+
19
+ scope_type = serializers.CharField(
20
+ help_text=_("流程范围类型,如 project/organization/global 等"),
21
+ max_length=128,
22
+ required=False,
23
+ allow_null=True,
24
+ allow_blank=True,
25
+ )
26
+ scope_value = serializers.CharField(
27
+ help_text=_("流程范围值,与 scope_type 配合使用,指定具体的范围 ID"),
28
+ max_length=128,
29
+ required=False,
30
+ allow_null=True,
31
+ allow_blank=True,
32
+ )
33
+
34
+
35
+ class TemplateSerializer(ScopeSerializer):
36
+ """流程模板序列化器,用于定义流程模板的基本信息"""
37
+
38
+ name = serializers.CharField(help_text=_("流程模板名称,唯一标识流程"), max_length=128, required=True)
39
+ notify_config = serializers.JSONField(help_text=_("通知配置,JSON格式,包含通知方式、通知人等信息"), required=False)
40
+ desc = serializers.CharField(
41
+ help_text=_("流程描述,说明流程的用途和功能"), max_length=256, required=False, allow_blank=True, allow_null=True
42
+ )
43
+ source = serializers.CharField(
44
+ help_text=_("流程来源,标识流程的创建方式或来源系统"), max_length=32, required=False, allow_null=True, allow_blank=True
45
+ )
46
+ version = serializers.CharField(
47
+ help_text=_("流程版本号,用于版本管理"), max_length=32, required=False, allow_blank=True, allow_null=True
48
+ )
49
+ extra_info = serializers.JSONField(help_text=_("额外扩展信息,JSON格式,用于存储自定义字段"), required=False)
50
+
51
+ def validate(self, attrs):
52
+ if "desc" in attrs and (attrs["desc"] is None or attrs["desc"] == ""):
53
+ del attrs["desc"]
54
+ return attrs
55
+
56
+
57
+ class CreateTemplateSerializer(TemplateSerializer):
58
+ """创建流程模板序列化器"""
59
+
60
+ source_template_id = serializers.IntegerField(help_text=_("源模板ID,从已有模板复制时使用"), required=False, allow_null=True)
61
+ pipeline_tree = serializers.JSONField(help_text=_("流程树,JSON格式,包含流程节点、连线等完整信息"), required=False)
62
+ operator = serializers.CharField(help_text=_("操作人,记录创建或更新流程的用户"), max_length=32, required=False, allow_blank=True)
63
+ triggers = serializers.ListField(required=False, help_text=_("触发器配置列表,用于设置流程的自动触发条件"), allow_empty=True)
64
+
65
+
66
+ class CreateTaskSerializer(ScopeSerializer):
67
+ """创建流程任务序列化器"""
68
+
69
+ template_id = serializers.IntegerField(help_text=_("流程模板ID,指定要实例化的流程模板"), required=True)
70
+ name = serializers.CharField(help_text=_("任务名称,用于标识任务实例"), max_length=128, required=False, allow_blank=True)
71
+ creator = serializers.CharField(help_text=_("任务创建者,记录创建任务的用户"), max_length=32, required=True)
72
+ description = serializers.CharField(help_text=_("任务描述,说明任务的目的和背景"), required=True, allow_blank=True)
73
+ constants = serializers.JSONField(help_text=_("任务启动参数,JSON格式,包含流程执行所需的变量值"), required=False, default=dict)
74
+
75
+
76
+ class UpdateTemplateSerializer(TemplateSerializer):
77
+ """更新流程模板序列化器"""
78
+
79
+ operator = serializers.CharField(help_text=_("操作人,记录更新流程的用户"), max_length=32, required=False, allow_blank=True)
80
+ pipeline_tree = serializers.JSONField(help_text=_("流程树信息,包含更新后的完整流程结构"), required=True)
81
+ triggers = serializers.ListField(required=True, help_text=_("触发器配置列表,更新流程的触发条件"), allow_empty=True)
82
+
83
+
84
+ class CopyTemplateSerializer(ScopeSerializer):
85
+ """复制流程模板序列化器"""
86
+
87
+ name = serializers.CharField(help_text=_("新模板名称,用于标识复制后的流程"), max_length=128, required=False, allow_blank=True)
88
+ desc = serializers.CharField(help_text=_("新模板描述,说明新模板的目的和背景"), required=False, allow_blank=True)
89
+
90
+
91
+ class GetServicePluginSerializer(ScopeSerializer):
92
+ """获取第三方插件元数据序列化器"""
93
+
94
+ plugin_code = serializers.CharField(required=True, help_text=_("插件编码,唯一标识第三方插件"))
95
+
96
+
97
+ class InnerPluginDetailSerializer(ScopeSerializer):
98
+ """获取内置插件详情序列化器"""
99
+
100
+ version = serializers.CharField(required=False, help_text=_("插件版本号,不指定则返回最新版本"), allow_blank=True)
101
+
102
+
103
+ class DecisionTableSerializer(ScopeSerializer):
104
+ """获取用户决策表插件列表序列化器"""
105
+
106
+ limit = serializers.IntegerField(
107
+ required=False, help_text=_("分页大小,每页返回的数据量"), default=20, min_value=1, max_value=200
108
+ )
109
+ offset = serializers.IntegerField(required=False, help_text=_("分页偏移量,用于翻页"), default=0, min_value=0)
110
+ template_id = serializers.IntegerField(required=True, help_text=_("流程模板ID,查询指定流程下的决策表"))
111
+
112
+
113
+ class UniFormAPiSerializer(ScopeSerializer):
114
+ """获取统一 API 插件列表序列化器"""
115
+
116
+ template_id = serializers.IntegerField(required=True, help_text=_("流程模板ID,查询指定流程下的统一API插件"))
117
+
118
+
119
+ class ServicePluginDetailSerializer(ScopeSerializer):
120
+ """获取第三方插件配置详情序列化器"""
121
+
122
+ plugin_code = serializers.CharField(required=False, help_text=_("插件编码,唯一标识插件"), allow_blank=True)
123
+ plugin_version = serializers.CharField(required=False, help_text=_("插件版本号,不指定则返回最新版本"), allow_blank=True)
124
+
125
+
126
+ class AnalysisConstantsRefSerializer(ScopeSerializer):
127
+ """变量引用统计分析序列化器"""
128
+
129
+ activities = serializers.JSONField(required=True, help_text=_("活动节点信息,JSON格式,包含流程中的所有活动节点"))
130
+ constants = serializers.JSONField(required=True, help_text=_("常量信息,JSON格式,包含流程中定义的所有变量"))
131
+ gateways = serializers.JSONField(required=True, help_text=_("网关信息,JSON格式,包含流程中的所有分支网关"))
132
+
133
+
134
+ class TemplateDetailQuerySerializer(ScopeSerializer):
135
+ """流程模板详情查询序列化器"""
136
+
137
+ with_mock_data = serializers.BooleanField(help_text=_("是否包含 Mock 数据,用于调试和测试"), required=False, default=False)
138
+
139
+
140
+ class TemplateListSerializer(ScopeSerializer):
141
+ """流程模板列表查询序列化器"""
142
+
143
+ limit = serializers.IntegerField(required=False, help_text=_("每页数量,最大200条"), default=20, min_value=1, max_value=200)
144
+ offset = serializers.IntegerField(required=False, help_text=_("分页偏移量,用于翻页查询"), default=0, min_value=0)
145
+ name = serializers.CharField(required=False, help_text=_("流程名称,支持模糊匹配"), allow_blank=True)
146
+ creator = serializers.CharField(required=False, help_text=_("创建者用户名,精确匹配"), allow_blank=True)
147
+ updated_by = serializers.CharField(required=False, help_text=_("最后更新人用户名,精确匹配"), allow_blank=True)
148
+ create_at_start = serializers.CharField(
149
+ required=False, help_text=_("创建起始时间,格式: YYYY-MM-DD HH:MM:SS,如 2023-08-25 07:49:45"), allow_blank=True
150
+ )
151
+ create_at_end = serializers.CharField(
152
+ required=False, help_text=_("创建结束时间,格式: YYYY-MM-DD HH:MM:SS,如 2023-08-25 07:49:46"), allow_blank=True
153
+ )
154
+ order_by = serializers.CharField(required=False, help_text=_("排序字段,默认按创建时间排序,如: -created 表示倒序"), allow_blank=True)
155
+
156
+
157
+ class TaskSerializer(ScopeSerializer):
158
+ """流程任务序列化器"""
159
+
160
+ task_id = serializers.IntegerField(help_text=_("任务实例ID,唯一标识一个流程任务"), required=True)
161
+
162
+
163
+ class OperateTaskSerializer(TaskSerializer):
164
+ """执行任务操作序列化器"""
165
+
166
+ action = serializers.CharField(
167
+ help_text=_("操作类型: start(启动), pause(暂停), resume(继续), revoke(撤销), retry(重试)等"), default="start", required=False
168
+ )
169
+
170
+
171
+ class BatchTaskStatesSerializer(ScopeSerializer):
172
+ """批量查询任务状态序列化器"""
173
+
174
+ task_ids = serializers.ListField(
175
+ help_text=_("任务ID列表,批量查询多个任务的状态"),
176
+ required=True,
177
+ child=serializers.IntegerField(required=True, help_text=_("任务实例ID")),
178
+ )
179
+
180
+
181
+ class CheckVariableKeySerializer(ScopeSerializer):
182
+ """检查变量 Key 合法性序列化器"""
183
+
184
+ key = serializers.CharField(help_text=_("变量 Key,检查命名是否符合规范(字母开头,支持字母数字下划线)"), required=True)
185
+
186
+
187
+ class GetConstantPreviewResultSerializer(ScopeSerializer):
188
+ """获取常量预览结果序列化器"""
189
+
190
+ constants = serializers.JSONField(help_text=_("常量信息,JSON格式,包含需要预览的变量定义"), required=False, default=dict)
191
+ extra_data = serializers.JSONField(help_text=_("预览上下文数据,JSON格式,提供额外的执行环境信息"), required=False, default=dict)
192
+
193
+
194
+ class TaskListSerializer(TemplateListSerializer):
195
+ """流程任务列表查询序列化器"""
196
+
197
+ id = serializers.IntegerField(help_text=_("任务实例ID,唯一标识一个流程任务"), required=False)
198
+ executor = serializers.CharField(help_text=_("执行者用户名,精确匹配"), required=False)
199
+ template_id = serializers.IntegerField(help_text=_("流程模板ID,查询指定流程下的任务"), required=False)
200
+
201
+
202
+ class DeleteTemplateSerializer(ScopeSerializer):
203
+ """删除流程模板序列化器"""
204
+
205
+ pass
206
+
207
+
208
+ class GetDraftTemplateSerializer(ScopeSerializer):
209
+ """获取草稿流程模板序列化器"""
210
+
211
+ pass
212
+
213
+
214
+ class CalculateVersionSerializer(ScopeSerializer):
215
+ """计算版本序列化器"""
216
+
217
+ pass
218
+
219
+
220
+ class TemplateReleaseSerializer(ScopeSerializer):
221
+ """模板发布序列化器"""
222
+
223
+ version = serializers.CharField(help_text=_("版本号"), required=True)
224
+ desc = serializers.CharField(help_text=_("描述"), required=False, allow_blank=True)
225
+
226
+
227
+ class TemplateRollbackSerializer(ScopeSerializer):
228
+ """模板回滚序列化器"""
229
+
230
+ version = serializers.CharField(help_text=_("版本号"), required=True)
231
+
232
+
233
+ class SnapshotSerializer(ScopeSerializer):
234
+ """快照序列化器"""
235
+
236
+ template_id = serializers.IntegerField(help_text=_("模板ID"), required=True)
237
+
238
+
239
+ class PreviewTaskTreeSerializer(ScopeSerializer):
240
+ """预览任务树序列化器"""
241
+
242
+ appoint_node_ids = serializers.ListSerializer(
243
+ child=serializers.CharField(help_text=_("节点ID")), help_text=_("包含的节点ID列表"), default=[]
244
+ )
245
+ is_all_nodes = serializers.BooleanField(required=False, default=False, help_text=_("preview是否需要过滤节点"))
246
+ version = serializers.CharField(help_text=_("版本号"), required=False)
247
+ is_draft = serializers.BooleanField(help_text=_("是否为草稿"), required=False, default=False)
248
+
249
+
250
+ class BKPluginSerializer(ScopeSerializer):
251
+ """BKPlugin序列化器"""
252
+
253
+ code = serializers.CharField(help_text=_("插件编码"), required=False)
254
+ name = serializers.CharField(help_text=_("插件名称"), required=False)
255
+ tag = serializers.IntegerField(help_text=_("插件分类id"), required=False)
256
+ manager = serializers.CharField(help_text=_("管理员"), required=False)
257
+ search_term = serializers.CharField(help_text=_("搜索关键字"), required=False, allow_blank=True)
258
+ limit = serializers.IntegerField(required=False, help_text=_("每页数量,最大200条"), default=20, min_value=1, max_value=200)
259
+ offset = serializers.IntegerField(required=False, help_text=_("分页偏移量,用于翻页查询"), default=0, min_value=0)
260
+
261
+
262
+ class PluginCodeQuerySerializer(ScopeSerializer):
263
+ plugin_code = serializers.CharField(help_text="插件服务编码")
@@ -0,0 +1,25 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
11
+ from django.dispatch import Signal
12
+
13
+ request_signal = Signal()
14
+
15
+ pre_request_signal = Signal()
16
+ post_request_signal = Signal()
17
+
18
+ pre_template_signal = Signal()
19
+ post_template_signal = Signal()
20
+
21
+ pre_task_signal = Signal()
22
+ post_task_signal = Signal()
23
+
24
+ pre_mock_task_signal = Signal()
25
+ post_mock_task_signal = Signal()
@@ -0,0 +1,35 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
11
+
12
+ from django.urls import include, path
13
+ from rest_framework import routers
14
+
15
+ from bkflow.interface.views import (
16
+ DecisionTableViewSet,
17
+ InnerPluginViewSet,
18
+ PluginServiceViewSet,
19
+ SystemVariableViewSet,
20
+ TemplateViewSet,
21
+ UniformApiViewSet,
22
+ )
23
+
24
+ router = routers.DefaultRouter(trailing_slash=True)
25
+
26
+ router.register(r"decision_table", DecisionTableViewSet, basename="decision_table")
27
+ router.register(r"inner_plugin", InnerPluginViewSet, basename="inner_plugin")
28
+ router.register(r"template", TemplateViewSet, basename="template")
29
+ router.register(r"plugin", PluginServiceViewSet, basename="plugin")
30
+ router.register(r"variable", SystemVariableViewSet, basename="variable")
31
+ router.register(r"uniform", UniformApiViewSet, basename="uniform")
32
+
33
+ urlpatterns = [
34
+ path("", include(router.urls)),
35
+ ]
@@ -0,0 +1,46 @@
1
+ """
2
+ Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
3
+ Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
4
+ Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://opensource.org/licenses/MIT
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9
+ specific language governing permissions and limitations under the License.
10
+ """
11
+ from bkflow.common.loader import call_config_function
12
+ from bkflow.config.default import bkflow_sdk_settings
13
+
14
+
15
+ def get_space_id(scope_type=None, scope_value=None):
16
+ """
17
+ 获取 space_id
18
+
19
+ 优先级:
20
+ 1. 如果配置了 BKFLOW_SDK_SPACE_TRANSFORMER,则调用该函数获取
21
+ 2. 否则使用 bkflow_sdk_settings.BKFLOW_SDK_DEFAULT_SPACE_ID
22
+
23
+ :param scope_type: 流程范围类型,如 project/organization/global 等
24
+ :param scope_value: 流程范围值,与 scope_type 配合使用
25
+ :return: space_id
26
+ """
27
+ transformer_path = getattr(bkflow_sdk_settings, "BKFLOW_SDK_SPACE_TRANSFORMER", None)
28
+
29
+ # 尝试通过 transformer 函数获取 space_id
30
+ if transformer_path:
31
+ space_id = call_config_function(
32
+ transformer_path,
33
+ "BKFLOW_SDK_SPACE_TRANSFORMER",
34
+ error_message_prefix="调用 BKFLOW_SDK_SPACE_TRANSFORMER",
35
+ scope_type=scope_type,
36
+ scope_value=scope_value,
37
+ )
38
+ if space_id is not None:
39
+ return space_id
40
+
41
+ # 使用默认值
42
+ default_space_id = getattr(bkflow_sdk_settings, "BKFLOW_SDK_DEFAULT_SPACE_ID", None)
43
+ if default_space_id is not None and default_space_id != "":
44
+ return default_space_id
45
+
46
+ raise ValueError("未配置 BKFLOW_SDK_DEFAULT_SPACE_ID 或 BKFLOW_SDK_SPACE_TRANSFORMER,无法获取 space_id")