@@ -692,6 +692,73 @@ def get_all_draft_pages_from_space_through_cql(self, space, start=0, limit=500,
692
692
693
693
return response .get ("results" )
694
694
695
+ def get_all_pages_by_space_ids_confluence_cloud (
696
+ self ,
697
+ space_ids ,
698
+ batch_size = 250 ,
699
+ sort = None ,
700
+ status = None ,
701
+ title = None ,
702
+ body_format = None ,
703
+ ):
704
+ """
705
+ Get all pages from a set of space ids:
706
+ https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-get
707
+
708
+ :param space_ids: A Set of space IDs passed as a filter to Confluence
709
+ :param batch_size: OPTIONAL: The batch size of pages to retrieve from confluence per request MAX is 250.
710
+ Default: 250
711
+ :param sort: OPTIONAL: The order the pages are retrieved in.
712
+ Valid values: id, -id, created-date, -created-date, modified-date, -modified-date, title, -title
713
+ :param status: OPTIONAL: Filter pages based on their status.
714
+ Valid values: current, archived, deleted, trashed
715
+ Default: current,archived
716
+ :param title: OPTIONAL: Filter pages based on their title.
717
+ :param body-format: OPTIONAL: The format of the body in the response. Valid values: storage, atlas_doc_format
718
+ :return:
719
+ """
720
+ path = "/api/v2/pages"
721
+ params = {}
722
+ if space_ids :
723
+ params ["space-id" ] = "," .join (space_ids )
724
+ if batch_size :
725
+ params ["limit" ] = batch_size
726
+ if sort :
727
+ params ["sort" ] = sort
728
+ if status :
729
+ params ["status" ] = status
730
+ if title :
731
+ params ["title" ] = title
732
+ if body_format :
733
+ params ["body-format" ] = body_format
734
+
735
+ _all_pages = []
736
+ try :
737
+ while True :
738
+ response = self .get (path , params = params )
739
+
740
+ pages = response .get ("results" )
741
+ _all_pages = _all_pages + pages
742
+
743
+ links = response .get ("_links" )
744
+ if links is not None and "next" in links :
745
+ path = response ["_links" ]["next" ].removeprefix ("/wiki/" )
746
+ params = {}
747
+ else :
748
+ break
749
+ except HTTPError as e :
750
+ if e .response .status_code == 400 :
751
+ raise ApiValueError (
752
+ "The configured params cannot be interpreted by Confluence"
753
+ "Check the api documentation for valid values for status, expand, and sort params" ,
754
+ reason = e ,
755
+ )
756
+ if e .response .status_code == 401 :
757
+ raise HTTPError ("Unauthorized (401)" , response = response )
758
+ raise
759
+
760
+ return _all_pages
761
+
695
762
@deprecated (version = "2.4.2" , reason = "Use get_all_restrictions_for_content()" )
696
763
def get_all_restictions_for_content (self , content_id ):
697
764
"""Let's use the get_all_restrictions_for_content()"""
0 commit comments