use tmflib::tmf638::service::Service;
use super::{create_tmf, delete_tmf, get_tmf, list_tmf, update_tmf};
use crate::common::tmf_error::TMFError;
#[cfg(not(feature = "blocking"))]
use crate::AsyncOperations;
#[cfg(feature = "blocking")]
use crate::BlockingOperations;
use crate::{Config, HasNew};
pub struct TMF638ServiceInventoryManagement {
config: Config,
}
impl TMF638ServiceInventoryManagement {
pub fn new(config: Config) -> TMF638ServiceInventoryManagement {
TMF638ServiceInventoryManagement { config }
}
}
#[cfg(feature = "blocking")]
impl BlockingOperations for TMF638ServiceInventoryManagement {
type TMF = Service;
fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
create_tmf(&self.config, item)
}
fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
delete_tmf(&self.config, id.into())
}
fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
get_tmf(&self.config, id.into())
}
fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
list_tmf(&self.config, filter)
}
fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
update_tmf(&self.config, id.into(), patch)
}
}
#[cfg(not(feature = "blocking"))]
impl AsyncOperations for TMF638ServiceInventoryManagement {
type TMF = Service;
async fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
create_tmf(&self.config, item).await
}
async fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
delete_tmf(&self.config, id.into()).await
}
async fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
get_tmf(&self.config, id.into()).await
}
async fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
list_tmf(&self.config, filter).await
}
async fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
update_tmf(&self.config, id.into(), patch).await
}
}
#[derive(Clone, Default, Debug)]
pub struct TMF638 {
config: Config,
}
impl HasNew<TMF638> for TMF638 {
fn new(config: Config) -> TMF638 {
TMF638 { config }
}
}
impl TMF638 {
pub fn service(&mut self) -> TMF638ServiceInventoryManagement {
super::tmf638::TMF638ServiceInventoryManagement::new(self.config.clone())
}
}