1919import com .google .common .collect .ImmutableList ;
2020import com .spectralogic .ds3cli .Arguments ;
2121import com .spectralogic .ds3cli .View ;
22- import com .spectralogic .ds3cli .ViewType ;
23- import com .spectralogic .ds3cli .exceptions .BadArgumentException ;
2422import com .spectralogic .ds3cli .exceptions .CommandException ;
2523import com .spectralogic .ds3cli .models .GetBucketResult ;
26- import com .spectralogic .ds3cli .views .cli .GetBucketView ;
2724import com .spectralogic .ds3cli .views .json .DataView ;
2825import com .spectralogic .ds3client .commands .GetBucketRequest ;
2926import com .spectralogic .ds3client .commands .GetBucketResponse ;
3027import com .spectralogic .ds3client .commands .spectrads3 .GetBucketSpectraS3Request ;
3128import com .spectralogic .ds3client .commands .spectrads3 .GetBucketSpectraS3Response ;
32- import com .spectralogic .ds3client .helpers .Ds3ClientHelpers ;
3329import com .spectralogic .ds3client .models .Bucket ;
3430import com .spectralogic .ds3client .models .Contents ;
3531import com .spectralogic .ds3client .networking .FailedRequestException ;
36- import com .spectralogic .ds3client .utils .Guard ;
3732import org .apache .commons .cli .Option ;
3833
3934import java .util .List ;
4035
4136import static com .spectralogic .ds3cli .ArgumentFactory .BUCKET ;
4237import static com .spectralogic .ds3cli .ArgumentFactory .PREFIX ;
43- import static com .spectralogic .ds3cli .ArgumentFactory .VERSION ;
38+ import static com .spectralogic .ds3cli .ArgumentFactory .SHOW_VERSIONS ;
4439
4540public class GetBucket extends CliCommand <GetBucketResult > {
4641
4742 private final static ImmutableList <Option > requiredArgs = ImmutableList .of (BUCKET );
48- private final static ImmutableList <Option > optionalArgs = ImmutableList .of (PREFIX , VERSION );
43+ private final static ImmutableList <Option > optionalArgs = ImmutableList .of (PREFIX , SHOW_VERSIONS );
4944
5045 private String bucket ;
5146 private String prefix ;
52- private boolean version ;
47+ private boolean showVersion ;
5348
5449 @ Override
5550 public CliCommand init (final Arguments args ) throws Exception {
5651 processCommandOptions (requiredArgs , optionalArgs , args );
5752
5853 this .bucket = args .getBucket ();
5954 this .prefix = args .getPrefix ();
60- this .version = args .getVersion ();
55+ this .showVersion = args .isShowVersions ();
6156 return this ;
6257 }
6358
@@ -67,23 +62,23 @@ public GetBucketResult call() throws Exception {
6762 try {
6863 // GetBucketDetail to get both name and id
6964 GetBucketRequest getBucketRequest = new GetBucketRequest (bucket );
70- getBucketRequest .withVersions (version );
65+ getBucketRequest .withVersions (showVersion );
7166 getBucketRequest .withPrefix (prefix );
7267 final GetBucketSpectraS3Request getBucketSpectraS3Request = new GetBucketSpectraS3Request (bucket );
7368 final GetBucketSpectraS3Response response = getClient ().getBucketSpectraS3 (getBucketSpectraS3Request );
7469 final Bucket bucketDetails = response .getBucketResult ();
7570 final GetBucketResponse bucket = getClient ().getBucket (getBucketRequest );
7671
7772 final List <Contents > contents ;
78- if (version ) {
73+ if (showVersion ) {
7974 contents = bucket .getListBucketResult ().getVersionedObjects ();
8075 } else {
8176 contents = bucket .getListBucketResult ().getObjects ();
8277 }
8378
8479 return new GetBucketResult (bucketDetails , contents );
85- } catch (final FailedRequestException e ) {
86- if (e .getStatusCode () == 404 ) {
80+ } catch (final FailedRequestException e ) {
81+ if (e .getStatusCode () == 404 ) {
8782 throw new CommandException ("Error: Unknown bucket." , e );
8883 }
8984 throw e ;
@@ -96,7 +91,7 @@ public View<GetBucketResult> getView() {
9691 case JSON :
9792 return new DataView ();
9893 default :
99- if ( version ) {
94+ if ( showVersion ) {
10095 return new com .spectralogic .ds3cli .views .cli .GetVersionedBucketView ();
10196 } else {
10297 return new com .spectralogic .ds3cli .views .cli .GetBucketView ();
0 commit comments