Skip to main content

DiscourseClient

Struct DiscourseClient 

Source
pub struct DiscourseClient { /* private fields */ }
Expand description

HTTP client for the Discourse API.

Implementations§

Source§

impl DiscourseClient

Source

pub fn create_backup(&self) -> Result<()>

Trigger a backup on the Discourse instance.

Source

pub fn list_backups(&self) -> Result<Value>

List backups available on the Discourse instance.

Source

pub fn restore_backup(&self, backup_path: &str) -> Result<()>

Restore a backup by filename/path.

Source§

impl DiscourseClient

Source

pub fn fetch_category(&self, category_id: u64) -> Result<CategoryResponse>

Fetch a category by ID (topics list included).

Source

pub fn fetch_categories(&self) -> Result<Vec<CategoryInfo>>

Fetch all categories.

Source

pub fn create_category(&self, category: &CategoryInfo) -> Result<u64>

Create a category with basic fields copied from a source category.

Source§

impl DiscourseClient

Source

pub fn new(config: &DiscourseConfig) -> Result<Self>

Create a new Discourse API client.

Source

pub fn baseurl(&self) -> &str

Return the configured base URL.

Source

pub fn fetch_site_title(&self) -> Result<String>

Fetch the Discourse site title.

Source

pub fn fetch_version_info(&self) -> Result<VersionInfo>

Fetch the current Discourse version and commit hash.

Source

pub fn fetch_version(&self) -> Result<Option<String>>

Fetch the current Discourse version (best-effort).

Source§

impl DiscourseClient

Source

pub fn upload_emoji(&self, emoji_path: &Path, emoji_name: &str) -> Result<()>

Upload a custom emoji.

Source

pub fn list_custom_emojis(&self) -> Result<Vec<CustomEmoji>>

List custom emojis.

Source§

impl DiscourseClient

Source

pub fn fetch_groups(&self) -> Result<Vec<GroupSummary>>

Fetch all groups.

Source

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).

Source

pub fn fetch_group_members( &self, group_id: u64, group_name: Option<&str>, ) -> Result<Vec<GroupMember>>

Source

pub fn create_group(&self, group: &GroupDetail) -> Result<u64>

Create a group with detailed settings copied from a source group.

Source§

impl DiscourseClient

Source

pub fn list_color_schemes(&self) -> Result<Value>

List color schemes (palettes) available on the Discourse instance.

Source

pub fn fetch_color_scheme(&self, scheme_id: u64) -> Result<Value>

Fetch a color scheme (palette) by ID.

Source

pub fn create_color_scheme( &self, name: &str, colors: &BTreeMap<String, String>, ) -> Result<u64>

Create a new color scheme (palette).

Source

pub fn update_color_scheme( &self, scheme_id: u64, name: Option<&str>, colors: &BTreeMap<String, String>, ) -> Result<()>

Update an existing color scheme (palette).

Source§

impl DiscourseClient

Source

pub fn list_plugins(&self) -> Result<Value>

List installed plugins on the Discourse instance.

Source§

impl DiscourseClient

Source

pub fn update_site_setting(&self, setting: &str, value: &str) -> Result<()>

Update a site setting by name (admin only).

Source

pub fn list_site_settings(&self) -> Result<Value>

Fetch all site settings (admin only). Returns raw JSON value.

Source

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

Source

pub fn list_themes(&self) -> Result<Value>

List installed themes on the Discourse instance.

Source

pub fn fetch_theme(&self, theme_id: u64) -> Result<Value>

Fetch a single theme by ID.

Source

pub fn create_theme(&self, theme: &Value) -> Result<u64>

Create a new theme and return its ID.

Source

pub fn delete_theme(&self, theme_id: u64) -> Result<()>

Delete a theme by ID.

Source

pub fn update_theme(&self, theme_id: u64, theme: &Value) -> Result<()>

Update an existing theme.

Source§

impl DiscourseClient

Source

pub fn fetch_topic( &self, topic_id: u64, include_raw: bool, ) -> Result<TopicResponse>

Fetch a topic by ID.

Source

pub fn fetch_post_raw(&self, post_id: u64) -> Result<Option<String>>

Fetch a post by ID and return its raw content.

Source

pub fn update_post(&self, post_id: u64, raw: &str) -> Result<()>

Update a post by ID.

Source

pub fn create_topic( &self, category_id: u64, title: &str, raw: &str, ) -> Result<u64>

Create a new topic in a category.

Source

pub fn create_post(&self, topic_id: u64, raw: &str) -> Result<u64>

Create a reply post in a topic.

Trait Implementations§

Source§

impl Clone for DiscourseClient

Source§

fn clone(&self) -> DiscourseClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more