Repository: googleapis/java-storage
Pull request #1438 (2022-06-07 13:43:35)

deps: update dependency com.google.apis:google-api-services-storage to v1-rev20220604-1.32.1
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.apis:google-api-services-storage](http://nexus.sonatype.org/oss-repository-hosting.html) ([source](http://svn.sonatype.org/spice/tags/oss-parent-7)) | `v1-rev20220509-1.32.1` -> `v1-rev20220604-1.32.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.apis:google-api-services-storage/v1-rev20220604-1.32.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.apis:google-api-services-storage/v1-rev20220604-1.32.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.apis:google-api-services-storage/v1-rev20220604-1.32.1/compatibility-slim/v1-rev20220509-1.32.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.apis:google-api-services-storage/v1-rev20220604-1.32.1/confidence-slim/v1-rev20220509-1.32.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-storage).


Patch:
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 e03110ff..02990680 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
@@ -446,7 +446,9 @@ public class BucketInfo implements Serializable {
           && condition.getDaysSinceNoncurrentTime() == null
           && condition.getNoncurrentTimeBefore() == null
           && condition.getCustomTimeBefore() == null
-          && condition.getDaysSinceCustomTime() == null) {
+          && condition.getDaysSinceCustomTime() == null
+          && condition.getMatchesPrefix() == null
+          && condition.getMatchesSuffix() == null) {
         log.warning(
             "Creating a lifecycle condition with no supported conditions:\n"
                 + this
@@ -527,7 +529,9 @@ public class BucketInfo implements Serializable {
                   lifecycleCondition.getCustomTimeBefore() == null
                       ? null
                       : new DateTime(true, lifecycleCondition.getCustomTimeBefore().getValue(), 0))
-              .setDaysSinceCustomTime(lifecycleCondition.getDaysSinceCustomTime());
+              .setDaysSinceCustomTime(lifecycleCondition.getDaysSinceCustomTime())
+              .setMatchesPrefix(lifecycleCondition.getMatchesPrefix())
+              .setMatchesSuffix(lifecycleCondition.getMatchesSuffix());
 
       rule.setCondition(condition);
 
@@ -548,6 +552,9 @@ public class BucketInfo implements Serializable {
               LifecycleAction.newSetStorageClassAction(
                   StorageClass.valueOf(action.getStorageClass()));
           break;
+        case AbortIncompleteMPUAction.TYPE:
+          lifecycleAction = LifecycleAction.newAbortIncompleteMPUploadAction();
+          break;
         default:
           log.warning(
               "The lifecycle action "
@@ -601,6 +608,8 @@ public class BucketInfo implements Serializable {
       private final DateTime noncurrentTimeBefore;
       private final DateTime customTimeBefore;
       private final Integer daysSinceCustomTime;
+      private final List<String> matchesPrefix;
+      private final List<String> matchesSuffix;
 
       private LifecycleCondition(Builder builder) {
         this.age = builder.age;
@@ -612,6 +621,8 @@ public class BucketInfo implements Serializable {
         this.noncurrentTimeBefore = builder.noncurrentTimeBefore;
         this.customTimeBefore = builder.customTimeBefore;
         this.daysSinceCustomTime = builder.daysSinceCustomTime;
+        this.matchesPrefix = builder.matchesPrefix;
+        this.matchesSuffix = builder.matchesSuffix;
       }
 
       public Builder toBuilder() {
@@ -624,7 +635,9 @@ public class BucketInfo implements Serializable {
             .setDaysSinceNoncurrentTime(this.daysSinceNoncurrentTime)
             .setNoncurrentTimeBefore(this.noncurrentTimeBefore)
             .setCustomTimeBefore(this.customTimeBefore)
-            .setDaysSinceCustomTime(this.daysSinceCustomTime);
+            .setDaysSinceCustomTime(this.daysSinceCustomTime)
+            .setMatchesPrefix(this.matchesPrefix)
+            .setMatchesSuffix(this.matchesSuffix);
       }
 
       public static Builder newBuilder() {
@@ -643,6 +656,8 @@ public class BucketInfo implements Serializable {
             .add("noncurrentTimeBefore", noncurrentTimeBefore)
             .add("customTimeBefore", customTimeBefore)
             .add("daysSinceCustomTime", daysSinceCustomTime)
+            .add("matchesPrefix", matchesPrefix)
+            .add("matchesSuffix", matchesSuffix)
             .toString();
       }
 
@@ -688,6 +703,14 @@ public class BucketInfo implements Serializable {
         return daysSinceCustomTime;
       }
 
+      public List<String> getMatchesPrefix() {
+        return matchesPrefix;
+      }
+
+      public List<String> getMatchesSuffix() {
+        return matchesSuffix;
+      }
+
       /** Builder for {@code LifecycleCondition}. */
       public static class Builder {
         private Integer age;
@@ -699,6 +722,8 @@ public class BucketInfo implements Serializable {
         private DateTime noncurrentTimeBefore;
         private DateTime customTimeBefore;
         private Integer daysSinceCustomTime;
+        private List<String> matchesPrefix;
+        private List<String> matchesSuffix;
 
         private Builder() {}
 
@@ -797,6 +822,24 @@ public class BucketInfo implements Serializable {
           return this;
         }
 
+        /**
+         * Sets the list of prefixes. If any prefix matches the beginning of the object’s name, this
+         * portion of the condition is satisfied for that object.
+         */
+        public Builder setMatchesPrefix(List<String> matchesPrefix) {
+          this.matchesPrefix = matchesPrefix != null ? ImmutableList.copyOf(matchesPrefix) : null;
+          return this;
+        }
+
+        /**
+         * Sets the list of suffixes. If any suffix matches the end of the object’s name, this
+         * portion of the condition is satisfied for that object.
+         */
+        public Builder setMatchesSuffix(List<String> matchesSuffix) {
+          this.matchesSuffix = matchesSuffix != null ? ImmutableList.copyOf(matchesSuffix) : null;
+          return this;
+        }
+
         /** Builds a {@code LifecycleCondition} object. * */
         public LifecycleCondition build() {
           return new LifecycleCondition(this);
@@ -845,6 +888,15 @@ public class BucketInfo implements Serializable {
         return new SetStorageClassLifecycleAction(storageClass);
       }
 
+      /**
+       * Create a new {@code AbortIncompleteMPUAction}. An incomplete multipart upload will be
+       * aborted when the multipart upload meets the specified condition. Age is the only condition
+       * supported for this action. See: https://cloud.google.com/storage/docs/lifecycle##abort-mpu
+       */
+      public static LifecycleAction newAbortIncompleteMPUploadAction() {
+        return new AbortIncompleteMPUAction();
+      }
+
       /**
        * Creates a new {@code LifecycleAction , with no specific supported action associated with it. This
        * is only intended as a "backup" for when the library doesn't recognize the type, and should
@@ -888,6 +940,15 @@ public class BucketInfo implements Serializable {
         return storageClass;
       }
     }
+
+    public static class AbortIncompleteMPUAction extends LifecycleAction {
+      public static final String TYPE = "AbortIncompleteMultipartUpload";
+      private static final long serialVersionUID = -1072182310389348060L;
+
+      private AbortIncompleteMPUAction() {
+        super(TYPE);
+      }
+    }
   }
 
   /**
diff --git a/pom.xml b/pom.xml
index 3a2b6333..a42dc0e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,7 @@
       <dependency>
         <groupId>com.google.apis</groupId>
         <artifactId>google-api-services-storage</artifactId>
-        <version>v1-rev20220509-1.32.1</version>
+        <version>v1-rev20220604-1.32.1</version>
       </dependency>
       <dependency>
         <groupId>com.google.cloud</groupId>


Test patch:
diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java
index 2041de55..e05d9747 100644
--- a/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java
+++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java
@@ -39,8 +39,11 @@ import com.google.cloud.storage.BucketInfo.DeleteRule.Type;
 import com.google.cloud.storage.BucketInfo.IamConfiguration;
 import com.google.cloud.storage.BucketInfo.IsLiveDeleteRule;
 import com.google.cloud.storage.BucketInfo.LifecycleRule;
+import com.google.cloud.storage.BucketInfo.LifecycleRule.AbortIncompleteMPUAction;
+import com.google.cloud.storage.BucketInfo.LifecycleRule.DeleteLifecycleAction;
 import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction;
 import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleCondition;
+import com.google.cloud.storage.BucketInfo.LifecycleRule.SetStorageClassLifecycleAction;
 import com.google.cloud.storage.BucketInfo.NumNewerVersionsDeleteRule;
 import com.google.cloud.storage.BucketInfo.PublicAccessPrevention;
 import com.google.cloud.storage.BucketInfo.RawDeleteRule;
@@ -331,6 +334,8 @@ public class BucketInfoTest {
     assertEquals(
         LifecycleRule.DeleteLifecycleAction.TYPE, deleteLifecycleRule.getAction().getType());
     assertEquals(10, deleteLifecycleRule.getCondition().getAge().intValue());
+    assertTrue(
+        LifecycleRule.fromPb(deleteLifecycleRule).getAction() instanceof DeleteLifecycleAction);
 
     Rule setStorageClassLifecycleRule =
         new LifecycleRule(
@@ -346,6 +351,9 @@ public class BucketInfoTest {
         setStorageClassLifecycleRule.getAction().getStorageClass());
     assertTrue(setStorageClassLifecycleRule.getCondition().getIsLive());
     assertEquals(10, setStorageClassLifecycleRule.getCondition().getNumNewerVersions().intValue());
+    assertTrue(
+        LifecycleRule.fromPb(setStorageClassLifecycleRule).getAction()
+            instanceof SetStorageClassLifecycleAction);
 
     Rule lifecycleRule =
         new LifecycleRule(
@@ -357,6 +365,8 @@ public class BucketInfoTest {
                     .setNoncurrentTimeBefore(new DateTime(System.currentTimeMillis()))
                     .setCustomTimeBefore(new DateTime(System.currentTimeMillis()))
                     .setDaysSinceCustomTime(30)
+                    .setMatchesSuffix(Collections.singletonList("-suffix"))
+                    .setMatchesPrefix(Collections.singletonList("prefix-"))
                     .build())
             .toPb();
     assertEquals(StorageClass.COLDLINE.toString(), lifecycleRule.getAction().getStorageClass());
@@ -367,6 +377,21 @@ public class BucketInfoTest {
     assertEquals(StorageClass.COLDLINE.toString(), lifecycleRule.getAction().getStorageClass());
     assertEquals(30, lifecycleRule.getCondition().getDaysSinceCustomTime().intValue());
     assertNotNull(lifecycleRule.getCondition().getCustomTimeBefore());
+    assertEquals("prefix-", lifecycleRule.getCondition().getMatchesPrefix().get(0));
+    assertEquals("-suffix", lifecycleRule.getCondition().getMatchesSuffix().get(0));
+    assertTrue(
+        LifecycleRule.fromPb(lifecycleRule).getAction() instanceof SetStorageClassLifecycleAction);
+
+    Rule abortMpuLifecycleRule =
+        new LifecycleRule(
+                LifecycleAction.newAbortIncompleteMPUploadAction(),
+                LifecycleCondition.newBuilder().setAge(10).build())
+            .toPb();
+    assertEquals(AbortIncompleteMPUAction.TYPE, abortMpuLifecycleRule.getAction().getType());
+    assertEquals(10, abortMpuLifecycleRule.getCondition().getAge().intValue());
+    assertTrue(
+        LifecycleRule.fromPb(abortMpuLifecycleRule).getAction()
+            instanceof AbortIncompleteMPUAction);
 
     Rule unsupportedRule =
         new LifecycleRule(
diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
index e5ecf1f0..b1863b38 100644
--- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
+++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
@@ -66,6 +66,7 @@ import com.google.cloud.storage.BlobInfo;
 import com.google.cloud.storage.Bucket;
 import com.google.cloud.storage.BucketInfo;
 import com.google.cloud.storage.BucketInfo.LifecycleRule;
+import com.google.cloud.storage.BucketInfo.LifecycleRule.AbortIncompleteMPUAction;
 import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction;
 import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleCondition;
 import com.google.cloud.storage.CopyWriter;
@@ -565,6 +566,29 @@ public class ITStorageTest {
     }
   }
 
+  @Test
+  public void testGetBucketAbortMPULifecycle() {
+    String lifecycleTestBucketName = RemoteStorageHelper.generateBucketName();
+    storage.create(
+        BucketInfo.newBuilder(lifecycleTestBucketName)
+            .setLocation("us")
+            .setLifecycleRules(
+                ImmutableList.of(
+                    new LifecycleRule(
+                        LifecycleAction.newAbortIncompleteMPUploadAction(),
+                        LifecycleCondition.newBuilder().setAge(1).build())))
+            .build());
+    Bucket remoteBucket =
+        storage.get(lifecycleTestBucketName, Storage.BucketGetOption.fields(BucketField.LIFECYCLE));
+    LifecycleRule lifecycleRule = remoteBucket.getLifecycleRules().get(0);
+    try {
+      assertEquals(AbortIncompleteMPUAction.TYPE, lifecycleRule.getAction().getActionType());
+      assertEquals(1, lifecycleRule.getCondition().getAge().intValue());
+    } finally {
+      storage.delete(lifecycleTestBucketName);
+    }
+  }
+
   @Test
   public void testClearBucketDefaultKmsKeyName() throws ExecutionException, InterruptedException {
     String bucketName = RemoteStorageHelper.generateBucketName();