Skip to content

Commit dccd662

Browse files
[Enhancement] Add support for fetching id of blogpost (#1142)
* modify get_page_by_title for blogpost * make get_page_by_id work for blogpost
1 parent 165286b commit dccd662

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

atlassian/confluence.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,15 @@ def get_child_pages(self, page_id):
207207
"""
208208
return self.get_page_child_by_type(page_id=page_id, type="page")
209209

210-
def get_page_id(self, space, title):
210+
def get_page_id(self, space, title, type='page'):
211211
"""
212212
Provide content id from search result by title and space
213213
:param space: SPACE key
214214
:param title: title
215+
:param type: type of content: Page or Blogpost. Defaults to page
215216
:return:
216217
"""
217-
return (self.get_page_by_title(space, title) or {}).get("id")
218+
return (self.get_page_by_title(space, title, type=type) or {}).get("id")
218219

219220
def get_parent_content_id(self, page_id):
220221
"""
@@ -269,7 +270,7 @@ def get_pages_by_title(self, space, title, start=0, limit=200, expand=None):
269270
"""
270271
return self.get_page_by_title(space, title, start, limit, expand)
271272

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

0 commit comments

Comments
 (0)