diff --git a/google-cloud-storage/clirr-ignored-differences.xml b/google-cloud-storage/clirr-ignored-differences.xml
index ae8d781dbe..a136652927 100644
--- a/google-cloud-storage/clirr-ignored-differences.xml
+++ b/google-cloud-storage/clirr-ignored-differences.xml
@@ -21,4 +21,15 @@
com.google.cloud.storage.PostPolicyV4 generateSignedPostPolicyV4(com.google.cloud.storage.BlobInfo, long, java.util.concurrent.TimeUnit, com.google.cloud.storage.Storage$PostPolicyV4Option[])
7012
-
\ No newline at end of file
+
+ com/google/cloud/storage/Storage
+ boolean deleteLifecycleRules(java.lang.String)
+ 7012
+
+
+ com/google/cloud/storage/spi/v1/StorageRpc
+ boolean deleteLifecycleRules(com.google.api.services.storage.model.Bucket)
+ 7012
+
+
+
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 7aa847c9b6..1cbe0e7d4e 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
@@ -1114,6 +1114,37 @@ public boolean deleteDefaultAcl(Entity entity) {
return storage.deleteDefaultAcl(getName(), entity);
}
+ /**
+ * Delete the lifecycle rules of this bucket.
+ *
+ *
Example of deleting the lifecycle rules of this bucket.
+ *
+ *
{@code
+ * String bucketName = "my-unique-bucket";
+ * Bucket bucket =
+ * storage.create(
+ * BucketInfo.newBuilder(bucketName)
+ * .setStorageClass(StorageClass.COLDLINE)
+ * .setLocation("us-central1")
+ * .setLifecycleRules(
+ * ImmutableList.of(
+ * new LifecycleRule(
+ * LifecycleAction.newDeleteAction(),
+ * LifecycleCondition.newBuilder().setAge(2).build())))
+ * .build());
+ * boolean rulesDeleted = bucket.deleteLifecycleRules();
+ * if (rulesDeleted) {
+ * // the lifecycle rules were deleted
+ * }
+ * }
+ *
+ * @return {@code true} if the bucket lifecycle rules were deleted.
+ * @throws StorageException upon failure
+ */
+ public boolean deleteLifecycleRules() {
+ return storage.deleteLifecycleRules(getName());
+ }
+
/**
* Creates a new default blob ACL entry on this bucket.
*
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 e28a941088..92f0dd16d4 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
@@ -1999,7 +1999,6 @@ Blob create(
* only if supplied Decrpytion Key decrypts the blob successfully, otherwise a {@link
* StorageException} is thrown. For more information review
*
- * @throws StorageException upon failure
* @see Encrypted
* Elements
@@ -3076,6 +3075,36 @@ PostPolicyV4 generateSignedPostPolicyV4(
*/
boolean deleteDefaultAcl(String bucket, Entity entity);
+ /**
+ * Delete the lifecycle rules of the requested bucket.
+ *
+ * Example of deleting the lifecycle rules of the requested bucket.
+ *
+ *
{@code
+ * String bucketName = "my-unique-bucket";
+ * Bucket bucket =
+ * storage.create(
+ * BucketInfo.newBuilder(bucketName)
+ * .setStorageClass(StorageClass.COLDLINE)
+ * .setLocation("us-central1")
+ * .setLifecycleRules(
+ * ImmutableList.of(
+ * new LifecycleRule(
+ * LifecycleAction.newDeleteAction(),
+ * LifecycleCondition.newBuilder().setAge(2).build())))
+ * .build());
+ * boolean rulesDeleted = storage.deleteLifecycleRules(bucketName);
+ * if (rulesDeleted) {
+ * // the lifecycle rules were deleted
+ * }
+ * }
+ *
+ * @param bucket name of the bucket.
+ * @return {@code true} if the bucket lifecycle rules were deleted.
+ * @throws StorageException upon failure
+ */
+ boolean deleteLifecycleRules(String bucket);
+
/**
* Creates a new default blob ACL entry on the specified bucket.
*
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 0e24521eb6..49589dc933 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
@@ -1158,6 +1158,25 @@ public Boolean call() {
}
}
+ @Override
+ public boolean deleteLifecycleRules(final String bucket) {
+ final com.google.api.services.storage.model.Bucket bucketPb = BucketInfo.of(bucket).toPb();
+ try {
+ return runWithRetries(
+ new Callable() {
+ @Override
+ public Boolean call() {
+ return storageRpc.deleteLifecycleRules(bucketPb);
+ }
+ },
+ getOptions().getRetrySettings(),
+ EXCEPTION_HANDLER,
+ getOptions().getClock());
+ } catch (RetryHelperException e) {
+ throw StorageException.translateAndThrow(e);
+ }
+ }
+
@Override
public boolean deleteAcl(final String bucket, final Entity entity) {
return deleteAcl(bucket, entity, new BucketSourceOption[0]);
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 e211c0277e..78d2cad88b 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
@@ -25,6 +25,7 @@
import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.http.ByteArrayContent;
import com.google.api.client.http.GenericUrl;
+import com.google.api.client.http.HttpContent;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
@@ -87,7 +88,8 @@ public class HttpStorageRpc implements StorageRpc {
public static final String NO_ACL_PROJECTION = "noAcl";
private static final String ENCRYPTION_KEY_PREFIX = "x-goog-encryption-";
private static final String SOURCE_ENCRYPTION_KEY_PREFIX = "x-goog-copy-source-encryption-";
-
+ private static final String GOOGLE_STORAGE_API_ENDPOINT =
+ "https://storage.googleapis.com/storage/v1/b/";
// declare this HttpStatus code here as it's not included in java.net.HttpURLConnection
private static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
@@ -1000,6 +1002,32 @@ public boolean deleteAcl(String bucket, String entity, Map