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 #[arg(long)]
54 danger_accept_invalid_certs: Option<bool>,
55
56 danger_accept_invalid_hostnames: Option<bool>,
65}
66
67impl From<&ClientConnectionArguments> for InstanceAddress {
68 fn from(args: &ClientConnectionArguments) -> Self {
69 InstanceAddress::builder()
70 .hostname(args.client_hostname.clone().unwrap_or(DEFAULT_HOSTNAME.to_string()))
71 .port(args.client_port.unwrap_or(DEFAULT_PORT))
72 .secure(args.client_secure.unwrap_or_default())
73 .endpoint_graphql(args.endpoint_graphql.clone().unwrap_or(DEFAULT_ENDPOINT_GRAPHQL.to_string()))
74 .endpoint_dynamic_graph(args.endpoint_dynamic_graph.clone().unwrap_or(DEFAULT_ENDPOINT_DYNAMIC_GRAPH.to_string()))
75 .endpoint_runtime(args.endpoint_runtime.clone().unwrap_or(DEFAULT_ENDPOINT_RUNTIME.to_string()))
76 .endpoint_plugin(args.endpoint_plugins.clone().unwrap_or(DEFAULT_ENDPOINT_PLUGIN.to_string()))
77 .bearer(args.bearer.clone())
78 .danger_accept_invalid_certs(args.danger_accept_invalid_certs)
79 .danger_accept_invalid_hostnames(args.danger_accept_invalid_hostnames)
80 .build()
81 }
82}