Skip to content

[Confluence] ConfluenceCloud: add set_page_label and remove_page_label - #1721

Merged
gonchik merged 1 commit into
atlassian-api:masterfrom
LuisFigueroaG:fix/confluence-cloud-page-labels
Nov 18, 2026
Merged

gonchik merged 1 commit into
atlassian-api:masterfrom
LuisFigueroaG:fix/confluence-cloud-page-labels

Conversation

@LuisFigueroaG

Copy link
Copy Markdown
Contributor

docs/confluence.rst documents confluence.set_page_label(page_id, label) and confluence.remove_page_label(page_id, label), and the Server client has both. The Cloud client (Confluence(url="https://<site>.atlassian.net") / ConfluenceCloud) doesn't, so the calls fail with:

AttributeError: 'Cloud' object has no attribute 'set_page_label'

Cloud does have add_content_labels() and remove_content_label(), but they take a different payload/path, so code written against the documented methods has to be changed for Cloud.

This adds both methods to Cloud with the same arguments, return value and error mapping as the Server client:

  • set_page_label sends POST /wiki/rest/api/content/{id}/label with {"prefix": "global", "name": label} (addLabelsToContent in the Cloud v1 labels reference); a 404 raises ApiError.
  • remove_page_label sends DELETE /wiki/rest/api/content/{id}/label?name={label} (removeLabelFromContentUsingQueryParameter). I used the query parameter version rather than /label/{label} because the path version rejects label names with /. A 403 raises ApiPermissionError and a 404 raises ApiError, like Server.

I also added a line to both entries in docs/confluence.rst saying they work on Cloud.

Tests: added eight tests to tests/confluence/test_confluence_cloud.py covering the request arguments, the final URLs (including ?name=team%2Freport), the 403/404 errors, and calls through Confluence(url="https://test.atlassian.net"). All of them fail on master with the error above. The full pytest suite, tox -e flake8,black,mypy,bandit,doc8 pass. I haven't run it against a real Confluence Cloud site.

docs/confluence.rst documents set_page_label(page_id, label) and
remove_page_label(page_id, label), and the Server client has both, but
the Cloud client does not, so Confluence(url="https://<site>.atlassian.net")
and ConfluenceCloud raise AttributeError for them.

Add both to Cloud with the same arguments and error mapping as the
Server client. set_page_label sends POST /wiki/rest/api/content/{id}/label
with a global label, and remove_page_label sends
DELETE /wiki/rest/api/content/{id}/label?name=..., which also accepts
label names containing "/".
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.52%. Comparing base (05b9cfa) to head (27c391e).

Files with missing lines Patch % Lines
atlassian/confluence/cloud/__init__.py 81.81% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1721      +/-   ##
==========================================
+ Coverage   65.49%   65.52%   +0.03%     
==========================================
  Files         107      107              
  Lines       19440    19462      +22     
  Branches     2129     2132       +3     
==========================================
+ Hits        12732    12753      +21     
+ Misses       6001     6000       -1     
- Partials      707      709       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gonchik
gonchik merged commit f7381ca into atlassian-api:master Nov 18, 2026
11 checks passed
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.

2 participants