Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functionality added for GCS delete multipart upload policy #18

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,20 @@ the License.-->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>2.1.3</version>
<version>2.8.0</version>
</dependency>

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>2.1.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-storage -->
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev20220604-1.32.1</version>
</dependency>

</dependencies>

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/io/cdap/e2e/utils/StorageClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -93,4 +98,18 @@ public static Blob uploadObject(String bucketName, String objectName, String fil
Files.readAllBytes(Paths.get(StorageClient.class.getResource("/" + filePath).toURI())));
}

/**
* @param bucketName , required random Bucket name to create in GCS.
* @param ageInDays Age has to be pass in days.
*/
public static Bucket createBucketwithLifeCycle(String bucketName, int ageInDays) throws IOException {
return getStorageService().create(BucketInfo.of(bucketName)).toBuilder()
.setLifecycleRules(
ImmutableList.of(
new LifecycleRule(
LifecycleAction.newAbortIncompleteMPUploadAction(),
LifecycleCondition.newBuilder().setAge(ageInDays).build()))).build().update();
}

}

Loading