node => get_standard_option('pve-node'),
},
},
- returns => {
+ returns => {
type => "array",
items => {
type => "object",
},
},
},
+ links => [ { rel => 'child', href => "{filename}" } ],
},
code => sub {
my ($param) = @_;
statistic => $include_statistic_property,
},
},
- returns => { type => "string" },
+ returns => { type => "string" },
code => sub {
my ($param) = @_;
return $rpcenv->fork_worker('backup', undef, $authuser, $worker);
}});
+__PACKAGE__->register_method ({
+ name => 'download',
+ path => '{filename}',
+ method => 'GET',
+ description => "Download a backup file.",
+ permissions => { check => [ 'admin' ] },
+ proxyto => 'node',
+ protected => 1,
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ filename => $backup_filename_property,
+ },
+ },
+ download => 1,
+ returns => { type => "string" },
+ code => sub {
+ my ($param) = @_;
+
+ my $filename = "${backup_dir}/$param->{filename}";
+
+ return $filename;
+ }});
+
__PACKAGE__->register_method ({
name => 'delete',
path => '{filename}',
my $class = ref($this) || $this;
my $self = $class->SUPER::new(%args);
-
+
$self->{rpcenv} = PMG::RESTEnvironment->init(
$self->{trusted_env} ? 'priv' : 'pub', atfork => sub { $self->atfork_handler() });
}
}
+
+ my $result = $handler->handle($info, $uri_param);
+
$resp = {
- data => $handler->handle($info, $uri_param),
info => $info, # useful to format output
status => HTTP_OK,
};
+ if ($info->{download}) {
+ die "download methods should have return type 'string' - internal error"
+ if ($info->{returns}->{type} ne 'string');
+ $resp->{download} = $result;
+ } else {
+ $resp->{data} = $result;
+ }
+
if (my $count = $rpcenv->get_result_attrib('total')) {
$resp->{total} = $count;
}