pub struct DiscourseClient { /* private fields */ }Expand description
HTTP client for the Discourse API.
Implementations§
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn create_backup(&self) -> Result<()>
pub fn create_backup(&self) -> Result<()>
Trigger a backup on the Discourse instance.
Sourcepub fn list_backups(&self) -> Result<Value>
pub fn list_backups(&self) -> Result<Value>
List backups available on the Discourse instance.
Sourcepub fn restore_backup(&self, backup_path: &str) -> Result<()>
pub fn restore_backup(&self, backup_path: &str) -> Result<()>
Restore a backup by filename/path.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn fetch_category(&self, category_id: u64) -> Result<CategoryResponse>
pub fn fetch_category(&self, category_id: u64) -> Result<CategoryResponse>
Fetch a category by ID (topics list included).
Sourcepub fn fetch_categories(&self) -> Result<Vec<CategoryInfo>>
pub fn fetch_categories(&self) -> Result<Vec<CategoryInfo>>
Fetch all categories.
Sourcepub fn create_category(&self, category: &CategoryInfo) -> Result<u64>
pub fn create_category(&self, category: &CategoryInfo) -> Result<u64>
Create a category with basic fields copied from a source category.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn new(config: &DiscourseConfig) -> Result<Self>
pub fn new(config: &DiscourseConfig) -> Result<Self>
Create a new Discourse API client.
Sourcepub fn fetch_site_title(&self) -> Result<String>
pub fn fetch_site_title(&self) -> Result<String>
Fetch the Discourse site title.
Sourcepub fn fetch_version_info(&self) -> Result<VersionInfo>
pub fn fetch_version_info(&self) -> Result<VersionInfo>
Fetch the current Discourse version and commit hash.
Sourcepub fn fetch_version(&self) -> Result<Option<String>>
pub fn fetch_version(&self) -> Result<Option<String>>
Fetch the current Discourse version (best-effort).
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn upload_emoji(&self, emoji_path: &Path, emoji_name: &str) -> Result<()>
pub fn upload_emoji(&self, emoji_path: &Path, emoji_name: &str) -> Result<()>
Upload a custom emoji. Retries on 429 via the shared client helper.
Sourcepub fn list_custom_emojis(&self) -> Result<Vec<CustomEmoji>>
pub fn list_custom_emojis(&self) -> Result<Vec<CustomEmoji>>
List custom emojis.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn fetch_groups(&self) -> Result<Vec<GroupSummary>>
pub fn fetch_groups(&self) -> Result<Vec<GroupSummary>>
Fetch all groups.
Sourcepub fn fetch_group_detail(
&self,
group_id: u64,
group_name: Option<&str>,
) -> Result<GroupDetail>
pub fn fetch_group_detail( &self, group_id: u64, group_name: Option<&str>, ) -> Result<GroupDetail>
Fetch group details by ID (fallbacks to name lookup if needed).
pub fn fetch_group_members( &self, group_id: u64, group_name: Option<&str>, ) -> Result<Vec<GroupMember>>
Sourcepub fn create_group(&self, group: &GroupDetail) -> Result<u64>
pub fn create_group(&self, group: &GroupDetail) -> Result<u64>
Create a group with detailed settings copied from a source group.
Sourcepub fn add_group_members_by_username(
&self,
group_id: u64,
usernames: &[String],
notify_users: bool,
) -> Result<AddMembersOutcome>
pub fn add_group_members_by_username( &self, group_id: u64, usernames: &[String], notify_users: bool, ) -> Result<AddMembersOutcome>
Add members to a group by username (PUT /groups/:id/members.json).
Sourcepub fn remove_group_members_by_username(
&self,
group_id: u64,
usernames: &[String],
) -> Result<()>
pub fn remove_group_members_by_username( &self, group_id: u64, usernames: &[String], ) -> Result<()>
Remove members from a group by username (DELETE /groups/:id/members.json).
Sourcepub fn fetch_user_groups(&self, username: &str) -> Result<Vec<GroupSummary>>
pub fn fetch_user_groups(&self, username: &str) -> Result<Vec<GroupSummary>>
Return the list of groups a user belongs to, by username.
Sourcepub fn add_group_members_by_email(
&self,
group_id: u64,
emails: &[String],
notify_users: bool,
) -> Result<AddMembersOutcome>
pub fn add_group_members_by_email( &self, group_id: u64, emails: &[String], notify_users: bool, ) -> Result<AddMembersOutcome>
Add members to a group by email (PUT /groups/:id/members.json).
Returns a tuple of (added_usernames, not_found_emails) parsed loosely from the response; both lists may be empty on success if the response doesn’t surface them.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn list_color_schemes(&self) -> Result<Value>
pub fn list_color_schemes(&self) -> Result<Value>
List color schemes (palettes) available on the Discourse instance.
Sourcepub fn fetch_color_scheme(&self, scheme_id: u64) -> Result<Value>
pub fn fetch_color_scheme(&self, scheme_id: u64) -> Result<Value>
Fetch a color scheme (palette) by ID.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn list_plugins(&self) -> Result<Value>
pub fn list_plugins(&self) -> Result<Value>
List installed plugins on the Discourse instance.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn update_site_setting(&self, setting: &str, value: &str) -> Result<()>
pub fn update_site_setting(&self, setting: &str, value: &str) -> Result<()>
Update a site setting by name (admin only).
Sourcepub fn list_site_settings(&self) -> Result<Value>
pub fn list_site_settings(&self) -> Result<Value>
Fetch all site settings (admin only). Returns raw JSON value.
Sourcepub fn fetch_site_setting(&self, setting: &str) -> Result<String>
pub fn fetch_site_setting(&self, setting: &str) -> Result<String>
Fetch a single site setting by name (admin only). Returns the value as a string, or an error if not found.
Source§impl DiscourseClient
impl DiscourseClient
List every tag visible to the authenticated user.
Fetch the current tag list for a topic.
Replace the full tag list on a topic. Returns the resulting tag set.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn list_themes(&self) -> Result<Value>
pub fn list_themes(&self) -> Result<Value>
List installed themes on the Discourse instance.
Sourcepub fn fetch_theme(&self, theme_id: u64) -> Result<Value>
pub fn fetch_theme(&self, theme_id: u64) -> Result<Value>
Fetch a single theme by ID.
Sourcepub fn create_theme(&self, theme: &Value) -> Result<u64>
pub fn create_theme(&self, theme: &Value) -> Result<u64>
Create a new theme and return its ID.
Sourcepub fn delete_theme(&self, theme_id: u64) -> Result<()>
pub fn delete_theme(&self, theme_id: u64) -> Result<()>
Delete a theme by ID.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn fetch_topic(
&self,
topic_id: u64,
include_raw: bool,
) -> Result<TopicResponse>
pub fn fetch_topic( &self, topic_id: u64, include_raw: bool, ) -> Result<TopicResponse>
Fetch a topic by ID.
Sourcepub fn fetch_post_raw(&self, post_id: u64) -> Result<Option<String>>
pub fn fetch_post_raw(&self, post_id: u64) -> Result<Option<String>>
Fetch a post by ID and return its raw content.
Sourcepub fn fetch_post(&self, post_id: u64) -> Result<PostInfo>
pub fn fetch_post(&self, post_id: u64) -> Result<PostInfo>
Fetch a post’s metadata (id, topic_id, post_number, raw).
Sourcepub fn delete_post(&self, post_id: u64) -> Result<()>
pub fn delete_post(&self, post_id: u64) -> Result<()>
Soft-delete a post by ID (DELETE /posts/:id.json).
Sourcepub fn move_posts(
&self,
source_topic_id: u64,
post_ids: &[u64],
dest_topic_id: u64,
) -> Result<String>
pub fn move_posts( &self, source_topic_id: u64, post_ids: &[u64], dest_topic_id: u64, ) -> Result<String>
Move one or more posts from their current topic to another topic.
source_topic_id is the topic the posts currently live in.
post_ids are the post IDs to move. dest_topic_id is where they land.
Returns the new URL of the moved posts’ topic.
Source§impl DiscourseClient
impl DiscourseClient
Sourcepub fn upload_file(
&self,
file_path: &Path,
upload_type: &str,
) -> Result<UploadInfo>
pub fn upload_file( &self, file_path: &Path, upload_type: &str, ) -> Result<UploadInfo>
Upload a file. upload_type is Discourse’s type field — typical
values: composer (default; for embedding in posts), avatar,
profile_background, card_background, custom_emoji.
Trait Implementations§
Source§impl Clone for DiscourseClient
impl Clone for DiscourseClient
Source§fn clone(&self) -> DiscourseClient
fn clone(&self) -> DiscourseClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more