pub struct BehaviorHandler { /* private fields */ }
Expand description
Handler for behavior operations
Implementations§
Source§impl BehaviorHandler
impl BehaviorHandler
Sourcepub fn new(client: FilesClient) -> Self
pub fn new(client: FilesClient) -> Self
Create a new behavior handler
Sourcepub async fn list(
&self,
cursor: Option<&str>,
per_page: Option<i64>,
sort_by: Option<Value>,
filter: Option<Value>,
filter_prefix: Option<&str>,
) -> Result<(Vec<BehaviorEntity>, PaginationInfo)>
pub async fn list( &self, cursor: Option<&str>, per_page: Option<i64>, sort_by: Option<Value>, filter: Option<Value>, filter_prefix: Option<&str>, ) -> Result<(Vec<BehaviorEntity>, PaginationInfo)>
List behaviors
§Arguments
cursor
- Pagination cursorper_page
- Results per pagesort_by
- Sort field and directionfilter
- Filter criteriafilter_prefix
- Filter by path prefix
§Returns
Tuple of (behaviors, pagination_info)
§Example
use files_sdk::{FilesClient, BehaviorHandler};
let client = FilesClient::builder().api_key("key").build()?;
let handler = BehaviorHandler::new(client);
let (behaviors, _) = handler.list(None, None, None, None, None).await?;
Sourcepub async fn list_for_folder(
&self,
path: &str,
cursor: Option<&str>,
per_page: Option<i64>,
) -> Result<(Vec<BehaviorEntity>, PaginationInfo)>
pub async fn list_for_folder( &self, path: &str, cursor: Option<&str>, per_page: Option<i64>, ) -> Result<(Vec<BehaviorEntity>, PaginationInfo)>
Sourcepub async fn get(&self, id: i64) -> Result<BehaviorEntity>
pub async fn get(&self, id: i64) -> Result<BehaviorEntity>
Sourcepub async fn create(
&self,
path: &str,
behavior: &str,
value: Option<Value>,
name: Option<&str>,
recursive: Option<bool>,
) -> Result<BehaviorEntity>
pub async fn create( &self, path: &str, behavior: &str, value: Option<Value>, name: Option<&str>, recursive: Option<bool>, ) -> Result<BehaviorEntity>
Create a new behavior
§Arguments
path
- Folder path (required)behavior
- Behavior type (required)value
- Behavior configuration valuename
- Behavior namerecursive
- Apply recursively
§Returns
The created behavior
§Example
use files_sdk::{FilesClient, BehaviorHandler};
use serde_json::json;
let client = FilesClient::builder().api_key("key").build()?;
let handler = BehaviorHandler::new(client);
let webhook_config = json!({"urls": ["https://example.com/hook"]});
let behavior = handler.create(
"/uploads",
"webhook",
Some(webhook_config),
Some("Upload Webhook"),
Some(true)
).await?;
Sourcepub async fn update(
&self,
id: i64,
value: Option<Value>,
name: Option<&str>,
disable_parent_folder_behavior: Option<bool>,
) -> Result<BehaviorEntity>
pub async fn update( &self, id: i64, value: Option<Value>, name: Option<&str>, disable_parent_folder_behavior: Option<bool>, ) -> Result<BehaviorEntity>
Auto Trait Implementations§
impl Freeze for BehaviorHandler
impl !RefUnwindSafe for BehaviorHandler
impl Send for BehaviorHandler
impl Sync for BehaviorHandler
impl Unpin for BehaviorHandler
impl !UnwindSafe for BehaviorHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more