aboutsummaryrefslogtreecommitdiff
path: root/lib/App/Glacier/Job/InventoryRetrieval.pm
blob: e73546e8f9ddaaba34824f68e32feabb722d3bdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package App::Glacier::Job::InventoryRetrieval;
use strict;
use warnings;

use parent qw(App::Glacier::Job);
use App::Glacier::Core;
use Carp;

# new(CMD, VAULT)
sub new {
    croak "bad number of arguments" unless $#_ >= 2;
    my ($class, $cmd, $vault, %opts) = @_;
    return $class->SUPER::new(
	$cmd, $vault, $vault,
	ttl => $cmd->cfget(qw(database inv ttl)),
	%opts);
}

sub init {
    my $self = shift;
    my $jid = $self->glacier->Initiate_inventory_retrieval(
		          $self->vault,
		          'JSON',
		          "Inventory retrieval for vault ".$self->vault
              );
    if ($self->glacier->lasterr) {
	if ($self->glacier->lasterr('code') == 404) {
	    $self->command->abend(EX_TEMPFAIL,
				  $self->glacier->last_error_message
				  . "\n"
				  . "Try again later or use the --cached option to see the cached content.")
	} else {
	    $self->command->abend(EX_FAILURE,
				  "can't create job: ",
				  $self->command->lasterr('code'),
				  $self->command->last_error_message);
	}
    }
    return $jid;
}

1;

Return to:

Send suggestions and report system problems to the System administrator.