Skip to content

Commit

Permalink
Merge pull request #10 from rruckley/feat-module-tmf633-4
Browse files Browse the repository at this point in the history
feat: Module tmf633
  • Loading branch information
rruckley authored Jan 22, 2025
2 parents 5edc1dd + 01976fc commit b314c42
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 13 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.5.26", features = ["derive"]}
clap = { version = "4.5.27", features = ["derive"]}
env_logger = "0.11.6"
log = "0.4.25"
tmf-client = "0.1.4"
tmf-client = "0.1.5"
# tmf-client = { git = "https://github.com/rruckley/tmf-client.git" }
tmflib = "0.1.24"
tmflib = "0.1.25"
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ use tmf::tmf629::{
TMF629Modules,
handle_tmf629,
};
use tmf::tmf633::{
TMF633Modules,
handle_tmf633,
};
use tmf::tmf648::{
TMF648Modules,
handle_tmf648,
Expand Down Expand Up @@ -70,6 +74,10 @@ pub enum TMFModules {
#[command(subcommand, help = "Party")]
module : TMF632Modules,
},
TMF633 {
#[command(subcommand, help = "Service Catalog")]
module : TMF633Modules,
},
TMF648 {
#[command(subcommand, help = "Product Quote")]
module : TMF648Modules,
Expand Down Expand Up @@ -123,6 +131,9 @@ fn main() -> Result<(),TMFError> {
TMFModules::TMF632 { module } => {
handle_tmf632(&mut client, module, Some(opts))
},
TMFModules::TMF633 { module } => {
handle_tmf633(&mut client, module, Some(opts))
},
TMFModules::TMF648 { module } => {
handle_tmf648(&mut client, module, Some(opts))
},
Expand Down
1 change: 1 addition & 0 deletions src/tmf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod tmf620;
pub mod tmf622;
pub mod tmf629;
pub mod tmf632;
pub mod tmf633;
pub mod tmf648;
pub mod tmf674;

Expand Down
112 changes: 112 additions & 0 deletions src/tmf/tmf633.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
//! TMF633 CLI Module
//! TMF620 CLI Module
use clap::Subcommand;

use super::{
display_desc, display_name, iterate_name, TMFOperation
};

use tmf_client::common::tmf_error::TMFError;
use tmf_client::{Operations, QueryOptions, TMFClient};

#[derive(Subcommand, Clone, Debug)]
pub enum TMF633Modules {
Catalog {
#[command(subcommand, help = "Catalog Operations")]
op : TMFOperation
},
Category {
#[command(subcommand, help = "Category Operations")]
op : TMFOperation
},
Candidate {
#[command(subcommand, help = "Service Cadidate Operations")]
op : TMFOperation

},
Specification {
#[command(subcommand, help = "Product Specification Operations")]
op : TMFOperation

},
}

pub fn handle_tmf633(client : &mut TMFClient, module : TMF633Modules, opts : Option<QueryOptions>) -> Result<(),TMFError> {
match module {
TMF633Modules::Catalog { op } => {
match op {
TMFOperation::List => {
let catalogs = client.tmf633().catalog().list(opts)?;
iterate_name(&catalogs);
Ok(())
},
TMFOperation::Get { id } => {
let catalog = client.tmf633().catalog().get(id)?;
let the_first = catalog.first().unwrap();
display_name(the_first);
Ok(())
},
_ => {
Err(TMFError::from("Not implemented"))
}
}
},
TMF633Modules::Category { op } => {
match op {
TMFOperation::List => {
let categories = client.tmf633().category().list(opts)?;
iterate_name(&categories);
Ok(())
},
TMFOperation::Get { id } => {
let category = client.tmf633().category().get(id)?;
let the_first = category.first().unwrap();
display_name(the_first);
Ok(())
},
_ => {
Err(TMFError::from("Not implemented"))
}
}
},
TMF633Modules::Candidate { op } => {
match op {
TMFOperation::List => {
let candidates = client.tmf633().candidate().list(opts)?;
iterate_name(&candidates);
Ok(())
},
TMFOperation::Get { id } => {
let candidate = client.tmf633().candidate().get(id)?;
let the_first = candidate.first().unwrap();
display_name(the_first);
Ok(())
}
_ => {
Err(TMFError::from("Not implemented"))
}
}
},
TMF633Modules::Specification { op } => {
match op {
TMFOperation::List => {
let specifications = client.tmf633().specification().list(opts)?;
iterate_name(&specifications);
Ok(())
},
TMFOperation::Get { id } => {
let specification = client.tmf633().specification().get(id)?;
let the_first = specification.first().unwrap();
display_desc(the_first);
Ok(())
}
_ => {
Err(TMFError::from("Not implemented"))
}

}
},
}
}

0 comments on commit b314c42

Please sign in to comment.