diff --git a/Cargo.lock b/Cargo.lock index 33b4a7d..ca98de9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,6 +119,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" +[[package]] +name = "futures-sink" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" + [[package]] name = "futures-task" version = "0.3.17" @@ -149,6 +155,31 @@ dependencies = [ "wasi", ] +[[package]] +name = "h2" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c06815895acec637cd6ed6e9662c935b866d20a106f8361892893a7d9234964" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -202,6 +233,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", + "h2", "http", "http-body", "httparse", @@ -228,6 +260,16 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "instant" version = "0.1.11" @@ -550,6 +592,12 @@ dependencies = [ "libc", ] +[[package]] +name = "slab" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" + [[package]] name = "smallvec" version = "1.7.0" @@ -657,6 +705,20 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-util" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + [[package]] name = "tower-service" version = "0.3.1" diff --git a/Cargo.toml b/Cargo.toml index 592d784..df92fa9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,5 @@ readme = "README.md" [dependencies] tokio = { version = "1", features = ["full"] } clap = "2.33.3" -hyper = "0.14.13" +hyper = { version = "0.14.13", features = ["full"] } hyper-tls = "0.5.0" - - diff --git a/src/main.rs b/src/main.rs index bd54808..fadbf3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use clap::{App, Arg, SubCommand}; +use subbeat::grafana_service; mod types; @@ -7,16 +8,27 @@ async fn main() -> types::Result<()> { let matches = App::new("subbeat") .version("0.0.2") .about("Timeseries toolkit") + .arg( + Arg::with_name("GRAFANA_URL") + .help("URL to your Grafana instance") + .required(true) + .index(1), + ) .arg( Arg::with_name("GRAFANA_API_KEY") .help("Grafna API Key. Go to http:///org/apikeys to get one") .required(true) - .index(1), + .index(2), ) .get_matches(); - // eyJrIjoiWnRRMTNmcGpvTHNPb3UzNzdUNUphRm53Rk9tMTNzOTQiLCJuIjoic3ViYmVhdC10ZXN0IiwiaWQiOjF9 - let input = matches.value_of("GRAFANA_API_KEY").unwrap(); + let url = matches.value_of("GRAFANA_URL").unwrap(); + let key = matches.value_of("GRAFANA_API_KEY").unwrap(); + + let gs = grafana_service::GrafanaService::new(url.to_string(), key.to_string()); + + gs.test_connection().await?; + - println!("input file for influxdb {}", input); + Ok(()) }