Skip to content

[Confluence] page_exists method without error log #949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2022
Merged
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
34 changes: 26 additions & 8 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,33 @@ def _get_paged(self, url, params=None, data=None, flags=None, trailing=None, abs
return

def page_exists(self, space, title):
"""
Check if title exists as page.
:param space: Space key
:param title: Title of the page
:return:
"""
url = "rest/api/content"
params = {}
if space is not None:
params["spaceKey"] = str(space)
if title is not None:
params["title"] = str(title)

try:
if self.get_page_by_title(space, title):
log.info('Page "{title}" already exists in space "{space}"'.format(space=space, title=title))
return True
else:
log.info("Page does not exist because did not find by title search")
return False
except (HTTPError, KeyError, IndexError):
log.info('Page "{title}" does not exist in space "{space}"'.format(space=space, title=title))
response = self.get(url, params=params)
except HTTPError as e:
if e.response.status_code == 404:
raise ApiPermissionError(
"The calling user does not have permission to view the content",
reason=e,
)

raise

if response.get("results"):
return True
else:
return False

def get_page_child_by_type(self, page_id, type="page", start=None, limit=None, expand=None):
Expand Down