reactive_graph_client/client/args/
connection.rs1use clap::Parser;
2use reactive_graph_remotes_model::DEFAULT_ENDPOINT_DYNAMIC_GRAPH;
3use reactive_graph_remotes_model::DEFAULT_ENDPOINT_GRAPHQL;
4use reactive_graph_remotes_model::DEFAULT_ENDPOINT_PLUGIN;
5use reactive_graph_remotes_model::DEFAULT_ENDPOINT_RUNTIME;
6use reactive_graph_remotes_model::DEFAULT_HOSTNAME;
7use reactive_graph_remotes_model::DEFAULT_PORT;
8use reactive_graph_remotes_model::InstanceAddress;
9
10#[derive(Parser, Debug, Clone)]
11pub struct ClientConnectionArguments {
12 #[arg(long)]
14 client_hostname: Option<String>,
15
16 #[arg(long)]
18 client_port: Option<u16>,
19
20 #[arg(long)]
22 client_secure: Option<bool>,
23
24 #[arg(long)]
26 endpoint_graphql: Option<String>,
27
28 #[arg(long)]
30 endpoint_dynamic_graph: Option<String>,
31
32 #[arg(long)]
34 endpoint_runtime: Option<String>,
35
36 #[arg(long)]
38 endpoint_plugins: Option<String>,
39
40 #[arg(long)]
42 bearer: Option<String>,
43}
44
45impl From<&ClientConnectionArguments> for InstanceAddress {
46 fn from(args: &ClientConnectionArguments) -> Self {
47 InstanceAddress::builder()
48 .hostname(args.client_hostname.clone().unwrap_or(DEFAULT_HOSTNAME.to_string()))
49 .port(args.client_port.unwrap_or(DEFAULT_PORT))
50 .secure(args.client_secure.unwrap_or_default())
51 .endpoint_graphql(args.endpoint_graphql.clone().unwrap_or(DEFAULT_ENDPOINT_GRAPHQL.to_string()))
52 .endpoint_dynamic_graph(args.endpoint_dynamic_graph.clone().unwrap_or(DEFAULT_ENDPOINT_DYNAMIC_GRAPH.to_string()))
53 .endpoint_runtime(args.endpoint_runtime.clone().unwrap_or(DEFAULT_ENDPOINT_RUNTIME.to_string()))
54 .endpoint_plugin(args.endpoint_plugins.clone().unwrap_or(DEFAULT_ENDPOINT_PLUGIN.to_string()))
55 .bearer(args.bearer.clone())
56 .build()
57 }
58}