]>
git.proxmox.com Git - pmg-api.git/blob - src/PMG/CLI/pmgsubscription.pm
1 package PMG
::CLI
::pmgsubscription
;
7 use JSON
qw(decode_json);
14 use PMG
::RESTEnvironment
;
15 use PMG
::API2
::Subscription
;
17 use base
qw(PVE::CLIHandler);
19 my $nodename = PVE
::INotify
::nodename
();
21 __PACKAGE__-
>register_method({
22 name
=> 'set_offline_key',
23 path
=> 'set_offline_key',
25 description
=> "(Internal use only!) Set a signed subscription info blob as offline key",
27 additionalProperties
=> 0,
34 returns
=> { type
=> 'null' },
38 my $info = decode_json
(decode_base64
($param->{data
}));
40 $info = Proxmox
::RS
::Subscription
::check_signature
($info);
41 $info = Proxmox
::RS
::Subscription
::check_server_id
($info);
42 $info = Proxmox
::RS
::Subscription
::check_age
($info, 0);
44 PMG
::API2
::Subscription
::write_etc_subscription
($info);
47 sub setup_environment
{
48 PMG
::RESTEnvironment-
>setup_default_cli_env();
52 update
=> [ 'PMG::API2::Subscription', 'update', undef, { node
=> $nodename } ],
53 get
=> [ 'PMG::API2::Subscription', 'get', undef, { node
=> $nodename },
56 foreach my $k (sort keys %$info) {
57 print "$k: $info->{$k}\n";
60 set
=> [ 'PMG::API2::Subscription', 'set', ['key'], { node
=> $nodename } ],
61 "set-offline-key" => [ __PACKAGE__
, 'set_offline_key', ['data'] ],
62 delete => [ 'PMG::API2::Subscription', 'delete', undef, { node
=> $nodename } ],