Skip to content

[Confluence] ConfluenceCloud: add create_page and update_page - #1699

Open
LuisFigueroaG wants to merge 1 commit into
atlassian-api:masterfrom
LuisFigueroaG:fix/confluence-cloud-page-methods
Open

LuisFigueroaG wants to merge 1 commit into
atlassian-api:masterfrom
LuisFigueroaG:fix/confluence-cloud-page-methods

Conversation

@LuisFigueroaG

Copy link
Copy Markdown
Contributor

In #1686, Confluence(url="https://<site>.atlassian.net", ...) and from atlassian.confluence import ConfluenceCloud both fail with:

'Cloud' object has no attribute 'update_page'

With a Cloud URL, Confluence passes calls to the legacy Cloud client (ConfluenceCloud), and since the client split that class has had no create_page or update_page. Code written against 4.x has nothing to call on Cloud except ConfluenceV2, which takes different arguments (space ID instead of key, and so on).

This adds both to Cloud, with the same arguments as the Server client:

  • create_page(space, title, body, parent_id=None, ...) POSTs to /wiki/rest/api/content with the space key.
  • update_page(page_id, title, body=None, parent_id=None, ...) reads the page (expand=body.storage,version), returns it as is when the title and body already match (unless always_update=True), and otherwise PUTs the next version to /wiki/rest/api/content/{id}.

These are the same v1 content endpoints the class already uses for get_page_by_id, create_content and update_content.

_create_body moves from Server to the shared ConfluenceBase so both clients use it; Server behaviour doesn't change.

The parent_id error with ConfluenceV2 from the same issue was fixed in #1692, so this covers the rest of it.

Fixes #1686

Added three tests in tests/confluence/test_confluence_cloud.py, one of them calling update_page through Confluence(url="https://test.atlassian.net"); they fail on master with the error from the issue. The full pytest suite, mypy, bandit and doc8 pass; flake8 and black only report the files under examples/ that already fail on master. I haven't run it against a real Cloud site.

Confluence(url="https://<site>.atlassian.net") and ConfluenceCloud return
the legacy Cloud client, which had no create_page/update_page, so code
written against 4.x fails with "'Cloud' object has no attribute
'update_page'".

Add both with the same arguments as the Server client, sending them to
/wiki/rest/api/content like the rest of the Cloud content methods.
_create_body moves to the shared base so both clients use it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confluence update_page not working any more?

1 participant