tmf_client/tmf/
tmf639.rs

1//! TMF639 Resource Inventory Management API
2
3// use tmflib::tmf637::v4::product::Product;
4use tmflib::tmf639::resource::Resource;
5
6use super::{create_tmf, delete_tmf, get_tmf, list_tmf, update_tmf};
7use crate::common::tmf_error::TMFError;
8#[cfg(not(feature = "blocking"))]
9use crate::AsyncOperations;
10#[cfg(feature = "blocking")]
11use crate::BlockingOperations;
12use crate::{Config, HasNew};
13
14/// TMF639 Resource Inventory Management API
15pub struct TMF639ResourceInventoryManagement {
16    config: Config,
17}
18
19impl TMF639ResourceInventoryManagement {
20    /// Create a new instance of the Resource Inventory Management module of TMF639 API
21    pub fn new(config: Config) -> TMF639ResourceInventoryManagement {
22        TMF639ResourceInventoryManagement { config }
23    }
24}
25
26#[cfg(feature = "blocking")]
27impl BlockingOperations for TMF639ResourceInventoryManagement {
28    type TMF = Resource;
29
30    fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
31        create_tmf(&self.config, item)
32    }
33    fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
34        delete_tmf(&self.config, id.into())
35    }
36    fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
37        get_tmf(&self.config, id.into())
38    }
39    fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
40        list_tmf(&self.config, filter)
41    }
42    fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
43        update_tmf(&self.config, id.into(), patch)
44    }
45}
46
47#[cfg(not(feature = "blocking"))]
48impl AsyncOperations for TMF639ResourceInventoryManagement {
49    type TMF = Resource;
50
51    async fn create(&self, item: Self::TMF) -> Result<Self::TMF, TMFError> {
52        create_tmf(&self.config, item).await
53    }
54    async fn delete(&self, id: impl Into<String>) -> Result<Self::TMF, TMFError> {
55        delete_tmf(&self.config, id.into()).await
56    }
57    async fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
58        get_tmf(&self.config, id.into()).await
59    }
60    async fn list(&self, filter: Option<crate::QueryOptions>) -> Result<Vec<Self::TMF>, TMFError> {
61        list_tmf(&self.config, filter).await
62    }
63    async fn update(&self, id: impl Into<String>, patch: Self::TMF) -> Result<Self::TMF, TMFError> {
64        update_tmf(&self.config, id.into(), patch).await
65    }
66}
67
68/// TMF639 API
69/// This module provides access to the Resource Inventory Management API of TMF639.
70#[derive(Clone, Default, Debug)]
71pub struct TMF639 {
72    config: Config,
73}
74
75impl HasNew<TMF639> for TMF639 {
76    fn new(config: Config) -> TMF639 {
77        TMF639 { config }
78    }
79}
80
81impl TMF639 {
82    /// Access the Product Inventory Management API
83    pub fn resource(&mut self) -> TMF639ResourceInventoryManagement {
84        super::tmf639::TMF639ResourceInventoryManagement::new(self.config.clone())
85    }
86}