Skip to content

Commit 9e9b000

Browse files
committed
Add batch_add_links and batch_remove_links
1 parent a9ba9a1 commit 9e9b000

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

seatable_api/api_gateway.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,29 @@ def add_link(self, link_id, table_name, other_table_name, row_id, other_row_id):
419419

420420
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
421421
return parse_response(response)
422+
423+
424+
def batch_add_links(self, link_id, table_name, other_table_name, other_rows_ids_map):
425+
"""
426+
:param link_id: str
427+
:param table_name: str
428+
:param other_table_name: str
429+
:param other_rows_ids_map: dict
430+
"""
431+
url = self._row_link_server_url()
432+
json_data = {
433+
'link_id': link_id,
434+
'table_name': table_name,
435+
'other_table_name': other_table_name,
436+
'other_rows_ids_map': other_rows_ids_map,
437+
}
438+
if like_table_id(table_name):
439+
json_data['table_id'] = table_name
440+
if like_table_id(other_table_name):
441+
json_data['other_table_id'] = other_table_name
442+
443+
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
444+
return parse_response(response)
422445

423446

424447
def remove_link(self, link_id, table_name, other_table_name, row_id, other_row_id):
@@ -442,6 +465,29 @@ def remove_link(self, link_id, table_name, other_table_name, row_id, other_row_i
442465
json_data['other_table_id'] = other_table_name
443466
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
444467
return parse_response(response)
468+
469+
470+
def batch_remove_links(self, link_id, table_name, other_table_name, other_rows_ids_map):
471+
"""
472+
:param link_id: str
473+
:param table_name: str
474+
:param other_table_name: str
475+
:param other_rows_ids_map: dict
476+
"""
477+
url = self._row_link_server_url()
478+
json_data = {
479+
'link_id': link_id,
480+
'table_name': table_name,
481+
'other_table_name': other_table_name,
482+
'other_rows_ids_map': other_rows_ids_map,
483+
}
484+
if like_table_id(table_name):
485+
json_data['table_id'] = table_name
486+
if like_table_id(other_table_name):
487+
json_data['other_table_id'] = other_table_name
488+
489+
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
490+
return parse_response(response)
445491

446492

447493
def update_link(self, link_id, table_name, other_table_name, row_id, other_rows_ids):

seatable_api/main.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,30 @@ def add_link(self, link_id, table_name, other_table_name, row_id, other_row_id):
641641
json_data['other_table_id'] = other_table_name
642642
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
643643
return parse_response(response)
644+
645+
@check_auth
646+
@api_gateway_wrapper
647+
def batch_add_links(self, link_id, table_name, other_table_name, other_rows_ids_map):
648+
"""
649+
:param link_id: str
650+
:param table_name: str
651+
:param other_table_name: str
652+
:param other_rows_ids_map: dict
653+
"""
654+
url = self._row_link_server_url()
655+
json_data = {
656+
'link_id': link_id,
657+
'table_name': table_name,
658+
'other_table_name': other_table_name,
659+
'other_rows_ids_map': other_rows_ids_map,
660+
}
661+
if like_table_id(table_name):
662+
json_data['table_id'] = table_name
663+
if like_table_id(other_table_name):
664+
json_data['other_table_id'] = other_table_name
665+
666+
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
667+
return parse_response(response)
644668

645669
@check_auth
646670
@api_gateway_wrapper
@@ -666,6 +690,30 @@ def remove_link(self, link_id, table_name, other_table_name, row_id, other_row_i
666690
json_data['other_table_id'] = other_table_name
667691
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
668692
return parse_response(response)
693+
694+
@check_auth
695+
@api_gateway_wrapper
696+
def batch_remove_links(self, link_id, table_name, other_table_name, other_rows_ids_map):
697+
"""
698+
:param link_id: str
699+
:param table_name: str
700+
:param other_table_name: str
701+
:param other_rows_ids_map: dict
702+
"""
703+
url = self._row_link_server_url()
704+
json_data = {
705+
'link_id': link_id,
706+
'table_name': table_name,
707+
'other_table_name': other_table_name,
708+
'other_rows_ids_map': other_rows_ids_map,
709+
}
710+
if like_table_id(table_name):
711+
json_data['table_id'] = table_name
712+
if like_table_id(other_table_name):
713+
json_data['other_table_id'] = other_table_name
714+
715+
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
716+
return parse_response(response)
669717

670718
@check_auth
671719
@api_gateway_wrapper

0 commit comments

Comments
 (0)