Add Test Impl for listing Links

This commit is contained in:
Samuel Lorch 2024-01-14 23:11:26 +01:00
parent 0f9cc36dfc
commit 5d952b736b
2 changed files with 16 additions and 2 deletions

View file

@ -1,13 +1,13 @@
use super::ApiError;
use crate::{
create_thing,
definitions::network::{NetworkInterface, StaticRoute},
definitions::network::{Link, NetworkInterface, StaticRoute},
delete_thing_by_index, delete_thing_by_name, get_thing_by_index, get_thing_by_name,
list_things,
state::RpcState,
update_thing_by_index, update_thing_by_name,
};
use jsonrpsee::RpcModule;
use jsonrpsee::{types::Params, RpcModule};
pub fn register_methods(module: &mut RpcModule<RpcState>) {
module
@ -79,4 +79,13 @@ pub fn register_methods(module: &mut RpcModule<RpcState>) {
delete_thing_by_name!(network.interfaces),
)
.unwrap();
module
.register_method("network.links.list", list_network_links)
.unwrap();
}
pub fn list_network_links(_: Params, state: &RpcState) -> Result<Vec<Link>, ApiError> {
Ok(vec![Link {
name: "test1".to_string(),
}])
}

View file

@ -43,3 +43,8 @@ pub struct StaticRoute {
pub metric: u64,
pub comment: String,
}
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
pub struct Link {
pub name: String,
}