xmes-dingtalk-connectflow-sdk 1.0.1__py3-none-any.whl → 1.0.3__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.
- DingtalkConnectflowSDk/__init__.py +2 -2
- DingtalkConnectflowSDk/_table/_types.py +110 -0
- DingtalkConnectflowSDk/_table/table.py +187 -0
- DingtalkConnectflowSDk/complex_table.py +38 -212
- {xmes_dingtalk_connectflow_sdk-1.0.1.dist-info → xmes_dingtalk_connectflow_sdk-1.0.3.dist-info}/METADATA +10 -7
- xmes_dingtalk_connectflow_sdk-1.0.3.dist-info/RECORD +9 -0
- xmes_dingtalk_connectflow_sdk-1.0.1.dist-info/RECORD +0 -7
- {xmes_dingtalk_connectflow_sdk-1.0.1.dist-info → xmes_dingtalk_connectflow_sdk-1.0.3.dist-info}/LICENSE +0 -0
- {xmes_dingtalk_connectflow_sdk-1.0.1.dist-info → xmes_dingtalk_connectflow_sdk-1.0.3.dist-info}/WHEEL +0 -0
@@ -1,3 +1,3 @@
|
|
1
|
-
__version__ = '1.0.
|
1
|
+
__version__ = '1.0.3'
|
2
2
|
|
3
|
-
from .complex_table import
|
3
|
+
from .complex_table import ComplexTable # noqa: F401
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import json
|
2
|
+
from copy import deepcopy
|
3
|
+
from dataclasses import dataclass
|
4
|
+
from typing import Literal
|
5
|
+
|
6
|
+
from .._types import FilteredDataclass
|
7
|
+
|
8
|
+
|
9
|
+
@dataclass
|
10
|
+
class GetterFilter:
|
11
|
+
"""记录筛选器"""
|
12
|
+
|
13
|
+
field: str
|
14
|
+
operator: Literal[
|
15
|
+
'equal', 'notEqual', 'incontain', 'notContain', 'empty', 'notEmpty'
|
16
|
+
]
|
17
|
+
value: list[str] = None
|
18
|
+
|
19
|
+
|
20
|
+
@dataclass
|
21
|
+
class Updater:
|
22
|
+
"""记录更新器"""
|
23
|
+
|
24
|
+
record_id: str
|
25
|
+
fields: dict[str, any]
|
26
|
+
|
27
|
+
def to_dict(self):
|
28
|
+
return self.__dict__
|
29
|
+
|
30
|
+
|
31
|
+
@dataclass
|
32
|
+
class GetterResult(metaclass=FilteredDataclass):
|
33
|
+
"""获取器结果"""
|
34
|
+
|
35
|
+
nextCursor: str = None
|
36
|
+
records: list[dict] = None
|
37
|
+
hasMore: bool = False
|
38
|
+
|
39
|
+
def __post_init__(self):
|
40
|
+
if self.records and isinstance(self.records, list):
|
41
|
+
self.records = self.__records_handle()
|
42
|
+
|
43
|
+
def __records_handle(self):
|
44
|
+
records: list[dict] = []
|
45
|
+
for record in self.records:
|
46
|
+
record_temp = {'id': record.get('id'), 'fields': {}}
|
47
|
+
fields: dict = record.get('fields')
|
48
|
+
|
49
|
+
for field_name, field_value in fields.items():
|
50
|
+
_value = deepcopy(field_value)
|
51
|
+
if isinstance(field_value, dict):
|
52
|
+
if 'link' in field_value:
|
53
|
+
_value = field_value.get('link')
|
54
|
+
elif 'name' in field_value:
|
55
|
+
_value = field_value.get('name')
|
56
|
+
|
57
|
+
record_temp['fields'][field_name] = _value
|
58
|
+
|
59
|
+
records.append(record_temp)
|
60
|
+
|
61
|
+
return records
|
62
|
+
|
63
|
+
def to_file(self, file_path: str):
|
64
|
+
"""
|
65
|
+
将数据写出到本地
|
66
|
+
|
67
|
+
Args:
|
68
|
+
file_path: 用于存储数据的文件路径
|
69
|
+
Returns:
|
70
|
+
格式化后的 json 字符串
|
71
|
+
"""
|
72
|
+
|
73
|
+
if not self.records:
|
74
|
+
raise ValueError('数据记录为空, 无法写出')
|
75
|
+
|
76
|
+
json_str = json.dumps(self.records, ensure_ascii=False, indent=2)
|
77
|
+
with open(file_path, 'w', encoding='utf-8') as f:
|
78
|
+
f.write(json_str)
|
79
|
+
|
80
|
+
return json_str
|
81
|
+
|
82
|
+
|
83
|
+
@dataclass
|
84
|
+
class AdderResult(metaclass=FilteredDataclass):
|
85
|
+
"""新增器结果"""
|
86
|
+
|
87
|
+
result: list[str] = None
|
88
|
+
"""新增的记录id列表"""
|
89
|
+
success: bool = None
|
90
|
+
errorMsg: str = None
|
91
|
+
|
92
|
+
|
93
|
+
@dataclass
|
94
|
+
class UpdaterResult(metaclass=FilteredDataclass):
|
95
|
+
"""更新器结果"""
|
96
|
+
|
97
|
+
result: list[dict] = None
|
98
|
+
"""更新的记录列表"""
|
99
|
+
success: bool = None
|
100
|
+
errorMsg: str = None
|
101
|
+
|
102
|
+
|
103
|
+
@dataclass
|
104
|
+
class DeletorResult(metaclass=FilteredDataclass):
|
105
|
+
"""删除器结果"""
|
106
|
+
|
107
|
+
result: list[str] = None
|
108
|
+
"""删除的记录id列表"""
|
109
|
+
success: bool = None
|
110
|
+
errorMsg: str = None
|
@@ -0,0 +1,187 @@
|
|
1
|
+
from typing import Any, Literal
|
2
|
+
|
3
|
+
from requests import post
|
4
|
+
|
5
|
+
from ._types import (
|
6
|
+
AdderResult,
|
7
|
+
DeletorResult,
|
8
|
+
GetterFilter,
|
9
|
+
GetterResult,
|
10
|
+
Updater,
|
11
|
+
UpdaterResult,
|
12
|
+
)
|
13
|
+
|
14
|
+
|
15
|
+
class Table:
|
16
|
+
__HEADERS = {
|
17
|
+
'Content-Type': 'application/json',
|
18
|
+
}
|
19
|
+
|
20
|
+
def __init__(self, flow_url: str, did: str, tid: str):
|
21
|
+
self.flow_url = flow_url
|
22
|
+
self.did = did
|
23
|
+
self.tid = tid
|
24
|
+
self.global_reqdata = {
|
25
|
+
'did': did,
|
26
|
+
'tid': tid,
|
27
|
+
}
|
28
|
+
|
29
|
+
def __verify_records(self, records: list[Any], record_type: object):
|
30
|
+
"""
|
31
|
+
records 参数校验
|
32
|
+
- 校验失败, 抛出 ValueError 异常
|
33
|
+
- 校验成功, 返回清洗后的 records 列表
|
34
|
+
|
35
|
+
Args:
|
36
|
+
records: 记录列表
|
37
|
+
record_type: 记录类型
|
38
|
+
"""
|
39
|
+
|
40
|
+
if not records or not isinstance(records, list):
|
41
|
+
raise ValueError('records 参数需要是列表类型且不能为空')
|
42
|
+
|
43
|
+
records_clean = [
|
44
|
+
record for record in records if record and isinstance(record, record_type)
|
45
|
+
]
|
46
|
+
if not records_clean:
|
47
|
+
record_type_name = record_type.__qualname__
|
48
|
+
raise ValueError(
|
49
|
+
f'records 列表经过判断清洗后, 未在其中找到有效的 {record_type_name}'
|
50
|
+
)
|
51
|
+
|
52
|
+
return records_clean
|
53
|
+
|
54
|
+
def get(
|
55
|
+
self,
|
56
|
+
size=20,
|
57
|
+
cursor: str = '',
|
58
|
+
combination: Literal['and', 'or'] = 'and',
|
59
|
+
filters: list[GetterFilter] | None = None,
|
60
|
+
):
|
61
|
+
"""
|
62
|
+
获取表格数据
|
63
|
+
Args:
|
64
|
+
size: 每页数据条数, 默认为 20
|
65
|
+
cursor: 分页游标, 首次请求可不传, 后续需传入上一次返回的 nextCursor 值
|
66
|
+
combination: 组合方式
|
67
|
+
filters: 过滤条件
|
68
|
+
Returns:
|
69
|
+
GetterResult 对象
|
70
|
+
"""
|
71
|
+
|
72
|
+
reqdata = {
|
73
|
+
**self.global_reqdata,
|
74
|
+
'handle': 'GET',
|
75
|
+
'handle_get': {
|
76
|
+
'size': size,
|
77
|
+
'cursor': cursor,
|
78
|
+
},
|
79
|
+
}
|
80
|
+
|
81
|
+
if combination and combination in ['and', 'or']:
|
82
|
+
filter_field = {}
|
83
|
+
filter_field['combination'] = combination
|
84
|
+
if filters and isinstance(filters, list):
|
85
|
+
conditions = [
|
86
|
+
item.__dict__ for item in filters if isinstance(item, GetterFilter)
|
87
|
+
]
|
88
|
+
filter_field['conditions'] = conditions
|
89
|
+
reqdata['handle_get']['filter'] = filter_field
|
90
|
+
|
91
|
+
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
92
|
+
resp_json: dict = resp.json()
|
93
|
+
result: dict = resp_json.get('GET_RESULT')
|
94
|
+
if not result or not isinstance(result, dict):
|
95
|
+
raise ValueError('返回的数据中未找到 GET_RESULT 字段或该字段非字典类型')
|
96
|
+
|
97
|
+
getter_result = GetterResult(**result)
|
98
|
+
|
99
|
+
return getter_result
|
100
|
+
|
101
|
+
def add(self, records: list[dict]):
|
102
|
+
"""
|
103
|
+
新增记录
|
104
|
+
Args:
|
105
|
+
records: 用于新增的记录列表
|
106
|
+
Returns:
|
107
|
+
AdderResult 对象
|
108
|
+
"""
|
109
|
+
|
110
|
+
records_clean = self.__verify_records(records, dict)
|
111
|
+
|
112
|
+
reqdata = {
|
113
|
+
**self.global_reqdata,
|
114
|
+
'handle': 'ADD',
|
115
|
+
'handle_add': {
|
116
|
+
'records': records_clean,
|
117
|
+
},
|
118
|
+
}
|
119
|
+
|
120
|
+
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
121
|
+
resp_json: dict = resp.json()
|
122
|
+
result: dict = resp_json.get('ADD_RESULT')
|
123
|
+
if not result or not isinstance(result, dict):
|
124
|
+
raise ValueError('返回的数据中未找到 ADD_RESULT 字段或该字段非字典类型')
|
125
|
+
|
126
|
+
adder_result = AdderResult(**result)
|
127
|
+
|
128
|
+
return adder_result
|
129
|
+
|
130
|
+
def update(self, records: list[Updater]):
|
131
|
+
"""
|
132
|
+
更新记录
|
133
|
+
Args:
|
134
|
+
records: 更新记录列表
|
135
|
+
Returns:
|
136
|
+
UpdaterResult 对象
|
137
|
+
"""
|
138
|
+
|
139
|
+
records_clean: list[Updater] = self.__verify_records(records, Updater)
|
140
|
+
records_clean = [record.to_dict() for record in records_clean]
|
141
|
+
|
142
|
+
reqdata = {
|
143
|
+
**self.global_reqdata,
|
144
|
+
'handle': 'UPDATE',
|
145
|
+
'handle_update': {
|
146
|
+
'records': records_clean,
|
147
|
+
},
|
148
|
+
}
|
149
|
+
|
150
|
+
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
151
|
+
resp_json: dict = resp.json()
|
152
|
+
result: dict = resp_json.get('UPDATE_RESULT')
|
153
|
+
if not result or not isinstance(result, dict):
|
154
|
+
raise ValueError('返回的数据中未找到 UPDATE_RESULT 字段或该字段非字典类型')
|
155
|
+
|
156
|
+
updater_result = UpdaterResult(**result)
|
157
|
+
|
158
|
+
return updater_result
|
159
|
+
|
160
|
+
def delete(self, record_ids: list[str]):
|
161
|
+
"""
|
162
|
+
删除记录
|
163
|
+
Args:
|
164
|
+
record_ids: 记录 id 列表
|
165
|
+
Returns:
|
166
|
+
DeletorResult 对象
|
167
|
+
"""
|
168
|
+
|
169
|
+
record_ids_clean = self.__verify_records(record_ids, str)
|
170
|
+
|
171
|
+
reqdata = {
|
172
|
+
**self.global_reqdata,
|
173
|
+
'handle': 'DELETE',
|
174
|
+
'handle_delete': {
|
175
|
+
'record_ids': record_ids_clean,
|
176
|
+
},
|
177
|
+
}
|
178
|
+
|
179
|
+
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
180
|
+
resp_json: dict = resp.json()
|
181
|
+
result: dict = resp_json.get('DELETE_RESULT')
|
182
|
+
if not result or not isinstance(result, dict):
|
183
|
+
raise ValueError('返回的数据中未找到 DELETE_RESULT 字段或该字段非字典类型')
|
184
|
+
|
185
|
+
deletor_result = DeletorResult(**result)
|
186
|
+
|
187
|
+
return deletor_result
|
@@ -5,252 +5,78 @@ Author: LeslieLiang
|
|
5
5
|
Description: 多维表连接流SDK
|
6
6
|
"""
|
7
7
|
|
8
|
-
import json
|
9
|
-
from copy import deepcopy
|
10
8
|
from dataclasses import dataclass
|
11
|
-
from
|
9
|
+
from urllib.parse import parse_qs, urlparse
|
12
10
|
|
13
|
-
from
|
14
|
-
|
15
|
-
from ._types import FilteredDataclass
|
16
|
-
|
17
|
-
|
18
|
-
@dataclass
|
19
|
-
class GetterFilter:
|
20
|
-
"""记录筛选器"""
|
21
|
-
|
22
|
-
field: str
|
23
|
-
operator: Literal[
|
24
|
-
'equal', 'notEqual', 'incontain', 'notContain', 'empty', 'notEmpty'
|
25
|
-
]
|
26
|
-
value: list[str] = None
|
27
|
-
|
28
|
-
|
29
|
-
@dataclass
|
30
|
-
class Updater:
|
31
|
-
"""记录更新器"""
|
32
|
-
|
33
|
-
record_id: str
|
34
|
-
fields: dict[str, any]
|
11
|
+
from ._table.table import Table
|
35
12
|
|
36
13
|
|
37
14
|
@dataclass
|
38
|
-
class
|
39
|
-
"""
|
15
|
+
class ViewUrl:
|
16
|
+
"""视图链接对象"""
|
40
17
|
|
41
|
-
|
42
|
-
|
43
|
-
|
18
|
+
url: str = None
|
19
|
+
did: str = None
|
20
|
+
"""文档id"""
|
21
|
+
tid: str = None
|
22
|
+
"""数据表id"""
|
44
23
|
|
45
|
-
def __post_init__(self):
|
46
|
-
if self.records and isinstance(self.records, list):
|
47
|
-
self.records = self.__records_handle()
|
48
24
|
|
49
|
-
|
50
|
-
|
51
|
-
for record in self.records:
|
52
|
-
record_temp = {'id': record.get('id'), 'fields': {}}
|
53
|
-
fields: dict = record.get('fields')
|
54
|
-
|
55
|
-
for field_name, field_value in fields.items():
|
56
|
-
_value = deepcopy(field_value)
|
57
|
-
if isinstance(field_value, dict):
|
58
|
-
if 'link' in field_value:
|
59
|
-
_value = field_value.get('link')
|
60
|
-
elif 'name' in field_value:
|
61
|
-
_value = field_value.get('name')
|
62
|
-
|
63
|
-
record_temp['fields'][field_name] = _value
|
64
|
-
|
65
|
-
records.append(record_temp)
|
66
|
-
|
67
|
-
return records
|
68
|
-
|
69
|
-
def to_file(self, file_path: str):
|
25
|
+
class ComplexTable:
|
26
|
+
def __init__(self, flow_url: str):
|
70
27
|
"""
|
71
|
-
|
72
|
-
|
28
|
+
初始化 ComplexTable 类
|
73
29
|
Args:
|
74
|
-
|
75
|
-
Returns:
|
76
|
-
数据文件路径
|
30
|
+
flow_url: 连接流 url
|
77
31
|
"""
|
78
32
|
|
79
|
-
if not self.records:
|
80
|
-
raise ValueError('数据记录为空, 无法写出')
|
81
|
-
|
82
|
-
with open(f'{file_path}.json', 'w', encoding='utf-8') as f:
|
83
|
-
f.write(json.dumps(self.records, ensure_ascii=False, indent=2))
|
84
|
-
|
85
|
-
return file_path
|
86
|
-
|
87
|
-
|
88
|
-
class Table:
|
89
|
-
__HEADERS = {
|
90
|
-
'Content-Type': 'application/json',
|
91
|
-
}
|
92
|
-
|
93
|
-
def __init__(self, flow_url: str, did: str, tid: str):
|
94
33
|
self.flow_url = flow_url
|
95
|
-
self.did = did
|
96
|
-
self.tid = tid
|
97
|
-
self.global_reqdata = {
|
98
|
-
'did': did,
|
99
|
-
'tid': tid,
|
100
|
-
}
|
101
34
|
|
102
|
-
def
|
103
|
-
self,
|
104
|
-
size=20,
|
105
|
-
cursor: str = '',
|
106
|
-
combination: Literal['and', 'or'] = 'and',
|
107
|
-
filters: list[GetterFilter] | None = None,
|
108
|
-
):
|
35
|
+
def _parse_view_url(self, view_url: str):
|
109
36
|
"""
|
110
|
-
|
111
|
-
Args:
|
112
|
-
size: 每页数据条数, 默认为 20
|
113
|
-
cursor: 分页游标, 首次请求可不传, 后续需传入上一次返回的 nextCursor 值
|
114
|
-
combination: 组合方式
|
115
|
-
filters: 过滤条件
|
116
|
-
Returns:
|
117
|
-
表格数据
|
118
|
-
"""
|
119
|
-
|
120
|
-
reqdata = {
|
121
|
-
**self.global_reqdata,
|
122
|
-
'handle': 'GET',
|
123
|
-
'handle_get': {
|
124
|
-
'size': size,
|
125
|
-
'cursor': cursor,
|
126
|
-
},
|
127
|
-
}
|
128
|
-
|
129
|
-
if combination and combination in ['and', 'or']:
|
130
|
-
filter_field = {}
|
131
|
-
filter_field['combination'] = combination
|
132
|
-
if filters and isinstance(filters, list):
|
133
|
-
conditions = [
|
134
|
-
item.__dict__ for item in filters if isinstance(item, GetterFilter)
|
135
|
-
]
|
136
|
-
filter_field['conditions'] = conditions
|
137
|
-
reqdata['handle_get']['filter'] = filter_field
|
37
|
+
解析视图链接
|
138
38
|
|
139
|
-
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
140
|
-
result: dict = resp.json().get('GET_RESULT')
|
141
|
-
|
142
|
-
getter_result = GetterResult(**result)
|
143
|
-
|
144
|
-
return getter_result
|
145
|
-
|
146
|
-
def add(self, records: list[dict]):
|
147
|
-
"""
|
148
|
-
新增记录
|
149
39
|
Args:
|
150
|
-
|
40
|
+
view_url: 视图链接
|
151
41
|
Returns:
|
152
|
-
|
42
|
+
ViewUrl 对象
|
153
43
|
"""
|
154
44
|
|
155
|
-
if not
|
156
|
-
raise ValueError('
|
45
|
+
if not view_url or not isinstance(view_url, str):
|
46
|
+
raise ValueError('view_url 参数不能为空或非字符串类型')
|
157
47
|
|
158
|
-
|
159
|
-
|
160
|
-
]
|
161
|
-
if not records_clean:
|
162
|
-
raise ValueError('records must not be empty')
|
48
|
+
parsed_url = urlparse(view_url)
|
49
|
+
url_path_splited = parsed_url.path.split('/')
|
50
|
+
did = url_path_splited[-1]
|
163
51
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
'handle_add': {
|
168
|
-
'records': records_clean,
|
169
|
-
},
|
170
|
-
}
|
52
|
+
query_dict = {k: v[0] for k, v in parse_qs(parsed_url.query).items()}
|
53
|
+
iframeQuery = query_dict.get('iframeQuery')
|
54
|
+
tid = parse_qs(iframeQuery).get('sheetId')[0]
|
171
55
|
|
172
|
-
|
173
|
-
return resp.json().get('ADD_RESULT')
|
56
|
+
return ViewUrl(url=view_url, did=did, tid=tid)
|
174
57
|
|
175
|
-
def
|
176
|
-
"""
|
177
|
-
更新记录
|
178
|
-
Args:
|
179
|
-
records: 更新记录列表
|
180
|
-
Returns:
|
181
|
-
更新记录结果
|
182
|
-
"""
|
183
|
-
|
184
|
-
if not records or not isinstance(records, list):
|
185
|
-
raise ValueError('records must be a list')
|
186
|
-
|
187
|
-
records_clean = [
|
188
|
-
record.__dict__
|
189
|
-
for record in records
|
190
|
-
if record and isinstance(record, Updater)
|
191
|
-
]
|
192
|
-
if not records_clean:
|
193
|
-
raise ValueError('records must not be empty')
|
194
|
-
|
195
|
-
reqdata = {
|
196
|
-
**self.global_reqdata,
|
197
|
-
'handle': 'UPDATE',
|
198
|
-
'handle_update': {
|
199
|
-
'records': records_clean,
|
200
|
-
},
|
201
|
-
}
|
202
|
-
|
203
|
-
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
204
|
-
return resp.json().get('UPDATE_RESULT')
|
205
|
-
|
206
|
-
def delete(self, record_ids: list[str]):
|
58
|
+
def get_table(self, did: str, tid: str) -> Table:
|
207
59
|
"""
|
208
|
-
|
60
|
+
获取表格对象
|
209
61
|
Args:
|
210
|
-
|
62
|
+
did: 文档 id
|
63
|
+
tid: 数据表 id
|
211
64
|
Returns:
|
212
|
-
|
65
|
+
Table 对象
|
213
66
|
"""
|
214
67
|
|
215
|
-
|
216
|
-
raise ValueError('record_ids must be a list')
|
217
|
-
|
218
|
-
record_ids_clean = [
|
219
|
-
record_id
|
220
|
-
for record_id in record_ids
|
221
|
-
if record_id and isinstance(record_id, str)
|
222
|
-
]
|
223
|
-
|
224
|
-
reqdata = {
|
225
|
-
**self.global_reqdata,
|
226
|
-
'handle': 'DELETE',
|
227
|
-
'handle_delete': {
|
228
|
-
'record_ids': record_ids_clean,
|
229
|
-
},
|
230
|
-
}
|
231
|
-
|
232
|
-
resp = post(self.flow_url, json=reqdata, headers=self.__HEADERS)
|
233
|
-
return resp.json().get('DELETE_RESULT')
|
234
|
-
|
68
|
+
return Table(self.flow_url, did, tid)
|
235
69
|
|
236
|
-
|
237
|
-
def __init__(self, flow_url: str):
|
238
|
-
"""
|
239
|
-
初始化 ComplexTable 类
|
240
|
-
Args:
|
241
|
-
flow_url: 连接流 url
|
70
|
+
def get_table_by_view_url(self, url: str):
|
242
71
|
"""
|
72
|
+
通过视图链接获取表格对象
|
73
|
+
- 解析视图链接获取其中的文档id和视图id
|
243
74
|
|
244
|
-
self.flow_url = flow_url
|
245
|
-
|
246
|
-
def get_table(self, did: str, tid: str) -> Table:
|
247
|
-
"""
|
248
|
-
获取表格对象
|
249
75
|
Args:
|
250
|
-
|
251
|
-
tid: 数据表 id
|
76
|
+
url: 视图链接
|
252
77
|
Returns:
|
253
78
|
Table 对象
|
254
79
|
"""
|
255
80
|
|
256
|
-
|
81
|
+
view_url = self._parse_view_url(view_url=url)
|
82
|
+
return self.get_table(did=view_url.did, tid=view_url.tid)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: xmes-dingtalk-connectflow-sdk
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.3
|
4
4
|
Summary: DingTalk Connection Platform Connection Flow SDK
|
5
5
|
License: MIT
|
6
6
|
Author: leslieliang
|
@@ -16,7 +16,7 @@ Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
16
16
|
Description-Content-Type: text/markdown
|
17
17
|
|
18
18
|
## 概述
|
19
|
-

