Crates.io | nology-api |
lib.rs | nology-api |
version | 0.0.2 |
source | src |
created_at | 2023-02-19 13:42:39.393256 |
updated_at | 2023-02-20 05:48:18.723218 |
description | Rust API client for synology/xpenology nas |
homepage | |
repository | https://github.com/bool-rus/nology-api |
max_upload_size | |
id | 788938 |
size | 15,779 |
With some reverse-engineered Api methods
If you need to extend features, you can
use nology_api::*;
use chrono::{Utc, Duration};
async fn integration_test() -> SynoResult<()> {
let account = env::var("SYNO_USER").unwrap();
let passwd = env::var("SYNO_PASS").unwrap();
//Create service by login
let service = SynoService::login(
Default::default(),
"http://192.168.1.199:5000/webapi/entry.cgi",
LoginRequest { account, passwd }
).await?;
//retrieve last photos (or videos) for 100 days (limit 1000)
let photos = service.request(browse::ListRequest{
offset: 0,
limit: 1000,
start_time: Utc::now() - Duration::days(100),
end_time: Utc::now(),
}).await?;
//take 3 last items
let items = photos.list.into_iter().map(|bi|bi.id).take(3).collect();
//and create album with it
let new_album = service.request(album::CreateRequest {
name: format!("test-album-{}", Utc::now().timestamp()),
items,
}).await.unwrap();
log::info!("album: {new_album:?}");
Ok(())
}
You can make your own Request/Response structs, and use it in SynoService::request
by impementing trait Request