I was successfully able to add the lifecycle rules to a bucket.
Storage storage=/* connection*/;
Builder builder = BucketInfo.newBuilder(name);
builder.setStorageClass(COLDLINE);
builder.setLifecycleRules( lifecycleRules);
storage.create(builder.build());
But seems there is no way to remove the lifecycle rules from bucket
Storage storage=/* connection*/;
Builder builder = BucketInfo.newBuilder(name);
builder.setLifecycleRules(null);
storage.update(builder.build());
Looks like there is no support in SDK for PATCH update where as Rest API for lifecycle configuration is available .
https://cloud.google.com/storage/docs/managing-lifecycles
curl -X PATCH --data-binary @[LIFECYCLE_CONFIG_FILE].json \
-H "Authorization: Bearer [OAUTH2_TOKEN]" \
-H "Content-Type: application/json" \
"https://storage.googleapis.com/storage/v1/b/[BUCKET_NAME]?fields=lifecycle"
Environment details
OS type and version: Windows 10
Java version: JDK 11
sdk version: google-cloud-storage-1.7.8.0.jar
I was successfully able to add the lifecycle rules to a bucket.
But seems there is no way to remove the lifecycle rules from bucket
Looks like there is no support in SDK for PATCH update where as Rest API for lifecycle configuration is available .
https://cloud.google.com/storage/docs/managing-lifecycles
Environment details
OS type and version: Windows 10
Java version: JDK 11
sdk version: google-cloud-storage-1.7.8.0.jar