forked from USGCRP/gcis-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport-report.pl
More file actions
executable file
·94 lines (60 loc) · 1.86 KB
/
export-report.pl
File metadata and controls
executable file
·94 lines (60 loc) · 1.86 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env perl
use Getopt::Long qw/GetOptions/;
use Pod::Usage qw/pod2usage/;
use Gcis::Client;
use Gcis::Exim;
use YAML::XS;
use Data::Dumper;
use strict;
use v5.14;
# $YAML::XS::Indent = 4;
GetOptions(
'url=s' => \(my $url),
'log_file=s' => \(my $log_file = '/tmp/gcis-export.log'),
'log_level=s' => \(my $log_level = "info"),
'report=s' => \(my $report),
'not_all' => \(my $not_all),
);
pod2usage(-msg => "missing url", -verbose => 1) unless $url;
&main;
sub main {
my $s = shift;
my $e = Exim->new($url);
$e->not_all if $not_all;
my $logger = Mojo::Log->new($log_file eq '-' ? () : (path => $log_file));
$logger->level($log_level);
$e->logger($logger);
$e->logger_info("starting: ".$url);
my $prefix = ($report =~ /^\/report\//) ? "" : "/report/";
my $rep = $e->get("$prefix$report");
$e->get_full_report($rep->{uri});
$e->dump;
$e->logger_info('done');
}
1;
=head1 NAME
export-report.pl -- export report from gcis (in yaml)
=head1 DESCRIPTION
export-report.pl exports an entire report from gcis with all of the dependent
information. All of the internal refrences are resolved. It should be
possible to load the resulting output to another gcis instance.
The output format is yaml.
=head1 SYNOPSIS
./export-report.pl [OPTIONS]
=head1 OPTIONS
=item B<--url>
GCIS URL.
=item B<--log_file>
Log file (/tmp/gcis-export.log).
=item B<--log_level>
Log level (see Mojo::Log)
=item B<--report>
Report unique identifier
=item B<--not_all>
Set to only export first set of items (opposite of "?all=1").
=head1 EXAMPLES
./export-report.pl --url=https://datas-dev-front.joss.ucar.edu
--report=indicator-annual-change-terrestrial-carbon-sequestration-contiguous-us
./export-report.pl --url=https://data-stage.globalchange.gov
--log_level=debug --report=/report/nca3
=cut