#![allow(missing_docs, unused_variables, trivial_casts)] extern crate openapi_client; #[allow(unused_extern_crates)] extern crate futures; #[allow(unused_extern_crates)] #[macro_use] extern crate swagger; #[allow(unused_extern_crates)] extern crate clap; extern crate tokio_core; extern crate uuid; use swagger::{ContextBuilder, EmptyContext, XSpanIdString, Has, Push, AuthData}; #[allow(unused_imports)] use futures::{Future, future, Stream, stream}; use tokio_core::reactor; #[allow(unused_imports)] use openapi_client::{ApiNoContext, ContextWrapperExt, ApiError, DataSourcesDataSourceIdEntitiesEntityIdChangesPostResponse, DataSourcesDataSourceIdSynchronizationStateGetResponse, DataSourcesGetResponse, DataSourcesPostResponse }; use clap::{App, Arg}; fn main() { let matches = App::new("client") .arg(Arg::with_name("operation") .help("Sets the operation to run") .possible_values(&[ "DataSourcesDataSourceIdEntitiesEntityIdChangesPost", "DataSourcesDataSourceIdSynchronizationStateGet", "DataSourcesGet", "DataSourcesPost", ]) .required(true) .index(1)) .arg(Arg::with_name("https") .long("https") .help("Whether to use HTTPS or not")) .arg(Arg::with_name("host") .long("host") .takes_value(true) .default_value("localhost") .help("Hostname to contact")) .arg(Arg::with_name("port") .long("port") .takes_value(true) .default_value("80") .help("Port to contact")) .get_matches(); let mut core = reactor::Core::new().unwrap(); let is_https = matches.is_present("https"); let base_url = format!("{}://{}:{}", if is_https { "https" } else { "http" }, matches.value_of("host").unwrap(), matches.value_of("port").unwrap()); let client = if matches.is_present("https") { // Using Simple HTTPS openapi_client::Client::try_new_https(core.handle(), &base_url, "examples/ca.pem") .expect("Failed to create HTTPS client") } else { // Using HTTP openapi_client::Client::try_new_http(core.handle(), &base_url) .expect("Failed to create HTTP client") }; let context: make_context_ty!(ContextBuilder, EmptyContext, Option, XSpanIdString) = make_context!(ContextBuilder, EmptyContext, None as Option, XSpanIdString(self::uuid::Uuid::new_v4().to_string())); let client = client.with_context(context); match matches.value_of("operation") { Some("DataSourcesDataSourceIdEntitiesEntityIdChangesPost") => { let result = core.run(client.data_sources_data_source_id_entities_entity_id_changes_post("data_source_id_example".to_string(), "entity_id_example".to_string(), Some(&Vec::new()))); println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); }, Some("DataSourcesDataSourceIdSynchronizationStateGet") => { let result = core.run(client.data_sources_data_source_id_synchronization_state_get("data_source_id_example".to_string())); println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); }, Some("DataSourcesGet") => { let result = core.run(client.data_sources_get()); println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); }, Some("DataSourcesPost") => { let result = core.run(client.data_sources_post(None)); println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has).get().clone()); }, _ => { panic!("Invalid operation provided") } } }