]>
git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Commands/config.pm
b4316d80550ecce889504b0b2ee5bf2a26f11c38
1 package PVE
::APIClient
::Commands
::config
;
7 use PVE
::APIClient
::Helpers
;
8 use PVE
::APIClient
::JSONSchema
qw(get_standard_option);
9 use PVE
::APIClient
::Tools
qw(extract_param);
10 use PVE
::APIClient
::Config
;
12 use PVE
::APIClient
::CLIFormatter
;
13 use PVE
::APIClient
::CLIHandler
;
15 use base
qw(PVE::APIClient::CLIHandler);
17 my $list_return_props = { %{PVE
::APIClient
::DefaultsConfig-
>updateSchema(1)->{properties
}} };
18 delete $list_return_props->{delete};
20 __PACKAGE__-
>register_method ({
24 description
=> "Dump default configuration.",
26 additionalProperties
=> 0,
31 properties
=> $list_return_props,
35 my $config = PVE
::APIClient
::Config-
>load();
37 my $defaults = PVE
::APIClient
::Config-
>get_defaults($config);
39 $defaults->{digest
} = $config->{digest
};
44 __PACKAGE__-
>register_method ({
48 description
=> "Update a remote configuration.",
49 parameters
=> PVE
::APIClient
::DefaultsConfig-
>updateSchema(1),
50 returns
=> { type
=> 'null'},
54 my $digest = extract_param
($param, 'digest');
55 my $delete = extract_param
($param, 'delete');
58 my $config = PVE
::APIClient
::Config-
>load();
60 PVE
::APIClient
::Tools
::assert_if_modified
($config->{digest
}, $digest);
62 my $defaults = PVE
::APIClient
::Config-
>get_defaults($config);
64 my $plugin = PVE
::APIClient
::Config-
>lookup('defaults');
65 my $opts = $plugin->check_config('defaults', $param, 0, 1);
67 foreach my $k (%$opts) {
68 $defaults->{$k} = $opts->{$k};
72 my $options = $plugin->private()->{options
}->{'defaults'};
73 foreach my $k (PVE
::APIClient
::Tools
::split_list
($delete)) {
74 my $d = $options->{$k} ||
75 die "no such option '$k'\n";
76 die "unable to delete required option '$k'\n"
78 die "unable to delete fixed option '$k'\n"
80 delete $defaults->{$k};
84 PVE
::APIClient
::Config-
>save($config);
87 PVE
::APIClient
::Config-
>lock_config(undef, $code);
94 set
=> [ __PACKAGE__
, 'set',],
95 list
=> [__PACKAGE__
, 'list', undef, undef,
97 my ($data, $schema, $options) = @_;
99 PVE
::APIClient
::CLIFormatter
::print_api_result
($data, $schema, undef, $options);