tmf-client 0.1.13

A Rust client library for TMF conformant APIs
Documentation
//! TMF620 Product Catalogue

use tmflib::tmf620::catalog::Catalog;
use tmflib::tmf620::category::Category;
use tmflib::tmf620::product_offering::ProductOffering;
use tmflib::tmf620::product_offering_price::ProductOfferingPrice;
use tmflib::tmf620::product_specification::ProductSpecification;

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, QueryOptions};

/// TMF620 Category API calls
#[derive(Clone, Debug)]
pub struct TMF620Category {
    config: Config,
}

impl TMF620Category {
    /// Create a new category reference
    pub fn new(config: Config) -> TMF620Category {
        TMF620Category { config }
    }
}

#[cfg(feature = "blocking")]
impl BlockingOperations for TMF620Category {
    type TMF = Category;

    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)
    }
    fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
        get_tmf(&self.config, id.into())
    }
    fn list(&self, filter: Option<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, patch)
    }
}

#[cfg(not(feature = "blocking"))]
impl AsyncOperations for TMF620Category {
    type TMF = Category;

    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).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<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, patch).await
    }
}

/// TMF620 Catalog API calls
#[derive(Clone, Debug)]
pub struct TMF620Catalog {
    config: Config,
}

impl TMF620Catalog {
    /// Create a new catalog reference
    pub fn new(config: Config) -> TMF620Catalog {
        TMF620Catalog { config }
    }
}

#[cfg(feature = "blocking")]
impl BlockingOperations for TMF620Catalog {
    type TMF = Catalog;

    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)
    }
    fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
        get_tmf(&self.config, id.into())
    }
    fn list(&self, filter: Option<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, patch)
    }
}

#[cfg(not(feature = "blocking"))]
impl AsyncOperations for TMF620Catalog {
    type TMF = Catalog;

    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).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<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, patch).await
    }
}

/// TMF620 ProductOffering API calls
#[derive(Clone, Debug)]
pub struct TMF620ProductOffering {
    config: Config,
}

impl TMF620ProductOffering {
    /// Create a new product_offering reference
    pub fn new(config: Config) -> TMF620ProductOffering {
        TMF620ProductOffering { config }
    }
}

#[cfg(feature = "blocking")]
impl BlockingOperations for TMF620ProductOffering {
    type TMF = ProductOffering;

    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)
    }
    fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
        get_tmf(&self.config, id.into())
    }
    fn list(&self, filter: Option<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, patch)
    }
}

#[cfg(not(feature = "blocking"))]
impl AsyncOperations for TMF620ProductOffering {
    type TMF = ProductOffering;

    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).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<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, patch).await
    }
}

/// TMF620 ProductOffering API calls
#[derive(Clone, Debug)]
pub struct TMF620ProductOfferingPrice {
    config: Config,
}

impl TMF620ProductOfferingPrice {
    /// Create a new product_offering reference
    pub fn new(config: Config) -> TMF620ProductOfferingPrice {
        TMF620ProductOfferingPrice { config }
    }
}

#[cfg(feature = "blocking")]
impl BlockingOperations for TMF620ProductOfferingPrice {
    type TMF = ProductOfferingPrice;

    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)
    }
    fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
        get_tmf(&self.config, id.into())
    }
    fn list(&self, filter: Option<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, patch)
    }
}

#[cfg(not(feature = "blocking"))]
impl AsyncOperations for TMF620ProductOfferingPrice {
    type TMF = ProductOfferingPrice;

    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).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<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, patch).await
    }
}

/// TMF620 ProductSpecification API calls
#[derive(Clone, Debug)]
pub struct TMF620ProductSpecification {
    config: Config,
}

impl TMF620ProductSpecification {
    /// Create a new product_offering reference
    pub fn new(config: Config) -> TMF620ProductSpecification {
        TMF620ProductSpecification { config }
    }
}

#[cfg(feature = "blocking")]
impl BlockingOperations for TMF620ProductSpecification {
    type TMF = ProductSpecification;

    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)
    }
    fn get(&self, id: impl Into<String>) -> Result<Vec<Self::TMF>, TMFError> {
        get_tmf(&self.config, id.into())
    }
    fn list(&self, filter: Option<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, patch)
    }
}

#[cfg(not(feature = "blocking"))]
impl AsyncOperations for TMF620ProductSpecification {
    type TMF = ProductSpecification;

    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).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<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, patch).await
    }
}

/// Product Catalogue API
#[derive(Clone, Debug)]
pub struct TMF620 {
    config: Config,
}

impl HasNew<TMF620> for TMF620 {
    fn new(config: Config) -> TMF620 {
        TMF620 { config }
    }
}

impl TMF620 {
    /// Return function for managing catalogs
    pub fn catalog(&self) -> TMF620Catalog {
        TMF620Catalog::new(self.config.clone())
    }
    /// Return function for managing categories
    pub fn category(&self) -> TMF620Category {
        TMF620Category::new(self.config.clone())
    }

    /// Return function for managing product_offering
    pub fn product_offering(&self) -> TMF620ProductOffering {
        TMF620ProductOffering::new(self.config.clone())
    }

    /// Return function for managing product_offering
    pub fn product_offering_price(&self) -> TMF620ProductOfferingPrice {
        TMF620ProductOfferingPrice::new(self.config.clone())
    }

    /// Return function for managing product_offering
    pub fn product_specification(&self) -> TMF620ProductSpecification {
        TMF620ProductSpecification::new(self.config.clone())
    }
}