Skip to content

[Enhancement] Add support for fetching id of blogpost #1142

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 2 commits into from
Apr 2, 2023
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
10 changes: 6 additions & 4 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,15 @@ def get_child_pages(self, page_id):
"""
return self.get_page_child_by_type(page_id=page_id, type="page")

def get_page_id(self, space, title):
def get_page_id(self, space, title, type='page'):
"""
Provide content id from search result by title and space
:param space: SPACE key
:param title: title
:param type: type of content: Page or Blogpost. Defaults to page
:return:
"""
return (self.get_page_by_title(space, title) or {}).get("id")
return (self.get_page_by_title(space, title, type=type) or {}).get("id")

def get_parent_content_id(self, page_id):
"""
Expand Down Expand Up @@ -269,7 +270,7 @@ def get_pages_by_title(self, space, title, start=0, limit=200, expand=None):
"""
return self.get_page_by_title(space, title, start, limit, expand)

def get_page_by_title(self, space, title, start=0, limit=1, expand=None):
def get_page_by_title(self, space, title, start=0, limit=1, expand=None, type='page'):
"""
Returns the first page on a piece of Content.
:param space: Space key
Expand All @@ -278,12 +279,13 @@ def get_page_by_title(self, space, title, start=0, limit=1, expand=None):
:param limit: OPTIONAL: The limit of the number of labels to return, this may be restricted by
fixed system limits. Default: 1.
:param expand: OPTIONAL: expand e.g. history
:param type: OPTIONAL: Type of content: Page or Blogpost. Defaults to page
:return: The JSON data returned from searched results the content endpoint, or the results of the
callback. Will raise requests.HTTPError on bad input, potentially.
If it has IndexError then return the None.
"""
url = "rest/api/content"
params = {}
params = {"type": type}
if start is not None:
params["start"] = int(start)
if limit is not None:
Expand Down