Skip to content

Commit 14ec62b

Browse files
Add again move_or_update_attachment_json_rpc to __init__.py (#1669)
This method applies to change attachment name at the selected confluence page
1 parent 35ad845 commit 14ec62b

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

atlassian/confluence/server/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,29 @@ def delete_attachment_by_id(self, attachment_id, version):
13701370
url = f"rest/experimental/content/{attachment_id}/version/{version}"
13711371
return self.delete(url)
13721372

1373+
def move_or_update_attachment_json_rpc(self, originalContentId: str, originalName: str, newContentEntityId: str=None, newName: str=None):
1374+
"""
1375+
Move attachment from source confluence page to destination confluence page optionally with new title
1376+
OR
1377+
Just update attachment from source confluence page with new title
1378+
via JSON-RPC.
1379+
:param str originalContentId: confluence source page id
1380+
:param str newContentEntityId: confluence destination page id
1381+
:param str originalName: source attachment title
1382+
:param str newName: new attachment title
1383+
"""
1384+
if self.api_version == "cloud" or self.cloud:
1385+
return {}
1386+
url = "rpc/json-rpc/confluenceservice-v2"
1387+
data = {
1388+
"jsonrpc": "2.0",
1389+
"method": "moveAttachment",
1390+
"id": 9,
1391+
"params": [originalContentId, originalName, newContentEntityId, newName]
1392+
}
1393+
1394+
return self.post(url, data=data).get("result") or {}
1395+
13731396
def remove_page_attachment_keep_version(self, page_id, filename, keep_last_versions):
13741397
"""
13751398
Keep last versions

0 commit comments

Comments
 (0)