Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions atlassian/confluence/cloud/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion atlassian/confluence_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 13 additions & 1 deletion docs/confluence_v2_migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_confluence_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down
Loading