5757 ' template_name=s' => \(my $template_name ),
5858 ' container_name=s' => \(my $container_name ),
5959 ' bookmark_name=s' => \(my $bookmark_name ),
60+ ' usefullname' => \(my $usefullname ),
6061 ' branch_name=s' => \(my $branch_name ),
6162 ' bookmark_branchname=s' => \(my $full_branchname ),
6263 ' bookmark_time=s' => \(my $bookmark_time ),
9596
9697if (lc $action eq ' create' ) {
9798
98- if (!defined ($template_name ) || (!defined ($bookmark_name ))) {
99- print " Options template_name and bookmark_name are required \n " ;
99+ if (!defined ($template_name ) || (!( defined ($bookmark_name ) ))) {
100+ print " Options template_name and bookmark_name or bookmark_prefix are required \n " ;
100101 pod2usage(-verbose => 1, -input => \*DATA );
101102 exit (1);
102103 }
126127 exit (1);
127128 }
128129
130+ if ((( lc $snapshots eq ' all' ) || ( lc $snapshots eq ' both' )) && (defined ($usefullname ))) {
131+ print " Snapshot option all or both can't run with usefullname flag \n " ;
132+ pod2usage(-verbose => 1, -input => \*DATA );
133+ exit (1);
134+ }
135+
129136 if (defined ($snapshots ) && (!defined ($source ))) {
130137 print " Option snapshot require a source to be defined \n " ;
131138 pod2usage(-verbose => 1, -input => \*DATA );
@@ -385,7 +392,7 @@ sub generate_snapshot_mapping {
385392 if ((lc $snapshots eq ' first' ) || (lc $snapshots eq ' both' )) {
386393 # find a first snapshot which can be used for bookmark ( has been taken after template was created )
387394 for my $snapitem ( @{ $snapshot -> getSnapshots() }) {
388- my $time = $snapshot -> getSnapshotCreationTime ($snapitem );
395+ my $time = $snapshot -> getStartPoint ($snapitem );
389396 my $goodtime ;
390397 if (version-> parse($engine_obj -> getApi()) < version-> parse(1.8.0)) {
391398 $goodtime = $datasources -> checkTime($datalayout_ref , $time );
@@ -396,7 +403,12 @@ sub generate_snapshot_mapping {
396403 my $timename = $time ;
397404 $timename =~ s / T/ / ;
398405 $timename =~ s /\. ...Z// ;
399- $bookmark_times_hash {$bookmark_name . ' -' . $timename } = $time ;
406+ if (defined ($usefullname )) {
407+ $timename = $bookmark_name ;
408+ } else {
409+ $timename = $bookmark_name . " -" . $timename
410+ }
411+ $bookmark_times_hash {$timename } = $time ;
400412 last ;
401413 }
402414 }
@@ -405,7 +417,7 @@ sub generate_snapshot_mapping {
405417 if ((lc $snapshots eq ' last' ) || (lc $snapshots eq ' both' )) {
406418 my $last_time = (@{ $snapshot -> getSnapshots() })[-1];
407419
408- my $time = $snapshot -> getSnapshotCreationTime ($last_time );
420+ my $time = $snapshot -> getStartPoint ($last_time );
409421 my $goodtime ;
410422 if (version-> parse($engine_obj -> getApi()) < version-> parse(1.8.0)) {
411423 $goodtime = $datasources -> checkTime($datalayout_ref , $time );
@@ -417,13 +429,18 @@ sub generate_snapshot_mapping {
417429 my $timename = $time ;
418430 $timename =~ s / T/ / ;
419431 $timename =~ s /\. ...Z// ;
420- $bookmark_times_hash {$bookmark_name . ' -' . $timename } = $time ;
432+ if (defined ($usefullname )) {
433+ $timename = $bookmark_name ;
434+ } else {
435+ $timename = $bookmark_name . " -" . $timename
436+ }
437+ $bookmark_times_hash {$timename } = $time ;
421438 }
422439 }
423440
424441 if (lc $snapshots eq ' all' ) {
425442 for my $snapitem ( @{ $snapshot -> getSnapshots() }) {
426- my $time = $snapshot -> getSnapshotCreationTime ($snapitem );
443+ my $time = $snapshot -> getStartPoint ($snapitem );
427444 my $goodtime ;
428445 if (version-> parse($engine_obj -> getApi()) < version-> parse(1.8.0)) {
429446 $goodtime = $datasources -> checkTime($datalayout_ref , $time );
@@ -458,6 +475,7 @@ =head1 SYNOPSIS
458475 [-source source_name]
459476 [-container_name container_name]
460477 [-expireat timestamp ]
478+ [-usefullname]
461479 [ --help|? ] [ -debug ]
462480
463481=head1 DESCRIPTION
@@ -507,7 +525,18 @@ =head2 Options
507525Set container for bookmark using container name
508526
509527=item B<-bookmark_name bookmark_name >
510- Set bookmark name
528+ Set bookmark name if bookmark is created using bookmark_time.
529+ When bookmarks are created using snapshot option,
530+ names will be generated using bookmark name as a prefix
531+ and snapshot time.
532+
533+ This behaviour can be modified using usefullname flag
534+
535+ =item B<-usefullname >
536+ If bookmarks are created using a snapshot last or snapshot first
537+ option, this flag will force a bookmark name to be set without
538+ adding a time of the snapshot
539+
511540
512541=item B<-bookmark_time time >
513542Set bookmark time. Allowed values:
@@ -536,14 +565,25 @@ =head2 Options
536565
537566=over 3
538567
539- =item B<-all > - create bookmarks for all snapshot of source created after template was created
568+ =item B<-all > - create bookmarks for all snapshot of source created after template was created.
569+ Bookmark names will be generated using this pattern: bookname_name-YYYY-MM-DDTHH:MI:SS.SSSZ
540570
541571=item B<-first > - create bookmark for a first snapshot of source after template was created
572+ Bookmark name will be generated using this pattern: bookname_name-YYYY-MM-DDTHH:MI:SS.SSSZ
573+ If the -usefullname parameter is used, bookmark name will be created without adding a snapshot time
542574
543575=item B<-last > - create bookmark for a last snapshot of source after template was created
576+ Bookmark name will be generated using this pattern: bookname_name-YYYY-MM-DDTHH:MI:SS.SSSZ
577+ If the -usefullname parameter is used, bookmark name will be created without adding a snapshot time
578+
579+ =item B<-both > - create bookmark for a first and last snapshot of source after template was created
580+ Bookmark names will be generated using this pattern: bookname_name-YYYY-MM-DDTHH:MI:SS.SSSZ
544581
545582=back
546583
584+ Bookmark will be created with a name following this pattern:
585+
586+
547587=item B<-expireat timestamp >
548588Set a bookmark expiration time using format "YYYY-MM-DD"
549589or "YYYY-MM-DD HH24:MI:SS"
0 commit comments