@@ -201,6 +201,42 @@ def _get_account_detail(self, account_name):
201201 data = parse_response (response )
202202 return data .get ('account' )
203203
204+ def _add_comment_url (self ):
205+ url = '%(server_url)s/api/v1/dtables/%(dtable_uuid)s/comments/' % {
206+ 'server_url' : self .dtable_server_url ,
207+ 'dtable_uuid' : self .dtable_uuid
208+ }
209+ return url
210+
211+ def _get_comments_url (self ):
212+ url = '%(server_url)s/api/v2.1/dtables/%(dtable_uuid)s/comments/' % {
213+ 'server_url' : self .server_url ,
214+ 'dtable_uuid' : self .dtable_uuid
215+ }
216+ return url
217+
218+ def _get_comments_count_url (self ):
219+ url = '%(server_url)s/api/v2.1/dtables/%(dtable_uuid)s/comments-count/' % {
220+ 'server_url' : self .server_url ,
221+ 'dtable_uuid' : self .dtable_uuid
222+ }
223+ return url
224+
225+ def _update_or_delete_comment_url (self , comment_id ):
226+ url = '%(server_url)s/api/v2.1/dtables/%(dtable_uuid)s/comments/%(comment_id)s/' % {
227+ 'server_url' : self .server_url ,
228+ 'dtable_uuid' : self .dtable_uuid ,
229+ 'comment_id' : comment_id
230+ }
231+ return url
232+
233+ def _get_comments_within_days_url (self ):
234+ url = '%(server_url)s/api/v2.1/dtables/%(dtable_uuid)s/comments-within-days/' % {
235+ 'server_url' : self .dtable_server_url ,
236+ 'dtable_uuid' : self .dtable_uuid
237+ }
238+ return url
239+
204240 def send_email (self , account_name , msg , ** kwargs ):
205241 msg_sender = self ._get_msg_sender_by_account (account_name )
206242 if not msg_sender or msg_sender .msg_type != 'email' :
@@ -944,7 +980,6 @@ def add_workflow_task_with_existed_row(self, workflow_token, row_id, initiator=N
944980 response = requests .post (url , data = {'row_id' : row_id , 'initiator' : initiator }, headers = headers )
945981 return parse_response (response )['task' ]
946982
947-
948983 def big_data_insert_rows (self , table_name , rows_data ):
949984 url = self ._dtable_db_insert_rows_url ()
950985 json_data = {
@@ -954,6 +989,75 @@ def big_data_insert_rows(self, table_name, rows_data):
954989 response = requests .post (url , json = json_data , headers = self .headers , timeout = self .timeout )
955990 return parse_response (response )
956991
992+ def add_comment (self , table_id , row_id , comment ):
993+ """
994+ :param table_id: str
995+ :param row_id: str
996+ :param comment: str
997+ :return: success response dict {'success': True}
998+ """
999+ url = self ._add_comment_url ()
1000+ params = {'table_id' : table_id , 'row_id' : row_id }
1001+ json_data = {'comment' : str (comment )}
1002+ response = requests .post (url , params = params , json = json_data , headers = self .headers , timeout = self .timeout )
1003+ return parse_response (response )
1004+
1005+ def get_comments_count (self , row_id ):
1006+ """
1007+ :param row_id: str
1008+ :return: int
1009+ """
1010+ url = self ._get_comments_count_url ()
1011+ params = {'row_id' : row_id }
1012+ response = requests .get (url , params = params , headers = self .headers , timeout = self .timeout )
1013+ return parse_response (response )['count' ]
1014+
1015+ def get_comments (self , row_id , page = 1 , per_page = 25 ):
1016+ """
1017+ :param row_id: str
1018+ :param page: str
1019+ :param per_page: str
1020+ :return: a dict of {'comments': <list>, 'count': <int>}
1021+ """
1022+ url = self ._get_comments_url ()
1023+ params = {
1024+ 'row_id' : row_id ,
1025+ 'page' : page ,
1026+ 'per_page' : per_page
1027+ }
1028+ response = requests .get (url , params = params , headers = self .headers , timeout = self .timeout )
1029+ return parse_response (response )
1030+
1031+ def resolve_comment (self , comment_id , resolved = True ):
1032+ """
1033+ :param comment_id: str
1034+ :param resolved: bool
1035+ :return: success response dict {'success': True}
1036+ """
1037+ url = self ._update_or_delete_comment_url (comment_id )
1038+ options = {'resovled' : 'true' if resolved else 'false' }
1039+ data = {'options' : options }
1040+ response = requests .get (url , json = data , headers = self .headers , timeout = self .timeout )
1041+ return parse_response (response )
1042+
1043+ def delete_comment (self , comment_id ):
1044+ """
1045+ :param comment_id: str
1046+ :return: success response dict {'success': True}
1047+ """
1048+ url = self ._update_or_delete_comment_url (comment_id )
1049+ response = requests .delete (url , headers = self .headers , timeout = self .timeout )
1050+ return parse_response (response )
1051+
1052+ def get_comments_within_days (self , days = 3 ):
1053+ """
1054+ :param days: int
1055+ :return: list of comments
1056+ """
1057+ url = self ._get_comments_within_days_url ()
1058+ params = {'days' : days }
1059+ response = requests .get (url , params = params , headers = self .headers , timeout = self .timeout )
1060+ return parse_response (response )['comment_list' ]
9571061
9581062
9591063class Account (object ):
0 commit comments