diff --git a/pom.xml b/pom.xml
index f9e8ab6b71..f7dfea65fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -360,7 +360,7 @@ the License.-->
com.google.cloud
google-cloud-storage
- 2.1.3
+ 2.8.0
@@ -368,6 +368,12 @@ the License.-->
google-cloud-bigquery
2.1.8
+
+
+ com.google.apis
+ google-api-services-storage
+ v1-rev20220604-1.32.1
+
diff --git a/src/main/java/io/cdap/e2e/utils/StorageClient.java b/src/main/java/io/cdap/e2e/utils/StorageClient.java
index 638538b988..8bcd2dadad 100644
--- a/src/main/java/io/cdap/e2e/utils/StorageClient.java
+++ b/src/main/java/io/cdap/e2e/utils/StorageClient.java
@@ -22,10 +22,15 @@
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.LifecycleAction;
+import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleCondition;
import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.Storage.BucketField;
import com.google.cloud.storage.StorageException;
import com.google.cloud.storage.StorageOptions;
+import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
@@ -40,7 +45,7 @@ public class StorageClient {
private static Storage getStorageService() throws IOException {
return (null == storageService) ? StorageOptions.newBuilder().setProjectId(
- PluginPropertyUtils.pluginProp(ConstantsUtil.PROJECT_ID)).build().getService() : storageService;
+ PluginPropertyUtils.pluginProp(ConstantsUtil.PROJECT_ID)).build().getService() : storageService;
}
public static Page listBuckets() throws IOException {
@@ -89,8 +94,18 @@ public static Bucket createBucket(String bucketName) throws IOException {
public static Blob uploadObject(String bucketName, String objectName, String filePath)
throws IOException, URISyntaxException {
return getStorageService().create(
- BlobInfo.newBuilder(BlobId.of(bucketName, objectName)).build(),
- Files.readAllBytes(Paths.get(StorageClient.class.getResource("/" + filePath).toURI())));
+ BlobInfo.newBuilder(BlobId.of(bucketName, objectName)).build(),
+ Files.readAllBytes(Paths.get(StorageClient.class.getResource("/" + filePath).toURI())));
+ }
+
+ public static Bucket createBucketwithLifeCycle(String bucketName, int age) throws IOException {
+ return getStorageService().create(BucketInfo.of(bucketName)).toBuilder()
+ .setLifecycleRules(
+ ImmutableList.of(
+ new LifecycleRule(
+ LifecycleAction.newAbortIncompleteMPUploadAction(),
+ LifecycleCondition.newBuilder().setAge(age).build()))).build().update();
}
}
+