@@ -111,8 +111,8 @@ def get_parent_content_id(self, page_id):
111111 parent_content_id = None
112112 try :
113113 parent_content_id = (
114- (self .get_page_by_id (page_id = page_id , expand = 'ancestors' ).get ('ancestors' ) or {})[- 1 ].get (
115- 'id' ) or None )
114+ (self .get_page_by_id (page_id = page_id , expand = 'ancestors' ).get ('ancestors' ) or {})[- 1 ].get (
115+ 'id' ) or None )
116116 except Exception as e :
117117 log .error (e )
118118 return parent_content_id
@@ -1255,6 +1255,44 @@ def set_page_property(self, page_id, data):
12551255
12561256 return response
12571257
1258+ def update_page_property (self , page_id , data ):
1259+ """
1260+ Update the page (content) property.
1261+ Use json data or independent keys
1262+ :param page_id: content_id format
1263+ :data: property data in json format
1264+ :return:
1265+ """
1266+ url = 'rest/api/content/{page_id}/property/{key}' .format (page_id = page_id , key = data .get ("key" ))
1267+ try :
1268+ response = self .put (path = url , data = data )
1269+ except HTTPError as e :
1270+ if e .response .status_code == 400 :
1271+ raise ApiValueError (
1272+ "The given property has a different content id to the one in the "
1273+ "path, or the content already has a value with the given key, or "
1274+ "the value is missing, or the value is too long" ,
1275+ reason = e )
1276+ if e .response .status_code == 403 :
1277+ raise ApiPermissionError (
1278+ "The user does not have permission to "
1279+ "edit the content with the given id" ,
1280+ reason = e )
1281+ if e .response .status_code == 404 :
1282+ raise ApiNotFoundError (
1283+ "There is no content with the given id, or no property with the given key, "
1284+ "or if the calling user does not have permission to view the content." ,
1285+ reason = e
1286+ )
1287+ if e .response .status_code == 409 :
1288+ raise ApiConflictError (
1289+ "The given version is does not match the expected "
1290+ "target version of the updated property" , reason = e )
1291+ if e .response .status_code == 413 :
1292+ raise ApiValueError ("The value is too long" , reason = e )
1293+ raise
1294+ return response
1295+
12581296 def delete_page_property (self , page_id , page_property ):
12591297 """
12601298 Delete the page (content) property e.g. delete key of hash
@@ -1287,7 +1325,6 @@ def get_page_property(self, page_id, page_property_key):
12871325 """
12881326 url = 'rest/api/content/{page_id}/property/{key}' .format (page_id = page_id ,
12891327 key = str (page_property_key ))
1290-
12911328 try :
12921329 response = self .get (path = url )
12931330 except HTTPError as e :
0 commit comments