]>
git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Commands/config.pm
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
::RESTHandler
;
14 use PVE
::APIClient
::CLIHandler
;
16 use base
qw(PVE::APIClient::CLIHandler);
18 my $list_return_props = { %{PVE
::APIClient
::DefaultsConfig-
>updateSchema(1)->{properties
}} };
19 delete $list_return_props->{delete};
21 __PACKAGE__-
>register_method ({
25 description
=> "Dump default configuration.",
27 additionalProperties
=> 0,
32 properties
=> $list_return_props,
36 my $config = PVE
::APIClient
::Config-
>load();
38 my $defaults = PVE
::APIClient
::Config-
>get_defaults($config);
40 $defaults->{digest
} = $config->{digest
};
45 __PACKAGE__-
>register_method ({
49 description
=> "Update a remote configuration.",
50 parameters
=> PVE
::APIClient
::DefaultsConfig-
>updateSchema(1),
51 returns
=> { type
=> 'null'},
55 my $digest = extract_param
($param, 'digest');
56 my $delete = extract_param
($param, 'delete');
59 my $config = PVE
::APIClient
::Config-
>load();
61 PVE
::APIClient
::Tools
::assert_if_modified
($config->{digest
}, $digest);
63 my $defaults = PVE
::APIClient
::Config-
>get_defaults($config);
65 my $plugin = PVE
::APIClient
::Config-
>lookup('defaults');
66 my $opts = $plugin->check_config('defaults', $param, 0, 1);
68 foreach my $k (%$opts) {
69 $defaults->{$k} = $opts->{$k};
73 my $options = $plugin->private()->{options
}->{'defaults'};
74 foreach my $k (PVE
::APIClient
::Tools
::split_list
($delete)) {
75 my $d = $options->{$k} ||
76 die "no such option '$k'\n";
77 die "unable to delete required option '$k'\n"
79 die "unable to delete fixed option '$k'\n"
81 delete $defaults->{$k};
85 PVE
::APIClient
::Config-
>save($config);
88 PVE
::APIClient
::Config-
>lock_config(undef, $code);
95 set
=> [ __PACKAGE__
, 'set',],
96 list
=> [__PACKAGE__
, 'list', undef, undef,
98 my ($data, $schema, $options) = @_;
100 PVE
::APIClient
::CLIFormatter
::print_api_result
($data, $schema, undef, $options);
102 $PVE::APIClient
::RESTHandler
::standard_output_options
,