From 407af366bb6e7d55e0221195422a3a5ae5c04a30 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 8 Feb 2024 23:18:37 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20post-p?= =?UTF-8?q?rocessor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 6 ++-- .../java/com/google/cloud/storage/Bucket.java | 7 ++-- .../com/google/cloud/storage/BucketInfo.java | 21 ++++++------ .../google/cloud/storage/GrpcConversions.java | 14 ++++---- .../google/cloud/storage/GrpcStorageImpl.java | 22 ++++++------ .../storage/HttpRetryAlgorithmManager.java | 3 +- .../google/cloud/storage/JsonConversions.java | 13 ++++--- .../com/google/cloud/storage/Storage.java | 18 +++++----- .../com/google/cloud/storage/StorageImpl.java | 18 +++++----- .../com/google/cloud/storage/UnifiedOpts.java | 9 +++-- .../cloud/storage/spi/v1/HttpStorageRpc.java | 25 ++++++++------ .../google/cloud/storage/it/ITBucketTest.java | 34 +++++++++++++------ .../it/runner/registry/StorageInstance.java | 2 -- 13 files changed, 105 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 6d2bb70810..5eba4f7b3c 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-storage' If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-storage:2.32.1' +implementation 'com.google.cloud:google-cloud-storage:2.33.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "2.32.1" +libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "2.33.0" ``` @@ -428,7 +428,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-storage/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-storage.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-storage/2.32.1 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-storage/2.33.0 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java index c0e01c5ea5..2332a223df 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java @@ -1090,9 +1090,10 @@ public Blob get(String blob, BlobGetOption... options) { } /** - * Returns the requested blob in this bucket of a specific generation or {@code null} if not found. + * Returns the requested blob in this bucket of a specific generation or {@code null} if not + * found. * - *

Example of getting a blob of a specific in the bucket. + *

Example of getting a blob of a specific in the bucket. * *

