pub struct ConfluenceApi { /* private fields */ }Expand description
Confluence Cloud REST API v2 backend.
Implementations§
Source§impl ConfluenceApi
impl ConfluenceApi
Sourcepub fn new(client: AtlassianClient) -> Self
pub fn new(client: AtlassianClient) -> Self
Creates a new Confluence API backend.
Source§impl ConfluenceApi
impl ConfluenceApi
Sourcepub async fn resolve_space_id(&self, space_key: &str) -> Result<String>
pub async fn resolve_space_id(&self, space_key: &str) -> Result<String>
Resolves a space key to a space ID via the Confluence API.
Sourcepub async fn create_page(
&self,
space_key: &str,
title: &str,
body_adf: &ValidatedAdfDocument,
parent_id: Option<&str>,
) -> Result<String>
pub async fn create_page( &self, space_key: &str, title: &str, body_adf: &ValidatedAdfDocument, parent_id: Option<&str>, ) -> Result<String>
Creates a new Confluence page.
Sourcepub async fn move_page(
&self,
page_id: &str,
target_id: &str,
position: MovePosition,
) -> Result<MovedPage>
pub async fn move_page( &self, page_id: &str, target_id: &str, position: MovePosition, ) -> Result<MovedPage>
Moves or reparents a Confluence page within its current space.
Same-space only — cross-space moves are not supported by the v2 API.
Uses the v1 move endpoint (PUT /wiki/rest/api/content/{id}/move/{position}/{target}),
then re-fetches the page with ?include-ancestors=true to populate
the returned MovedPage.
Sourcepub async fn delete_page(&self, id: &str, purge: bool) -> Result<()>
pub async fn delete_page(&self, id: &str, purge: bool) -> Result<()>
Deletes a Confluence page.
Sourcepub async fn get_children(&self, page_id: &str) -> Result<Vec<ChildPage>>
pub async fn get_children(&self, page_id: &str) -> Result<Vec<ChildPage>>
Fetches all child pages of a given page, handling pagination.
Uses the v1 content API (/wiki/rest/api/content/{id}/child/page)
which is more widely supported than the v2 children endpoint.
Sourcepub async fn get_space_root_pages(
&self,
space_id: &str,
) -> Result<Vec<ChildPage>>
pub async fn get_space_root_pages( &self, space_id: &str, ) -> Result<Vec<ChildPage>>
Fetches top-level pages in a space (pages with no parent), handling pagination.
Uses the v2 API endpoint /wiki/api/v2/spaces/{space-id}/pages?depth=root.
Sourcepub async fn get_page_comments(
&self,
page_id: &str,
) -> Result<Vec<ConfluenceComment>>
pub async fn get_page_comments( &self, page_id: &str, ) -> Result<Vec<ConfluenceComment>>
Lists footer comments on a Confluence page, handling pagination.
Sourcepub async fn add_page_comment(
&self,
page_id: &str,
body_adf: &ValidatedAdfDocument,
) -> Result<()>
pub async fn add_page_comment( &self, page_id: &str, body_adf: &ValidatedAdfDocument, ) -> Result<()>
Adds a footer comment to a Confluence page.
Sourcepub async fn get_labels(&self, page_id: &str) -> Result<Vec<ConfluenceLabel>>
pub async fn get_labels(&self, page_id: &str) -> Result<Vec<ConfluenceLabel>>
Fetches all labels on a Confluence page, handling pagination.
Sourcepub async fn add_labels(&self, page_id: &str, labels: &[String]) -> Result<()>
pub async fn add_labels(&self, page_id: &str, labels: &[String]) -> Result<()>
Adds one or more labels to a Confluence page.
Sourcepub async fn remove_label(&self, page_id: &str, label_name: &str) -> Result<()>
pub async fn remove_label(&self, page_id: &str, label_name: &str) -> Result<()>
Removes a label from a Confluence page.
Sourcepub async fn get_page_metadata(&self, page_id: &str) -> Result<PageMetadata>
pub async fn get_page_metadata(&self, page_id: &str) -> Result<PageMetadata>
Fetches lightweight metadata (id, title, current version) for a page.
Cheaper than AtlassianApi::get_content because it skips the body
and the space-key lookup.
Sourcepub async fn list_page_versions(
&self,
page_id: &str,
since: Option<&SinceFilter>,
limit: u32,
) -> Result<(Vec<PageVersion>, bool)>
pub async fn list_page_versions( &self, page_id: &str, since: Option<&SinceFilter>, limit: u32, ) -> Result<(Vec<PageVersion>, bool)>
Lists version history for a Confluence page, auto-paginated.
Returns up to limit versions matching the optional since filter.
limit = 0 means unlimited. The Confluence v2 API returns versions
newest-first, so encountering a version older than since ends
pagination early.
The boolean in the return tuple is truncated: true when limit
was hit before the API was exhausted (more newer-than-since
versions exist upstream).
Sourcepub async fn upload_attachment(
&self,
page_id: &str,
file_path: &Path,
filename: Option<&str>,
comment: Option<&str>,
minor_edit: bool,
) -> Result<ConfluenceAttachment>
pub async fn upload_attachment( &self, page_id: &str, file_path: &Path, filename: Option<&str>, comment: Option<&str>, minor_edit: bool, ) -> Result<ConfluenceAttachment>
Uploads an attachment to a Confluence page from a local file path.
Streams the file body — the file is never fully buffered in memory.
Sends X-Atlassian-Token: no-check (Atlassian convention for
state-changing multipart endpoints).
Does not retry on 429: see AtlassianClient::post_multipart.
Sourcepub async fn list_attachments(
&self,
page_id: &str,
cursor: Option<&str>,
limit: u32,
) -> Result<ConfluenceAttachmentPage>
pub async fn list_attachments( &self, page_id: &str, cursor: Option<&str>, limit: u32, ) -> Result<ConfluenceAttachmentPage>
Lists attachments on a Confluence page (one page at a time).
Unlike other v2 list helpers in this module, this does not
auto-drain pagination: pass ConfluenceAttachmentPage::next_cursor
back as cursor to fetch the next page.
Sourcepub async fn delete_attachment(
&self,
attachment_id: &str,
purge: bool,
) -> Result<()>
pub async fn delete_attachment( &self, attachment_id: &str, purge: bool, ) -> Result<()>
Deletes an attachment by ID.
When purge is true, permanently purges (requires space admin);
otherwise the attachment is moved to trash.
Sourcepub async fn get_page_at_version(
&self,
id: &str,
version: u32,
) -> Result<ContentItem>
pub async fn get_page_at_version( &self, id: &str, version: u32, ) -> Result<ContentItem>
Fetches a Confluence page pinned to a specific version number.
Like AtlassianApi::get_content but returns the historical
snapshot at version rather than the current head. Used by the
version-comparison tooling to fetch each side of the diff
independently — Confluence stores versions as immutable snapshots.