diff --git a/atlassian/confluence/cloud/cloud.py b/atlassian/confluence/cloud/cloud.py index 072f35e05..6e27f2a04 100644 --- a/atlassian/confluence/cloud/cloud.py +++ b/atlassian/confluence/cloud/cloud.py @@ -344,9 +344,7 @@ def get_child_pages( raise ValueError("Status must be one of 'current', 'archived', 'any'") params["status"] = status - if not get_body: - params["body-format"] = "none" - elif body_format: + if body_format: if body_format not in ("storage", "atlas_doc_format", "view"): raise ValueError("body_format must be one of 'storage', 'atlas_doc_format', or 'view'") params["body-format"] = body_format diff --git a/atlassian/confluence_base.py b/atlassian/confluence_base.py index ec8991f50..59cca8b0f 100644 --- a/atlassian/confluence_base.py +++ b/atlassian/confluence_base.py @@ -35,7 +35,7 @@ class ConfluenceEndpoints: "content": "api/v2/pages", "page_by_id": "api/v2/pages/{id}", "page": "api/v2/pages", - "child_pages": "api/v2/pages/{id}/children/page", + "child_pages": "api/v2/pages/{id}/direct-children", "page_versions": "api/v2/pages/{id}/versions", "page_version": "api/v2/pages/{id}/versions/{version_number}", "search": "api/v2/search", diff --git a/docs/confluence_v2_migration_guide.md b/docs/confluence_v2_migration_guide.md index 05868bcef..d1e57dfc3 100644 --- a/docs/confluence_v2_migration_guide.md +++ b/docs/confluence_v2_migration_guide.md @@ -68,13 +68,25 @@ Below are the most common method name changes between v1 and v2: |-----------|-----------|-------| | `get_page_by_id(page_id)` | `get_page_by_id(page_id)` | Same name, different response structure | | `get_all_pages_from_space(space)` | `get_pages(space_key=space)` | Parameter name changes | -| `get_page_child_by_type(page_id, type="page")` | `get_child_pages(page_id)` | Simpler, focused on pages | +| `get_page_child_by_type(page_id, type="page")` | `get_child_pages(page_id)` | Uses the Cloud V2 direct-children endpoint | | `create_page(space, title, body)` | `create_page(space_id, title, body)` | Parameter `space` renamed to `space_id` | | `update_page(page_id, title, body, version)` | `update_page(page_id, title, body, version)` | Same name, requires version number | | `update_or_create(page_id, title, body, ...)` | No direct equivalent | Use separate create/update methods | | `get_content_properties(page_id)` | `get_page_properties(page_id)` | More specific naming | | `get_content_property(page_id, key)` | `get_page_property_by_key(page_id, key)` | More specific naming | +### Child Pages Endpoint + +Confluence Cloud has deprecated `GET /wiki/api/v2/pages/{id}/children`. The +`get_child_pages()` method uses the replacement endpoint, +`GET /wiki/api/v2/pages/{id}/direct-children`. + +The replacement endpoint uses the `read:hierarchical-content:confluence` +scope and may return direct children of different content types, including +pages, folders, databases, embeds, and whiteboards. The returned child objects +contain minimal information; use the appropriate resource method to retrieve +full details. + ## Response Structure Changes The response structure differs significantly between v1 and v2 APIs: diff --git a/tests/test_confluence_v2.py b/tests/test_confluence_v2.py index df3b6b350..35bb98e56 100644 --- a/tests/test_confluence_v2.py +++ b/tests/test_confluence_v2.py @@ -163,7 +163,8 @@ def test_get_child_pages(self, mock_get_paged): # Assertions mock_get_paged.assert_called_once_with( - "api/v2/pages/PARENT123/children/page", params={"limit": 25, "status": "current", "body-format": "none"} + "api/v2/pages/PARENT123/direct-children", + params={"limit": 25, "status": "current"}, ) self.assertEqual(response, mock_pages) @@ -192,7 +193,7 @@ def test_get_child_pages_with_filters(self, mock_get_paged): "expand": "version", "sort": "child-position", } - mock_get_paged.assert_called_once_with("api/v2/pages/PARENT123/children/page", params=expected_params) + mock_get_paged.assert_called_once_with("api/v2/pages/PARENT123/direct-children", params=expected_params) self.assertEqual(response, mock_pages) def test_get_child_pages_invalid_status(self):