Repository navigation
Confluence Cloud: run CQL search against the v1 endpoint - #1694
Open
R3gardless wants to merge 3 commits into
Open
R3gardless wants to merge 3 commits into
R3gardless wants to merge 3 commits into
Conversation
The Confluence Cloud v2 API has no search endpoint, so search(), iter_cql(), cql_all(), search_content() and get_space_content() were all calling api/v2/search, which does not exist. Point the search endpoint at v1 rest/api/search and translate the arguments to what it accepts: a free text query becomes a text ~ CQL clause (added before a trailing ORDER BY when a CQL expression is given too), excerpt=False becomes excerpt=none and body_format becomes expand=content.body.<format>.
Codacy's Prospector run flags the summary position and the Google style Raises section, so state the error behaviour in prose instead.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ConfluenceEndpoints.V2["search"]isapi/v2/search, and every search helper on the Cloud client goes through it:search(),iter_cql(),cql_all(),search_content()andget_space_content().The Confluence Cloud v2 API has no search endpoint. Atlassian's v2 OpenAPI spec (
https://dac-static.atlassian.com/cloud/confluence/openapi-v2.v3.json,info.version2.0.0) defines no path containingsearch, and CQL search is documented only under the v1 API (GET /wiki/rest/api/search). So these calls cannot succeed against Cloud today.Change
ConfluenceEndpoints.V2["search"]→rest/api/search(still served on Cloud)._search_params()now builds what the v1 endpoint accepts:query→cqlclausetext ~ "<query>"(quotes escaped);querytogether withcql→ the clause is ANDed into the expression, inserted before a trailingORDER BYso expressions built byget_space_content()stay valid;excerpt=False→excerpt=none(the v1 parameter is an enum, not a boolean);body_format→expand=content.body.<format>(v1 has nobody-formatparameter)._get_paged()keeps working: the v1 search response carries a relative_links.nextwith the cursor in its query string.Tests
tests/test_confluence_v2.py(test_search,test_search_with_cql) andtests/confluence/test_confluence_cloud.py(test_iter_cql_follows_all_result_pages,test_iter_cql_supports_text_query).test_iter_cql_combines_cql_and_text_query_before_order_byandtest_iter_cql_maps_body_format_to_expand.1753 passed, 10 skipped.Note
This is independent of #1693 (label writes), which fixes the same class of problem for
/pages/{id}/labels. Either can be merged first.