From 11d26c62de1390396225734007b76e285e0ad7e6 Mon Sep 17 00:00:00 2001 From: hyGeorg Date: Thu, 24 Oct 2024 13:33:38 +0200 Subject: [PATCH 1/2] added possibility to share news based on a confluence page --- atlassian/confluence.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/atlassian/confluence.py b/atlassian/confluence.py index 0bea94f6b..e9f942748 100644 --- a/atlassian/confluence.py +++ b/atlassian/confluence.py @@ -136,6 +136,24 @@ def page_exists(self, space, title, type=None): else: return False + def share_with_others(self,page_id:str, group:list, message:str): + """ + Notify members (currently only groups implemented) about something on that page + """ + url = "rest/share-page/latest/share" + params = { + "contextualPageId": page_id, + #"emails": [], + "entityId": page_id, + "entityType": "page", + "groups": group, + "note": message + #"users":[] + } + r = self.post(url, json=params,headers={"contentType":"application/json; charset=utf-8"},advanced_mode=True,) + if r.status_code != 200: + raise Exception(f"failed sharing content {r.status_code}: {r.text}") + def get_page_child_by_type(self, page_id, type="page", start=None, limit=None, expand=None): """ Provide content by type (page, blog, comment) From 76d21be46ce00529c85caca36e9fa5b95d886395 Mon Sep 17 00:00:00 2001 From: hyGeorg Date: Fri, 25 Oct 2024 10:40:59 +0200 Subject: [PATCH 2/2] removed f-strings, types and trailing spaces. --- atlassian/confluence.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/atlassian/confluence.py b/atlassian/confluence.py index e9f942748..dbaa1f22b 100644 --- a/atlassian/confluence.py +++ b/atlassian/confluence.py @@ -136,7 +136,7 @@ def page_exists(self, space, title, type=None): else: return False - def share_with_others(self,page_id:str, group:list, message:str): + def share_with_others(self,page_id, group, message): """ Notify members (currently only groups implemented) about something on that page """ @@ -150,10 +150,10 @@ def share_with_others(self,page_id:str, group:list, message:str): "note": message #"users":[] } - r = self.post(url, json=params,headers={"contentType":"application/json; charset=utf-8"},advanced_mode=True,) + r = self.post(url, json=params,headers={"contentType":"application/json; charset=utf-8"},advanced_mode=True) if r.status_code != 200: - raise Exception(f"failed sharing content {r.status_code}: {r.text}") - + raise Exception("failed sharing content {code}: {reason}".format(code=r.status_code,reason=r.text)) + def get_page_child_by_type(self, page_id, type="page", start=None, limit=None, expand=None): """ Provide content by type (page, blog, comment)