|
20
20
|

|
21
21
|
|
22
22
|
`xmes-dingtalk-connectflow-sdk` 是钉钉连接平台自建连接流SDK(向美而生),通过该工具可以方便快捷的调用钉钉的连接流。
|
@@ -33,35 +33,38 @@ pip install xmes-dingtalk-connectflow-sdk
|
|
33
33
|
### ComplexTable
|
34
34
|
该工具提供了连接流 `多维表CURD_241217` 的操作调用工具。
|
35
35
|
```python
|
36
|
-
from DingtalkConnectflowSDK import ComplexTable
|
36
|
+
from DingtalkConnectflowSDK import ComplexTable
|
37
|
+
from DingtalkConnectflowSDk._table._types import GetterFilter, Updater
|
37
38
|
|
38
39
|
# 初始化ComplexTable对象
|
39
40
|
complextable = ComplexTable(flow_url='<连接流的同步协调URL>')
|
40
41
|
|
41
42
|
# 获取 Table 对象
|
42
43
|
table = complextable.get_table(did='<文档ID>', tid='<数据表ID>')
|
44
|
+
# 或者直接传入视图链接
|
45
|
+
# table = complextable.get_table_by_view_url(url='<视图链接>')
|
43
46
|
|
44
47
|
# 查询数据
|
45
48
|
filters = [
|
46
49
|
GetterFilter(field='来源', operator='equal', value=['SDK', 'API'])
|
47
50
|
]
|
48
|
-
|
51
|
+
result = table.get(size=10, fillters=filters)
|
49
52
|
|
50
53
|
# 新增数据
|
51
54
|
records = [
|
52
55
|
{'标题': 'Test Record 1', '来源': 'SDK},
|
53
56
|
{'标题': 'Test Record 2', '来源': 'SDK},
|
54
57
|
]
|
55
|
-
|
58
|
+
result = table.add(records)
|
56
59
|
|
57
60
|
# 更新数据
|
58
61
|
records = [
|
59
62
|
Updater(record_id='<记录ID>', fields={'来源': 'API'}),
|
60
63
|
Updater(record_id='<记录ID>', fields={'来源': 'API'}),
|
61
64
|
]
|
62
|
-
|
65
|
+
result = table.update(records)
|
63
66
|
|
64
67
|
# 删除数据
|
65
68
|
record_ids = ['<记录ID>', '<记录ID>']
|
66
|
-
|
69
|
+
result = table.delete(record_ids)
|
67
70
|
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
DingtalkConnectflowSDk/__init__.py,sha256=VJs2MzhbqEwd2gdtyV17Bo4oVXhotWktGWB-J0Ic9GI,80
|
2
|
+
DingtalkConnectflowSDk/_table/_types.py,sha256=DV-GVshNXdQTL0Ix53Z2Dd5G4fRi5hXEuUJxLzU_L6Y,2748
|
3
|
+
DingtalkConnectflowSDk/_table/table.py,sha256=E2NCZRToTELaaJ4Q8oNgKEoA3HT14tsRNzeZjexTQeU,5755
|
4
|
+
DingtalkConnectflowSDk/_types.py,sha256=TnJI3HHXVObasHWWdqBkX9n-N5E1IENmx7a4k0ehbdk,317
|
5
|
+
DingtalkConnectflowSDk/complex_table.py,sha256=AVV5ALwmvDb73D8ZTQ-fXAPONn5tUmSPqvM9GbswsQg,2056
|
6
|
+
xmes_dingtalk_connectflow_sdk-1.0.3.dist-info/LICENSE,sha256=pLVhl_GNSUPILCWP8DLtqZXytsqXr1lfPp4RwXXypZc,1090
|
7
|
+
xmes_dingtalk_connectflow_sdk-1.0.3.dist-info/METADATA,sha256=rDyAPyG6CW6gf1DADDaHJ3mM3fft2IOHzSC-bnKUrvQ,2156
|
8
|
+
xmes_dingtalk_connectflow_sdk-1.0.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
9
|
+
xmes_dingtalk_connectflow_sdk-1.0.3.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
DingtalkConnectflowSDk/__init__.py,sha256=-hU6zkU0j1fC1i5ctzX9dvrooD_4Z9mJqjvz13yiqPc,69
|
2
|
-
DingtalkConnectflowSDk/_types.py,sha256=TnJI3HHXVObasHWWdqBkX9n-N5E1IENmx7a4k0ehbdk,317
|
3
|
-
DingtalkConnectflowSDk/complex_table.py,sha256=V4Az32gtsMlbjshrumuO_7dsx67I3EwK6-mceeZAurk,7000
|
4
|
-
xmes_dingtalk_connectflow_sdk-1.0.1.dist-info/LICENSE,sha256=pLVhl_GNSUPILCWP8DLtqZXytsqXr1lfPp4RwXXypZc,1090
|
5
|
-
xmes_dingtalk_connectflow_sdk-1.0.1.dist-info/METADATA,sha256=dMVvQ_UqRGy_1WRpFxOiJcvIZpxUcezwig0dRH4YLGc,2000
|
6
|
-
xmes_dingtalk_connectflow_sdk-1.0.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
7
|
-
xmes_dingtalk_connectflow_sdk-1.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|