bkflow-sdk 0.0.28__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.
- bkflow/__init__.py +11 -0
- bkflow/client/__init__.py +10 -0
- bkflow/client/apis/__init__.py +10 -0
- bkflow/client/apis/bkflow.py +342 -0
- bkflow/client/base.py +104 -0
- bkflow/client/core.py +253 -0
- bkflow/common/__init__.py +10 -0
- bkflow/common/decorators.py +107 -0
- bkflow/common/exceptions.py +46 -0
- bkflow/common/validator.py +96 -0
- bkflow/common/views.py +50 -0
- bkflow/config/__init__.py +10 -0
- bkflow/config/default.py +61 -0
- bkflow/interface/__init__.py +10 -0
- bkflow/interface/apps.py +18 -0
- bkflow/interface/serializers.py +270 -0
- bkflow/interface/signals.py +25 -0
- bkflow/interface/urls.py +35 -0
- bkflow/interface/views.py +748 -0
- bkflow_sdk-0.0.28.dist-info/METADATA +248 -0
- bkflow_sdk-0.0.28.dist-info/RECORD +23 -0
- bkflow_sdk-0.0.28.dist-info/WHEEL +5 -0
- bkflow_sdk-0.0.28.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,270 @@
|
|
|
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.conf import settings
|
|
13
|
+
from django.utils.translation import gettext_lazy as _
|
|
14
|
+
from rest_framework import serializers
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SpaceSerializer(serializers.Serializer):
|
|
18
|
+
"""空间基础序列化器"""
|
|
19
|
+
|
|
20
|
+
space_id = serializers.IntegerField(
|
|
21
|
+
required=False, help_text=_("空间ID,用于标识流程所属的业务空间"), default=settings.BKFLOW_SDK_DEFAULT_SPACE_ID
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ScopeSerializer(SpaceSerializer):
|
|
26
|
+
"""流程范围序列化器,用于指定流程的作用域"""
|
|
27
|
+
|
|
28
|
+
scope_type = serializers.CharField(
|
|
29
|
+
help_text=_("流程范围类型,如 project/organization/global 等"),
|
|
30
|
+
max_length=128,
|
|
31
|
+
required=False,
|
|
32
|
+
allow_null=True,
|
|
33
|
+
allow_blank=True,
|
|
34
|
+
)
|
|
35
|
+
scope_value = serializers.CharField(
|
|
36
|
+
help_text=_("流程范围值,与 scope_type 配合使用,指定具体的范围 ID"),
|
|
37
|
+
max_length=128,
|
|
38
|
+
required=False,
|
|
39
|
+
allow_null=True,
|
|
40
|
+
allow_blank=True,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class TemplateSerializer(ScopeSerializer):
|
|
45
|
+
"""流程模板序列化器,用于定义流程模板的基本信息"""
|
|
46
|
+
|
|
47
|
+
name = serializers.CharField(help_text=_("流程模板名称,唯一标识流程"), max_length=128, required=True)
|
|
48
|
+
notify_config = serializers.JSONField(help_text=_("通知配置,JSON格式,包含通知方式、通知人等信息"), required=False)
|
|
49
|
+
desc = serializers.CharField(
|
|
50
|
+
help_text=_("流程描述,说明流程的用途和功能"), max_length=256, required=False, allow_blank=True, allow_null=True
|
|
51
|
+
)
|
|
52
|
+
source = serializers.CharField(
|
|
53
|
+
help_text=_("流程来源,标识流程的创建方式或来源系统"), max_length=32, required=False, allow_null=True, allow_blank=True
|
|
54
|
+
)
|
|
55
|
+
version = serializers.CharField(
|
|
56
|
+
help_text=_("流程版本号,用于版本管理"), max_length=32, required=False, allow_blank=True, allow_null=True
|
|
57
|
+
)
|
|
58
|
+
extra_info = serializers.JSONField(help_text=_("额外扩展信息,JSON格式,用于存储自定义字段"), required=False)
|
|
59
|
+
|
|
60
|
+
def validate(self, attrs):
|
|
61
|
+
if "desc" in attrs and (attrs["desc"] is None or attrs["desc"] == ""):
|
|
62
|
+
del attrs["desc"]
|
|
63
|
+
return attrs
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class CreateTemplateSerializer(TemplateSerializer, SpaceSerializer):
|
|
67
|
+
"""创建流程模板序列化器"""
|
|
68
|
+
|
|
69
|
+
source_template_id = serializers.IntegerField(help_text=_("源模板ID,从已有模板复制时使用"), required=False, allow_null=True)
|
|
70
|
+
pipeline_tree = serializers.JSONField(help_text=_("流程树,JSON格式,包含流程节点、连线等完整信息"), required=False)
|
|
71
|
+
operator = serializers.CharField(help_text=_("操作人,记录创建或更新流程的用户"), max_length=32, required=False, allow_blank=True)
|
|
72
|
+
triggers = serializers.ListField(required=False, help_text=_("触发器配置列表,用于设置流程的自动触发条件"), allow_empty=True)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class CreateTaskSerializer(ScopeSerializer):
|
|
76
|
+
"""创建流程任务序列化器"""
|
|
77
|
+
|
|
78
|
+
template_id = serializers.IntegerField(help_text=_("流程模板ID,指定要实例化的流程模板"), required=True)
|
|
79
|
+
name = serializers.CharField(help_text=_("任务名称,用于标识任务实例"), max_length=128, required=False, allow_blank=True)
|
|
80
|
+
creator = serializers.CharField(help_text=_("任务创建者,记录创建任务的用户"), max_length=32, required=True)
|
|
81
|
+
description = serializers.CharField(help_text=_("任务描述,说明任务的目的和背景"), required=True, allow_blank=True)
|
|
82
|
+
constants = serializers.JSONField(help_text=_("任务启动参数,JSON格式,包含流程执行所需的变量值"), required=False, default=dict)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class UpdateTemplateSerializer(TemplateSerializer):
|
|
86
|
+
"""更新流程模板序列化器"""
|
|
87
|
+
|
|
88
|
+
operator = serializers.CharField(help_text=_("操作人,记录更新流程的用户"), max_length=32, required=False, allow_blank=True)
|
|
89
|
+
pipeline_tree = serializers.JSONField(help_text=_("流程树信息,包含更新后的完整流程结构"), required=True)
|
|
90
|
+
triggers = serializers.ListField(required=True, help_text=_("触发器配置列表,更新流程的触发条件"), allow_empty=True)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class CopyTemplateSerializer(ScopeSerializer):
|
|
94
|
+
"""复制流程模板序列化器"""
|
|
95
|
+
|
|
96
|
+
name = serializers.CharField(help_text=_("新模板名称,用于标识复制后的流程"), max_length=128, required=False, allow_blank=True)
|
|
97
|
+
desc = serializers.CharField(help_text=_("新模板描述,说明新模板的目的和背景"), required=False, allow_blank=True)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class GetServicePluginSerializer(serializers.Serializer):
|
|
101
|
+
"""获取第三方插件元数据序列化器"""
|
|
102
|
+
|
|
103
|
+
plugin_code = serializers.CharField(required=True, help_text=_("插件编码,唯一标识第三方插件"))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class InnerPluginDetailSerializer(SpaceSerializer):
|
|
107
|
+
"""获取内置插件详情序列化器"""
|
|
108
|
+
|
|
109
|
+
version = serializers.CharField(required=False, help_text=_("插件版本号,不指定则返回最新版本"), allow_blank=True)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class DecisionTableSerializer(SpaceSerializer):
|
|
113
|
+
"""获取用户决策表插件列表序列化器"""
|
|
114
|
+
|
|
115
|
+
limit = serializers.IntegerField(
|
|
116
|
+
required=False, help_text=_("分页大小,每页返回的数据量"), default=20, min_value=1, max_value=200
|
|
117
|
+
)
|
|
118
|
+
offset = serializers.IntegerField(required=False, help_text=_("分页偏移量,用于翻页"), default=0, min_value=0)
|
|
119
|
+
template_id = serializers.IntegerField(required=True, help_text=_("流程模板ID,查询指定流程下的决策表"))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class UniFormAPiSerializer(SpaceSerializer):
|
|
123
|
+
"""获取统一 API 插件列表序列化器"""
|
|
124
|
+
|
|
125
|
+
template_id = serializers.IntegerField(required=True, help_text=_("流程模板ID,查询指定流程下的统一API插件"))
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class ServicePluginDetailSerializer(serializers.Serializer):
|
|
129
|
+
"""获取第三方插件配置详情序列化器"""
|
|
130
|
+
|
|
131
|
+
plugin_code = serializers.CharField(required=False, help_text=_("插件编码,唯一标识插件"), allow_blank=True)
|
|
132
|
+
plugin_version = serializers.CharField(required=False, help_text=_("插件版本号,不指定则返回最新版本"), allow_blank=True)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class AnalysisConstantsRefSerializer(serializers.Serializer):
|
|
136
|
+
"""变量引用统计分析序列化器"""
|
|
137
|
+
|
|
138
|
+
activities = serializers.JSONField(required=True, help_text=_("活动节点信息,JSON格式,包含流程中的所有活动节点"))
|
|
139
|
+
constants = serializers.JSONField(required=True, help_text=_("常量信息,JSON格式,包含流程中定义的所有变量"))
|
|
140
|
+
gateways = serializers.JSONField(required=True, help_text=_("网关信息,JSON格式,包含流程中的所有分支网关"))
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class TemplateDetailQuerySerializer(ScopeSerializer):
|
|
144
|
+
"""流程模板详情查询序列化器"""
|
|
145
|
+
|
|
146
|
+
with_mock_data = serializers.BooleanField(help_text=_("是否包含 Mock 数据,用于调试和测试"), required=False, default=False)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class TemplateListSerializer(ScopeSerializer):
|
|
150
|
+
"""流程模板列表查询序列化器"""
|
|
151
|
+
|
|
152
|
+
limit = serializers.IntegerField(required=False, help_text=_("每页数量,最大200条"), default=20, min_value=1, max_value=200)
|
|
153
|
+
offset = serializers.IntegerField(required=False, help_text=_("分页偏移量,用于翻页查询"), default=0, min_value=0)
|
|
154
|
+
name = serializers.CharField(required=False, help_text=_("流程名称,支持模糊匹配"), allow_blank=True)
|
|
155
|
+
creator = serializers.CharField(required=False, help_text=_("创建者用户名,精确匹配"), allow_blank=True)
|
|
156
|
+
updated_by = serializers.CharField(required=False, help_text=_("最后更新人用户名,精确匹配"), allow_blank=True)
|
|
157
|
+
create_at_start = serializers.CharField(
|
|
158
|
+
required=False, help_text=_("创建起始时间,格式: YYYY-MM-DD HH:MM:SS,如 2023-08-25 07:49:45"), allow_blank=True
|
|
159
|
+
)
|
|
160
|
+
create_at_end = serializers.CharField(
|
|
161
|
+
required=False, help_text=_("创建结束时间,格式: YYYY-MM-DD HH:MM:SS,如 2023-08-25 07:49:46"), allow_blank=True
|
|
162
|
+
)
|
|
163
|
+
order_by = serializers.CharField(required=False, help_text=_("排序字段,默认按创建时间排序,如: -created 表示倒序"), allow_blank=True)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class TaskSerializer(ScopeSerializer):
|
|
167
|
+
"""流程任务序列化器"""
|
|
168
|
+
|
|
169
|
+
task_id = serializers.IntegerField(help_text=_("任务实例ID,唯一标识一个流程任务"), required=True)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class OperateTaskSerializer(TaskSerializer):
|
|
173
|
+
"""执行任务操作序列化器"""
|
|
174
|
+
|
|
175
|
+
action = serializers.CharField(
|
|
176
|
+
help_text=_("操作类型: start(启动), pause(暂停), resume(继续), revoke(撤销), retry(重试)等"), default="start", required=False
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class BatchTaskStatesSerializer(ScopeSerializer):
|
|
181
|
+
"""批量查询任务状态序列化器"""
|
|
182
|
+
|
|
183
|
+
task_ids = serializers.ListField(
|
|
184
|
+
help_text=_("任务ID列表,批量查询多个任务的状态"),
|
|
185
|
+
required=True,
|
|
186
|
+
child=serializers.IntegerField(required=True, help_text=_("任务实例ID")),
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class CheckVariableKeySerializer(serializers.Serializer):
|
|
191
|
+
"""检查变量 Key 合法性序列化器"""
|
|
192
|
+
|
|
193
|
+
key = serializers.CharField(help_text=_("变量 Key,检查命名是否符合规范(字母开头,支持字母数字下划线)"), required=True)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class GetConstantPreviewResultSerializer(serializers.Serializer):
|
|
197
|
+
"""获取常量预览结果序列化器"""
|
|
198
|
+
|
|
199
|
+
constants = serializers.JSONField(help_text=_("常量信息,JSON格式,包含需要预览的变量定义"), required=False, default=dict)
|
|
200
|
+
extra_data = serializers.JSONField(help_text=_("预览上下文数据,JSON格式,提供额外的执行环境信息"), required=False, default=dict)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class TaskListSerializer(TemplateListSerializer):
|
|
204
|
+
"""流程任务列表查询序列化器"""
|
|
205
|
+
|
|
206
|
+
id = serializers.IntegerField(help_text=_("任务实例ID,唯一标识一个流程任务"), required=False)
|
|
207
|
+
executor = serializers.CharField(help_text=_("执行者用户名,精确匹配"), required=False)
|
|
208
|
+
template_id = serializers.IntegerField(help_text=_("流程模板ID,查询指定流程下的任务"), required=False)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class DeleteTemplateSerializer(ScopeSerializer):
|
|
212
|
+
"""删除流程模板序列化器"""
|
|
213
|
+
|
|
214
|
+
pass
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class GetDraftTemplateSerializer(ScopeSerializer):
|
|
218
|
+
"""获取草稿流程模板序列化器"""
|
|
219
|
+
|
|
220
|
+
pass
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class CalculateVersionSerializer(ScopeSerializer):
|
|
224
|
+
"""计算版本序列化器"""
|
|
225
|
+
|
|
226
|
+
pass
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
class TemplateReleaseSerializer(serializers.Serializer):
|
|
230
|
+
"""模板发布序列化器"""
|
|
231
|
+
|
|
232
|
+
version = serializers.CharField(help_text=_("版本号"), required=True)
|
|
233
|
+
desc = serializers.CharField(help_text=_("描述"), required=False, allow_blank=True)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class TemplateRollbackSerializer(serializers.Serializer):
|
|
237
|
+
"""模板回滚序列化器"""
|
|
238
|
+
|
|
239
|
+
version = serializers.CharField(help_text=_("版本号"), required=True)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class SnapshotSerializer(serializers.Serializer):
|
|
243
|
+
"""快照序列化器"""
|
|
244
|
+
|
|
245
|
+
template_id = serializers.IntegerField(help_text=_("模板ID"), required=True)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
class PreviewTaskTreeSerializer(serializers.Serializer):
|
|
249
|
+
"""预览任务树序列化器"""
|
|
250
|
+
|
|
251
|
+
appoint_node_ids = serializers.ListSerializer(
|
|
252
|
+
child=serializers.CharField(help_text=_("节点ID")), help_text=_("包含的节点ID列表"), default=[]
|
|
253
|
+
)
|
|
254
|
+
is_all_nodes = serializers.BooleanField(required=False, default=False, help_text=_("preview是否需要过滤节点"))
|
|
255
|
+
version = serializers.CharField(help_text=_("版本号"), required=False)
|
|
256
|
+
is_draft = serializers.BooleanField(help_text=_("是否为草稿"), required=False, default=False)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
class BKPluginSerializer(serializers.Serializer):
|
|
260
|
+
"""BKPlugin序列化器"""
|
|
261
|
+
|
|
262
|
+
manager = serializers.CharField(help_text=_("管理员"), required=True)
|
|
263
|
+
space_id = serializers.CharField(help_text=_("空间ID"), required=True)
|
|
264
|
+
search_term = serializers.CharField(help_text=_("搜索关键字"), required=False, allow_blank=True)
|
|
265
|
+
limit = serializers.IntegerField(required=False, help_text=_("每页数量,最大200条"), default=20, min_value=1, max_value=200)
|
|
266
|
+
offset = serializers.IntegerField(required=False, help_text=_("分页偏移量,用于翻页查询"), default=0, min_value=0)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
class PluginCodeQuerySerializer(serializers.Serializer):
|
|
270
|
+
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()
|
bkflow/interface/urls.py
ADDED
|
@@ -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
|
+
]
|