{@code
    * String blobName = "my_blob_name";
@@ -1106,7 +1107,7 @@ public Blob get(String blob, BlobGetOption... options) {
    * @throws StorageException upon failure
    */
   @TransportCompatibility({Transport.HTTP, Transport.GRPC})
-  public Blob get(String blob, Long generation, BlobGetOption...options) {
+  public Blob get(String blob, Long generation, BlobGetOption... options) {
     return storage.get(BlobId.of(getName(), blob, generation), options);
   }
 
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java
index 4ae2707a39..5512ee0d71 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java
@@ -371,7 +371,7 @@ public boolean equals(Object o) {
       }
       SoftDeletePolicy that = (SoftDeletePolicy) o;
       return Objects.equals(retentionDuration, that.retentionDuration)
-              && Objects.equals(effectiveTime, that.effectiveTime);
+          && Objects.equals(effectiveTime, that.effectiveTime);
     }
 
     @Override
@@ -379,11 +379,12 @@ public int hashCode() {
       return Objects.hash(retentionDuration, effectiveTime);
     }
 
-    @Override public String toString() {
+    @Override
+    public String toString() {
       return MoreObjects.toStringHelper(this)
-              .add("retentionDuration", retentionDuration)
-              .add("effectiveTime", effectiveTime)
-              .toString();
+          .add("retentionDuration", retentionDuration)
+          .add("effectiveTime", effectiveTime)
+          .toString();
     }
 
     public static Builder newBuilder() {
@@ -413,17 +414,15 @@ public static final class Builder {
       private Duration retentionDuration;
       private OffsetDateTime effectiveTime;
 
-      /**
-       * Sets the length of time to retain soft-deleted objects for, expressed as a Duration
-       */
+      /** Sets the length of time to retain soft-deleted objects for, expressed as a Duration */
       public Builder setRetentionDuration(Duration retentionDuration) {
         this.retentionDuration = retentionDuration;
         return this;
       }
 
       /**
-       * Sets the time from which this soft-delete policy is effective.
-       * This is package-private because it can only be set by the backend.
+       * Sets the time from which this soft-delete policy is effective. This is package-private
+       * because it can only be set by the backend.
        */
       Builder setEffectiveTime(OffsetDateTime effectiveTime) {
         this.effectiveTime = effectiveTime;
@@ -2281,7 +2280,7 @@ Builder setObjectRetention(ObjectRetention objectRetention) {
 
     @Override
     public Builder setSoftDeletePolicy(SoftDeletePolicy softDeletePolicy) {
-      if(!Objects.equals(this.softDeletePolicy, softDeletePolicy)) {
+      if (!Objects.equals(this.softDeletePolicy, softDeletePolicy)) {
         modifiedFields.add(BucketField.SOFT_DELETE_POLICY);
       }
       this.softDeletePolicy = softDeletePolicy;
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcConversions.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcConversions.java
index 5939b010f9..a00b52123a 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcConversions.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcConversions.java
@@ -16,7 +16,9 @@
 
 package com.google.cloud.storage;
 
-import com.google.api.client.util.Data;
+import static com.google.cloud.storage.Storage.BucketField.SOFT_DELETE_POLICY;
+import static com.google.cloud.storage.Utils.*;
+
 import com.google.api.pathtemplate.PathTemplate;
 import com.google.cloud.Binding;
 import com.google.cloud.Condition;
@@ -65,9 +67,6 @@
 import java.util.Map;
 import java.util.function.Function;
 
-import static com.google.cloud.storage.Storage.BucketField.SOFT_DELETE_POLICY;
-import static com.google.cloud.storage.Utils.*;
-
 final class GrpcConversions {
   static final GrpcConversions INSTANCE = new GrpcConversions();
 
@@ -90,7 +89,7 @@ final class GrpcConversions {
       Codec.of(this::autoclassEncode, this::autoclassDecode);
 
   private final Codec softDeletePolicyCodec =
-          Codec.of(this::softDeletePolicyEncode, this::softDeletePolicyDecode);
+      Codec.of(this::softDeletePolicyEncode, this::softDeletePolicyDecode);
   private final Codec lifecycleRuleCodec =
       Codec.of(this::lifecycleRuleEncode, this::lifecycleRuleDecode);
   private final Codec bucketInfoCodec =
@@ -291,7 +290,7 @@ private BucketInfo bucketInfoDecode(Bucket from) {
     if (from.hasAutoclass()) {
       to.setAutoclass(autoclassCodec.decode(from.getAutoclass()));
     }
-    if(from.hasSoftDeletePolicy()) {
+    if (from.hasSoftDeletePolicy()) {
       to.setSoftDeletePolicy(softDeletePolicyCodec.decode(from.getSoftDeletePolicy()));
     }
     if (from.hasCustomPlacementConfig()) {
@@ -380,7 +379,8 @@ private Bucket bucketInfoEncode(BucketInfo from) {
     ifNonNull(from.getIamConfiguration(), iamConfigurationCodec::encode, to::setIamConfig);
     ifNonNull(from.getAutoclass(), autoclassCodec::encode, to::setAutoclass);
     ifNonNull(from.getSoftDeletePolicy(), softDeletePolicyCodec::encode, to::setSoftDeletePolicy);
-    if(from.getModifiedFields().contains(SOFT_DELETE_POLICY) && from.getSoftDeletePolicy() == null) {
+    if (from.getModifiedFields().contains(SOFT_DELETE_POLICY)
+        && from.getSoftDeletePolicy() == null) {
       System.out.println("this is happening");
       System.out.println(Bucket.SoftDeletePolicy.getDefaultInstance().toString());
       to.clearSoftDeletePolicy();
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
index cd9ff3502c..7c213c23ba 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
@@ -412,22 +412,22 @@ public Blob restore(BlobId blob, BlobRestoreOption... options) {
   private Blob internalObjectRestore(BlobId blobId, Opts opts) {
     Opts finalOpts = opts.prepend(defaultOpts).prepend(ALL_BLOB_FIELDS);
     GrpcCallContext grpcCallContext =
-            finalOpts.grpcMetadataMapper().apply(GrpcCallContext.createDefault());
+        finalOpts.grpcMetadataMapper().apply(GrpcCallContext.createDefault());
     RestoreObjectRequest.Builder builder =
-            RestoreObjectRequest.newBuilder()
-                    .setBucket(bucketNameCodec.encode(blobId.getBucket()))
-                    .setObject(blobId.getName());
+        RestoreObjectRequest.newBuilder()
+            .setBucket(bucketNameCodec.encode(blobId.getBucket()))
+            .setObject(blobId.getName());
     ifNonNull(blobId.getGeneration(), builder::setGeneration);
     RestoreObjectRequest req = finalOpts.restoreObjectRequest().apply(builder).build();
     GrpcCallContext merge = Utils.merge(grpcCallContext, Retrying.newCallContext());
     return Retrying.run(
-            getOptions(),
-            retryAlgorithmManager.getFor(req),
-            () -> storageClient.restoreObjectCallable().call(req, merge),
-            resp -> {
-              BlobInfo tmp = codecs.blobInfo().decode(resp);
-              return finalOpts.clearBlobFields().decode(tmp).asBlob(this);
-            });
+        getOptions(),
+        retryAlgorithmManager.getFor(req),
+        () -> storageClient.restoreObjectCallable().call(req, merge),
+        resp -> {
+          BlobInfo tmp = codecs.blobInfo().decode(resp);
+          return finalOpts.clearBlobFields().decode(tmp).asBlob(this);
+        });
   }
 
   @Override
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpRetryAlgorithmManager.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpRetryAlgorithmManager.java
index 0d3890af06..c5163ad00f 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpRetryAlgorithmManager.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpRetryAlgorithmManager.java
@@ -213,7 +213,8 @@ public ResultRetryAlgorithm getForObjectsGet(
     return retryStrategy.getIdempotentHandler();
   }
 
-  public ResultRetryAlgorithm getForObjectsRestore(StorageObject pb, Map optionsMap) {
+  public ResultRetryAlgorithm getForObjectsRestore(
+      StorageObject pb, Map optionsMap) {
     return retryStrategy.getIdempotentHandler();
   }
 
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/JsonConversions.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/JsonConversions.java
index 68518148ba..69f23e16b5 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/JsonConversions.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/JsonConversions.java
@@ -66,8 +66,8 @@
 import com.google.cloud.storage.BucketInfo.LifecycleRule.SetStorageClassLifecycleAction;
 import com.google.cloud.storage.BucketInfo.Logging;
 import com.google.cloud.storage.BucketInfo.ObjectRetention;
-import com.google.cloud.storage.BucketInfo.SoftDeletePolicy;
 import com.google.cloud.storage.BucketInfo.PublicAccessPrevention;
+import com.google.cloud.storage.BucketInfo.SoftDeletePolicy;
 import com.google.cloud.storage.Conversions.Codec;
 import com.google.cloud.storage.Cors.Origin;
 import com.google.cloud.storage.HmacKey.HmacKeyMetadata;
@@ -123,7 +123,7 @@ final class JsonConversions {
       Codec.of(this::objectRetentionEncode, this::objectRetentionDecode);
 
   private final Codec softDeletePolicyCodec =
-          Codec.of(this::softDeletePolicyEncode, this::softDeletePolicyDecode);
+      Codec.of(this::softDeletePolicyEncode, this::softDeletePolicyDecode);
   private final Codec lifecycleRuleCodec =
       Codec.of(this::lifecycleRuleEncode, this::lifecycleRuleDecode);
   private final Codec lifecycleConditionCodec =
@@ -374,13 +374,15 @@ private Retention retentionDecode(StorageObject.Retention from) {
 
   private Bucket.SoftDeletePolicy softDeletePolicyEncode(SoftDeletePolicy from) {
     Bucket.SoftDeletePolicy to = new Bucket.SoftDeletePolicy();
-    ifNonNull(from.getRetentionDuration(), durationSecondsCodec::encode, to::setRetentionDurationSeconds);
+    ifNonNull(
+        from.getRetentionDuration(), durationSecondsCodec::encode, to::setRetentionDurationSeconds);
     return to;
   }
 
   private SoftDeletePolicy softDeletePolicyDecode(Bucket.SoftDeletePolicy from) {
     SoftDeletePolicy.Builder to = SoftDeletePolicy.newBuilder();
-    ifNonNull(from.getRetentionDurationSeconds(), durationSecondsCodec::decode, to::setRetentionDuration);
+    ifNonNull(
+        from.getRetentionDurationSeconds(), durationSecondsCodec::decode, to::setRetentionDuration);
     ifNonNull(from.getEffectiveTime(), dateTimeCodec::decode, to::setEffectiveTime);
     return to.build();
   }
@@ -456,7 +458,8 @@ private Bucket bucketInfoEncode(BucketInfo from) {
         to::setCustomPlacementConfig);
     ifNonNull(from.getObjectRetention(), this::objectRetentionEncode, to::setObjectRetention);
     ifNonNull(from.getSoftDeletePolicy(), this::softDeletePolicyEncode, to::setSoftDeletePolicy);
-    if(from.getSoftDeletePolicy() == null && from.getModifiedFields().contains(SOFT_DELETE_POLICY)) {
+    if (from.getSoftDeletePolicy() == null
+        && from.getModifiedFields().contains(SOFT_DELETE_POLICY)) {
       to.setSoftDeletePolicy(Data.nullOf(Bucket.SoftDeletePolicy.class));
     }
     return to;
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java
index 8baa8215d1..4f6ed5b3a5 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java
@@ -1574,8 +1574,8 @@ public static BlobGetOption shouldReturnRawInputStream(boolean shouldReturnRawIn
 
     /**
      * Returns an option for whether the request should return a soft-deleted object. If an object
-     * has been soft-deleted (Deleted while a Soft Delete Policy) is in place, this must be true
-     * or the request will return null.
+     * has been soft-deleted (Deleted while a Soft Delete Policy) is in place, this must be true or
+     * the request will return null.
      */
     @TransportCompatibility({Transport.HTTP, Transport.GRPC})
     public static BlobGetOption softDeleted(boolean softDeleted) {
@@ -1617,7 +1617,7 @@ public static BlobGetOption[] dedupe(BlobGetOption[] array, BlobGetOption... os)
     }
   }
 
-  /** Class for specifying blob restore options **/
+  /** Class for specifying blob restore options * */
   class BlobRestoreOption extends Option {
 
     private static final long serialVersionUID = 1922118465380110958L;
@@ -1626,7 +1626,6 @@ class BlobRestoreOption extends Option {
       super(opt);
     }
 
-
     /**
      * Returns an option for blob's data generation match. If this option is used the request will
      * fail if generation does not match.
@@ -1664,7 +1663,8 @@ public static BlobRestoreOption metagenerationNotMatch(long generation) {
     }
 
     /**
-     * Returns an option for whether the restored object should copy the access controls of the source object.
+     * Returns an option for whether the restored object should copy the access controls of the
+     * source object.
      */
     @TransportCompatibility({Transport.HTTP, Transport.GRPC})
     public static BlobRestoreOption copySourceAcl(boolean copySourceAcl) {
@@ -1895,9 +1895,7 @@ public static BlobListOption fields(BlobField... fields) {
       return new BlobListOption(UnifiedOpts.fields(set));
     }
 
-    /**
-     * Returns an option for whether the list result should include soft-deleted objects.
-     */
+    /** Returns an option for whether the list result should include soft-deleted objects. */
     @TransportCompatibility({Transport.HTTP, Transport.GRPC})
     public static BlobListOption softDeleted(boolean softDeleted) {
       return new BlobListOption(UnifiedOpts.softDeleted(softDeleted));
@@ -3109,8 +3107,8 @@ Blob createFrom(
   Blob get(BlobId blob);
 
   /**
-   * Restores a soft-deleted object to full object status and returns the object.
-   * Note that you must specify a generation to use this method.
+   * Restores a soft-deleted object to full object status and returns the object. Note that you must
+   * specify a generation to use this method.
    *
    * 

Example of restoring an object. * diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java index 4f4ec09300..a5df68b832 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java @@ -340,23 +340,23 @@ public Blob get(BlobId blob, BlobGetOption... options) { public Blob get(BlobId blob) { return get(blob, new BlobGetOption[0]); } + @Override public Blob restore(BlobId blob, BlobRestoreOption... options) { ImmutableMap optionsMap = - Opts.unwrap(options).resolveFrom(blob).getRpcOptions(); + Opts.unwrap(options).resolveFrom(blob).getRpcOptions(); StorageObject obj = codecs.blobId().encode(blob); - ResultRetryAlgorithm algorithm = - retryAlgorithmManager.getForObjectsRestore(obj, optionsMap); + ResultRetryAlgorithm algorithm = retryAlgorithmManager.getForObjectsRestore(obj, optionsMap); return run( - algorithm, - () -> storageRpc.restore(obj, optionsMap), - (x) -> { - BlobInfo info = Conversions.json().blobInfo().decode(x); - return info.asBlob(this); - }); + algorithm, + () -> storageRpc.restore(obj, optionsMap), + (x) -> { + BlobInfo info = Conversions.json().blobInfo().decode(x); + return info.asBlob(this); + }); } private static class BucketPageFetcher implements NextPageFetcher { diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/UnifiedOpts.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/UnifiedOpts.java index 3e22538193..d1eaab459b 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/UnifiedOpts.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/UnifiedOpts.java @@ -481,9 +481,11 @@ static Projection projection(@NonNull String projection) { static SoftDeleted softDeleted(boolean softDeleted) { return new SoftDeleted(softDeleted); } + static CopySourceAcl copySourceAcl(boolean copySourceAcl) { return new CopySourceAcl(copySourceAcl); } + static RequestedPolicyVersion requestedPolicyVersion(long l) { return new RequestedPolicyVersion(l); } @@ -655,7 +657,8 @@ public Mapper listObjects() { } } - static final class SoftDeleted extends RpcOptVal implements ObjectListOpt, ObjectSourceOpt { + static final class SoftDeleted extends RpcOptVal + implements ObjectListOpt, ObjectSourceOpt { private static final long serialVersionUID = -8526951678111463350L; @@ -1030,8 +1033,8 @@ public Mapper getObject() { } @Override - public Mapper restoreObject() { - return b-> b.setIfGenerationMatch(val); + public Mapper restoreObject() { + return b -> b.setIfGenerationMatch(val); } @Override diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java index 5f6d0d5f88..680d20acfb 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java @@ -543,7 +543,7 @@ private Storage.Objects.Get getCall(StorageObject object, Map options .setFields(Option.FIELDS.getString(options)) .setUserProject(Option.USER_PROJECT.getString(options)) .setSoftDeleted(Option.SOFT_DELETED.getBoolean(options)); - //.setGeneration(Option.GENERATION.getLong(options)); + // .setGeneration(Option.GENERATION.getLong(options)); } @Override @@ -570,17 +570,20 @@ public StorageObject restore(StorageObject object, Map options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_RESTORE_OBJECT); Scope scope = tracer.withSpan(span); try { - Storage.Objects.Restore restore = storage.objects().restore(object.getBucket(), object.getName(), object.getGeneration(), object); + Storage.Objects.Restore restore = + storage + .objects() + .restore(object.getBucket(), object.getName(), object.getGeneration(), object); return restore - .setProjection(DEFAULT_PROJECTION) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)) - .setCopySourceAcl(Option.COPY_SOURCE_ACL.getBoolean(options)) - .setUserProject(Option.USER_PROJECT.getString(options)) - .setFields(Option.FIELDS.getString(options)) - .execute(); + .setProjection(DEFAULT_PROJECTION) + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)) + .setCopySourceAcl(Option.COPY_SOURCE_ACL.getBoolean(options)) + .setUserProject(Option.USER_PROJECT.getString(options)) + .setFields(Option.FIELDS.getString(options)) + .execute(); } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); StorageException serviceException = translate(ex); diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITBucketTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITBucketTest.java index 3513aeb07b..fbdb7221a7 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITBucketTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITBucketTest.java @@ -28,7 +28,6 @@ import com.google.api.gax.paging.Page; import com.google.cloud.Policy; import com.google.cloud.storage.Blob; -import com.google.cloud.storage.BlobId; import com.google.cloud.storage.BlobInfo; import com.google.cloud.storage.Bucket; import com.google.cloud.storage.BucketInfo; @@ -555,9 +554,13 @@ public void testUpdateBucket_noModification() throws Exception { @Test public void testSoftDeletePolicy() { String bucketName = generator.randomBucketName(); - BucketInfo bucketInfo = BucketInfo.newBuilder(bucketName).setSoftDeletePolicy(BucketInfo.SoftDeletePolicy - .newBuilder().setRetentionDuration(Duration.ofDays(10)).build()) - .build(); + BucketInfo bucketInfo = + BucketInfo.newBuilder(bucketName) + .setSoftDeletePolicy( + BucketInfo.SoftDeletePolicy.newBuilder() + .setRetentionDuration(Duration.ofDays(10)) + .build()) + .build(); try { storage.create(bucketInfo); @@ -575,19 +578,28 @@ public void testSoftDeletePolicy() { assertNull(remoteBucket.get(softDelBlobName)); - ImmutableList softDeletedBlobs = ImmutableList.copyOf(remoteBucket.list(Storage.BlobListOption.softDeleted(true)).iterateAll()); + ImmutableList softDeletedBlobs = + ImmutableList.copyOf( + remoteBucket.list(Storage.BlobListOption.softDeleted(true)).iterateAll()); assertThat(softDeletedBlobs.size() > 0); - assertNotNull(remoteBucket.get(softDelBlobName, gen, Storage.BlobGetOption.softDeleted(true))); + assertNotNull( + remoteBucket.get(softDelBlobName, gen, Storage.BlobGetOption.softDeleted(true))); assertNotNull(storage.restore(blob.getBlobId())); - remoteBucket.toBuilder() - .setSoftDeletePolicy(BucketInfo.SoftDeletePolicy.newBuilder().setRetentionDuration(Duration.ofDays(20)).build()) - .build() - .update(); + remoteBucket + .toBuilder() + .setSoftDeletePolicy( + BucketInfo.SoftDeletePolicy.newBuilder() + .setRetentionDuration(Duration.ofDays(20)) + .build()) + .build() + .update(); - assertEquals(Duration.ofDays(20), storage.get(bucketName).getSoftDeletePolicy().getRetentionDuration()); + assertEquals( + Duration.ofDays(20), + storage.get(bucketName).getSoftDeletePolicy().getRetentionDuration()); } finally { BucketCleaner.doCleanup(bucketName, storage); } diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/StorageInstance.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/StorageInstance.java index 0285813e64..b653dea056 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/StorageInstance.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/StorageInstance.java @@ -19,8 +19,6 @@ import com.google.cloud.Policy; import com.google.cloud.storage.Acl; import com.google.cloud.storage.Acl.Entity; -import com.google.cloud.storage.Blob; -import com.google.cloud.storage.BlobId; import com.google.cloud.storage.Bucket; import com.google.cloud.storage.BucketInfo; import com.google.cloud.storage.Storage;