Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Mar 30, 2022
1 parent ddbc554 commit ec70866
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 44 deletions.
8 changes: 6 additions & 2 deletions README.md
Expand Up @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-storage'
If you are using Gradle without BOM, add this to your dependencies

```Groovy
implementation 'com.google.cloud:google-cloud-storage:2.5.1'
implementation 'com.google.cloud:google-cloud-storage:2.6.0'
```

If you are using SBT, add this to your dependencies

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "2.5.1"
libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "2.6.0"
```

## Authentication
Expand Down Expand Up @@ -240,9 +240,11 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-storage/tree/
| Change Default Storage Class | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/ChangeDefaultStorageClass.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/ChangeDefaultStorageClass.java) |
| Configure Bucket Cors | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/ConfigureBucketCors.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/ConfigureBucketCors.java) |
| Create Bucket | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/CreateBucket.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/CreateBucket.java) |
| Create Bucket Pub Sub Notification | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/CreateBucketPubSubNotification.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/CreateBucketPubSubNotification.java) |
| Create Bucket With Storage Class And Location | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/CreateBucketWithStorageClassAndLocation.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/CreateBucketWithStorageClassAndLocation.java) |
| Create Bucket With Turbo Replication | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/CreateBucketWithTurboReplication.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/CreateBucketWithTurboReplication.java) |
| Delete Bucket | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/DeleteBucket.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/DeleteBucket.java) |
| Delete Bucket Pub Sub Notification | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/DeleteBucketPubSubNotification.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/DeleteBucketPubSubNotification.java) |
| Disable Bucket Versioning | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/DisableBucketVersioning.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/DisableBucketVersioning.java) |
| Disable Default Event Based Hold | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/DisableDefaultEventBasedHold.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/DisableDefaultEventBasedHold.java) |
| Disable Lifecycle Management | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/DisableLifecycleManagement.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/DisableLifecycleManagement.java) |
Expand All @@ -262,10 +264,12 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-storage/tree/
| Get Uniform Bucket Level Access | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/GetUniformBucketLevelAccess.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/GetUniformBucketLevelAccess.java) |
| List Bucket Iam Members | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/ListBucketIamMembers.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/ListBucketIamMembers.java) |
| List Buckets | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/ListBuckets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/ListBuckets.java) |
| List Pub Sub Notifications | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/ListPubSubNotifications.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/ListPubSubNotifications.java) |
| Lock Retention Policy | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/LockRetentionPolicy.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/LockRetentionPolicy.java) |
| Make Bucket Public | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/MakeBucketPublic.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/MakeBucketPublic.java) |
| Print Bucket Acl | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/PrintBucketAcl.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/PrintBucketAcl.java) |
| Print Bucket Acl Filter By User | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/PrintBucketAclFilterByUser.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/PrintBucketAclFilterByUser.java) |
| Print Pub Sub Notification | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/PrintPubSubNotification.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/PrintPubSubNotification.java) |
| Remove Bucket Cors | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/RemoveBucketCors.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/RemoveBucketCors.java) |
| Remove Bucket Default Kms Key | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/RemoveBucketDefaultKmsKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/RemoveBucketDefaultKmsKey.java) |
| Remove Bucket Default Owner | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/RemoveBucketDefaultOwner.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/RemoveBucketDefaultOwner.java) |
Expand Down
Expand Up @@ -25,10 +25,10 @@
import com.google.cloud.storage.StorageOptions;
import java.util.Map;


public class CreateBucketPubSubNotification {

public static void createBucketPubSubNotification(String bucketName,
public static void createBucketPubSubNotification(
String bucketName,
String topicName,
Map<String, String> customAttributes,
EventType[] eventTypes,
Expand Down Expand Up @@ -58,16 +58,17 @@ public static void createBucketPubSubNotification(String bucketName,
// String etag = "etag-value";

Storage storage = StorageOptions.newBuilder().build().getService();
NotificationInfo notificationInfo = NotificationInfo.newBuilder(topicName)
.setEtag(etag)
.setCustomAttributes(customAttributes)
.setSelfLink(selfLink)
.setEventTypes(eventTypes)
.setObjectNamePrefix(objectNamePrefix)
.setPayloadFormat(payloadFormat)
.build();
NotificationInfo notificationInfo =
NotificationInfo.newBuilder(topicName)
.setEtag(etag)
.setCustomAttributes(customAttributes)
.setSelfLink(selfLink)
.setEventTypes(eventTypes)
.setObjectNamePrefix(objectNamePrefix)
.setPayloadFormat(payloadFormat)
.build();
Notification notification = storage.createNotification(bucketName, notificationInfo);
System.out.println("Successfully created notification for topic " + notification.getTopic());
}
}
// [END storage_create_bucket_notifications]
// [END storage_create_bucket_notifications]
Expand Up @@ -17,11 +17,9 @@
package com.example.storage.bucket;

// [START storage_delete_bucket_notification]
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;


public class DeleteBucketPubSubNotification {

public static void deleteBucketPubSubNotification(String bucketName, String notificationId) {
Expand All @@ -40,4 +38,4 @@ public static void deleteBucketPubSubNotification(String bucketName, String noti
}
}
}
// [END storage_delete_bucket_notification]
// [END storage_delete_bucket_notification]
Expand Up @@ -17,13 +17,11 @@
package com.example.storage.bucket;

// [START storage_list_bucket_notifications]
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.Notification;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
import java.util.List;


public class ListPubSubNotifications {

public static void listPubSubNotifications(String bucketName) {
Expand All @@ -38,4 +36,4 @@ public static void listPubSubNotifications(String bucketName) {
}
}
}
// [END storage_list_bucket_notifications]
// [END storage_list_bucket_notifications]
Expand Up @@ -17,19 +17,16 @@
package com.example.storage.bucket;

// [START storage_print_pubsub_bucket_notification]
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.Notification;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
import java.util.List;


public class PrintPubSubNotification {

public static void printPubSubNotification(String bucketName, String notificationId) {
// The ID to give your GCS bucket
// String bucketName = "your-unique-bucket-name";

// The Pub/Sub topic you would like to find
// String notificationId = "your-unique-notification-id"

Expand All @@ -39,4 +36,4 @@ public static void printPubSubNotification(String bucketName, String notificatio
"Found notification " + notification.getTopic() + " for bucket " + bucketName);
}
}
// [END storage_print_pubsub_bucket_notification]
// [END storage_print_pubsub_bucket_notification]
Expand Up @@ -23,7 +23,6 @@
import com.google.cloud.pubsub.v1.TopicAdminClient;
import com.google.cloud.storage.Notification;
import com.google.cloud.storage.NotificationInfo.EventType;
import com.google.cloud.storage.NotificationInfo.PayloadFormat;
import com.google.common.collect.ImmutableMap;
import com.google.iam.v1.Binding;
import com.google.iam.v1.GetIamPolicyRequest;
Expand All @@ -45,7 +44,7 @@ public class CreateBucketPubSubNotificationTest extends TestBase {
private static final String SELF_LINK = "http://storage/b/n";
private static final String OBJECT_NAME_PREFIX = "index.html";
private static final EventType[] EVENT_TYPES = {
EventType.OBJECT_FINALIZE, EventType.OBJECT_METADATA_UPDATE
EventType.OBJECT_FINALIZE, EventType.OBJECT_METADATA_UPDATE
};
private static TopicAdminClient topicAdminClient;

Expand Down Expand Up @@ -94,5 +93,4 @@ public void testCreateBucketPubSubNotification() {
ETAG);
assertThat(stdOut.getCapturedOutputAsUtf8String()).contains(TOPIC);
}

}
}
Expand Up @@ -41,10 +41,11 @@ public class DeleteBucketPubSubNotificationTest extends TestBase {
private static final String PROJECT = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String TOPIC = String.format("projects/%s/topics/new-topic-delete", PROJECT);
private static TopicAdminClient topicAdminClient;
private static final NotificationInfo notificationInfo = NotificationInfo.newBuilder(TOPIC)
.setCustomAttributes(CUSTOM_ATTRIBUTES)
.setPayloadFormat(PAYLOAD_FORMAT)
.build();
private static final NotificationInfo notificationInfo =
NotificationInfo.newBuilder(TOPIC)
.setCustomAttributes(CUSTOM_ATTRIBUTES)
.setPayloadFormat(PAYLOAD_FORMAT)
.build();

@BeforeClass
public static void configureTopicAdminClient() throws IOException {
Expand Down Expand Up @@ -82,10 +83,9 @@ public void testDeleteBucketPubSubNotification() {

Notification notification = storage.createNotification(bucketName, notificationInfo);
com.example.storage.bucket.DeleteBucketPubSubNotification.deleteBucketPubSubNotification(
bucketName,
notification.getNotificationId());
assertThat(stdOut.getCapturedOutputAsUtf8String()).contains(
"Successfully deleted notification");
bucketName, notification.getNotificationId());
assertThat(stdOut.getCapturedOutputAsUtf8String())
.contains("Successfully deleted notification");
}

@Test
Expand All @@ -98,9 +98,7 @@ public void testNotificationNotFound() {
storage.deleteNotification(bucketName, notification.getNotificationId());
// Now try to delete again.
com.example.storage.bucket.DeleteBucketPubSubNotification.deleteBucketPubSubNotification(
bucketName,
notification.getNotificationId());
bucketName, notification.getNotificationId());
assertThat(stdOut.getCapturedOutputAsUtf8String()).contains("Failed to find notification");
}

}
}
Expand Up @@ -85,5 +85,4 @@ public void testListBucketPubSubNotification() {
ListPubSubNotifications.listPubSubNotifications(bucketName);
assertThat(stdOut.getCapturedOutputAsUtf8String()).contains(TOPIC);
}

}
}
Expand Up @@ -85,5 +85,4 @@ public void testPrintBucketPubSubNotification() {
PrintPubSubNotification.printPubSubNotification(bucketName, notification.getNotificationId());
assertThat(stdOut.getCapturedOutputAsUtf8String()).contains(TOPIC);
}

}
}

0 comments on commit ec70866

Please sign in to comment.