Skip to content

Commit

Permalink
Merge branch 'atlassian-api:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gkowalc authored Oct 2, 2024
2 parents 5e0217f + 78fe140 commit c880174
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,73 @@ def get_all_draft_pages_from_space_through_cql(self, space, start=0, limit=500,

return response.get("results")

def get_all_pages_by_space_ids_confluence_cloud(
self,
space_ids,
batch_size=250,
sort=None,
status=None,
title=None,
body_format=None,
):
"""
Get all pages from a set of space ids:
https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-get
:param space_ids: A Set of space IDs passed as a filter to Confluence
:param batch_size: OPTIONAL: The batch size of pages to retrieve from confluence per request MAX is 250.
Default: 250
:param sort: OPTIONAL: The order the pages are retrieved in.
Valid values: id, -id, created-date, -created-date, modified-date, -modified-date, title, -title
:param status: OPTIONAL: Filter pages based on their status.
Valid values: current, archived, deleted, trashed
Default: current,archived
:param title: OPTIONAL: Filter pages based on their title.
:param body-format: OPTIONAL: The format of the body in the response. Valid values: storage, atlas_doc_format
:return:
"""
path = "/api/v2/pages"
params = {}
if space_ids:
params["space-id"] = ",".join(space_ids)
if batch_size:
params["limit"] = batch_size
if sort:
params["sort"] = sort
if status:
params["status"] = status
if title:
params["title"] = title
if body_format:
params["body-format"] = body_format

_all_pages = []
try:
while True:
response = self.get(path, params=params)

pages = response.get("results")
_all_pages = _all_pages + pages

links = response.get("_links")
if links is not None and "next" in links:
path = response["_links"]["next"].removeprefix("/wiki/")
params = {}
else:
break
except HTTPError as e:
if e.response.status_code == 400:
raise ApiValueError(
"The configured params cannot be interpreted by Confluence"
"Check the api documentation for valid values for status, expand, and sort params",
reason=e,
)
if e.response.status_code == 401:
raise HTTPError("Unauthorized (401)", response=response)
raise

return _all_pages

@deprecated(version="2.4.2", reason="Use get_all_restrictions_for_content()")
def get_all_restictions_for_content(self, content_id):
"""Let's use the get_all_restrictions_for_content()"""
Expand Down

0 comments on commit c880174

Please sign in to comment.