Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Cargo.lock

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

14 changes: 9 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ tmf674 = ["tmflib/tmf674"]
v4 = ["tmflib/build-V4"]
v5 = ["tmflib/build-V5"]
insecure = []
default = ["tmf620","tmf622","tmf629","tmf632","tmf633","tmf637","tmf638","tmf639","tmf645","tmf648","tmf663","tmf674","v4","insecure"]
oauth2 = ["dep:oauth2"]
default = ["tmf620","tmf622","tmf629","tmf632","tmf633","tmf637","tmf638","tmf639","tmf645","tmf648","tmf663","tmf674","v4","insecure","oauth2"]

[dependencies]
env_logger = "0.11.8"
env_logger = "0.11.5"
oauth2 = { version = "5.0.0", optional = true}
reqwest = {version = "0.12.22", features = ["blocking","rustls-tls"]}
serde = "1.0.219"
serde_json = "1.0.141"
serde = "1.0.214"
serde_json = "1.0.132"
tmflib = "0.1.22"

thiserror = "2.0.12"
tmflib = "0.1.31"

14 changes: 13 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct QueryOptions {
pub limit : Option<u16>,
/// Offset the results returned
pub offset : Option<u16>,
/// Filter on name
/// Simple filter on name field, if it exists.
pub name : Option<String>,
}

Expand Down Expand Up @@ -160,6 +160,18 @@ pub trait Operations {
/// Create a new instance of a TMF object
fn create(&self, item : Self::TMF) -> Result<Self::TMF,TMFError>;
/// Update an existing TMF Object using the provided patch object
/// Update an existing TMF object
/// ```
/// # use tmf_client::{TMFClient,Operations};
/// use tmflib::tmf620::category::Category;
/// use tmflib::{HasId,HasName};
/// let mut existing = Category::new("My Category");
/// existing.set_name("New Category Name");
/// let result = TMFClient::new("http://localhost:8080")
/// .tmf620()
/// .category()
/// .update(existing.get_id(),existing);
/// ```
fn update(&self, id : impl Into<String>, patch : Self::TMF) -> Result<Self::TMF,TMFError>;
/// Delete a specific tmf object by Id
/// ```
Expand Down
26 changes: 24 additions & 2 deletions src/tmf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@ use std::io::Read;
use crate::QueryOptions;
use crate::common::tmf_error::TMFError;
use tmflib::{HasId,Uri};
use serde::{de::DeserializeOwned, Serialize};
// use log::info;
use serde::de::DeserializeOwned;
use serde::Serialize;

#[cfg(feature = "oauth2")]
use oauth2::basic::BasicClient;

#[cfg(feature = "oauth2")]
use oauth2::{
ClientId,
ClientSecret,
AuthUrl,
TokenUrl
};

#[cfg(feature = "tmf620")]
pub mod tmf620;
Expand Down Expand Up @@ -36,6 +47,17 @@ pub mod tmf674;

static USER_AGENT : &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));

/// Get a new OAuth toekn
#[cfg(feature = "oauth2")]
pub fn get_token() {
// let _client = BasicClient::new(
// ClientId::new(std::env::var("OAUTH_CLIENT_ID").unwrap()),
// Some(ClientSecret::new(std::env::var("OAUTH_CLIENT_SECRET").unwrap())),
// AuthUrl::new(std::env::var("OAUTH_AUTH_URL").unwrap()).unwrap(),
// Some(TokenUrl::new(std::env::var("OAUTH_TOKEN_URL").unwrap()).unwrap())
// );
}

/// Make API call to retrieve a single TMF object
pub fn get_tmf<T : HasId + DeserializeOwned>(host: Uri, id : String) -> Result<Vec<T>,TMFError> {
// Return results
Expand Down