]> git.proxmox.com Git - proxmox-backup.git/blame - src/bin/proxmox_backup_manager/dns.rs
update to first proxmox crate split
[proxmox-backup.git] / src / bin / proxmox_backup_manager / dns.rs
CommitLineData
ea6f404e
DM
1use anyhow::Error;
2use serde_json::Value;
3
6ef1b649
WB
4use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
5use proxmox_schema::api;
ea6f404e
DM
6
7use proxmox_backup::api2;
8
9#[api(
10 input: {
11 properties: {
12 "output-format": {
13 schema: OUTPUT_FORMAT,
14 optional: true,
15 },
16 }
17 }
18)]
19/// Read DNS settings
20fn get_dns(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
21
22 let output_format = get_output_format(&param);
23
24 param["node"] = "localhost".into();
25
26 let info = &api2::node::dns::API_METHOD_GET_DNS;
27 let mut data = match info.handler {
28 ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
29 _ => unreachable!(),
30 };
31
32
33 let options = default_table_format_options()
34 .column(ColumnConfig::new("search"))
35 .column(ColumnConfig::new("dns1"))
36 .column(ColumnConfig::new("dns2"))
37 .column(ColumnConfig::new("dns3"));
38
b2362a12 39 format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
ea6f404e
DM
40
41 Ok(Value::Null)
42}
43
44pub fn dns_commands() -> CommandLineInterface {
45
46 let cmd_def = CliCommandMap::new()
47 .insert(
48 "get",
49 CliCommand::new(&API_METHOD_GET_DNS)
50 )
51 .insert(
52 "set",
53 CliCommand::new(&api2::node::dns::API_METHOD_UPDATE_DNS)
54 .fixed_param("node", String::from("localhost"))
55 );
56
57 cmd_def.into()
58}