Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions seatable_api/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,29 @@ def add_link(self, link_id, table_name, other_table_name, row_id, other_row_id):

response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
return parse_response(response)


def batch_add_links(self, link_id, table_name, other_table_name, other_rows_ids_map):
"""
:param link_id: str
:param table_name: str
:param other_table_name: str
:param other_rows_ids_map: dict
"""
url = self._row_link_server_url()
json_data = {
'link_id': link_id,
'table_name': table_name,
'other_table_name': other_table_name,
'other_rows_ids_map': other_rows_ids_map,
}
if like_table_id(table_name):
json_data['table_id'] = table_name
if like_table_id(other_table_name):
json_data['other_table_id'] = other_table_name

response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
return parse_response(response)


def remove_link(self, link_id, table_name, other_table_name, row_id, other_row_id):
Expand All @@ -442,6 +465,29 @@ def remove_link(self, link_id, table_name, other_table_name, row_id, other_row_i
json_data['other_table_id'] = other_table_name
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
return parse_response(response)


def batch_remove_links(self, link_id, table_name, other_table_name, other_rows_ids_map):
"""
:param link_id: str
:param table_name: str
:param other_table_name: str
:param other_rows_ids_map: dict
"""
url = self._row_link_server_url()
json_data = {
'link_id': link_id,
'table_name': table_name,
'other_table_name': other_table_name,
'other_rows_ids_map': other_rows_ids_map,
}
if like_table_id(table_name):
json_data['table_id'] = table_name
if like_table_id(other_table_name):
json_data['other_table_id'] = other_table_name

response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
return parse_response(response)


def update_link(self, link_id, table_name, other_table_name, row_id, other_rows_ids):
Expand Down
48 changes: 48 additions & 0 deletions seatable_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,30 @@ def add_link(self, link_id, table_name, other_table_name, row_id, other_row_id):
json_data['other_table_id'] = other_table_name
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
return parse_response(response)

@check_auth
@api_gateway_wrapper
def batch_add_links(self, link_id, table_name, other_table_name, other_rows_ids_map):
"""
:param link_id: str
:param table_name: str
:param other_table_name: str
:param other_rows_ids_map: dict
"""
url = self._row_link_server_url()
json_data = {
'link_id': link_id,
'table_name': table_name,
'other_table_name': other_table_name,
'other_rows_ids_map': other_rows_ids_map,
}
if like_table_id(table_name):
json_data['table_id'] = table_name
if like_table_id(other_table_name):
json_data['other_table_id'] = other_table_name

response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
return parse_response(response)

@check_auth
@api_gateway_wrapper
Expand All @@ -666,6 +690,30 @@ def remove_link(self, link_id, table_name, other_table_name, row_id, other_row_i
json_data['other_table_id'] = other_table_name
response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
return parse_response(response)

@check_auth
@api_gateway_wrapper
def batch_remove_links(self, link_id, table_name, other_table_name, other_rows_ids_map):
"""
:param link_id: str
:param table_name: str
:param other_table_name: str
:param other_rows_ids_map: dict
"""
url = self._row_link_server_url()
json_data = {
'link_id': link_id,
'table_name': table_name,
'other_table_name': other_table_name,
'other_rows_ids_map': other_rows_ids_map,
}
if like_table_id(table_name):
json_data['table_id'] = table_name
if like_table_id(other_table_name):
json_data['other_table_id'] = other_table_name

response = requests.delete(url, json=json_data, headers=self.headers, timeout=self.timeout)
return parse_response(response)

@check_auth
@api_gateway_wrapper
Expand Down