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 584abff commit 4c3fd41
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 43 deletions.
4 changes: 4 additions & 0 deletions README.md
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 @@ -26,10 +26,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 All @@ -53,16 +53,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 @@ -39,4 +37,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,12 +17,9 @@
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 {

Expand All @@ -38,4 +35,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 @@ -83,9 +82,15 @@ public void testCreateBucketPubSubNotification() {
assertNotNull("Unable to determine project", PROJECT);
assertNotNull("Topic Admin Client did not start up", topicAdminClient);

com.example.storage.bucket.CreateBucketPubSubNotification.createBucketPubSubNotification(bucketName, TOPIC,
CUSTOM_ATTRIBUTES, EVENT_TYPES, OBJECT_NAME_PREFIX, PAYLOAD_FORMAT, SELF_LINK, ETAG);
com.example.storage.bucket.CreateBucketPubSubNotification.createBucketPubSubNotification(
bucketName,
TOPIC,
CUSTOM_ATTRIBUTES,
EVENT_TYPES,
OBJECT_NAME_PREFIX,
PAYLOAD_FORMAT,
SELF_LINK,
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", 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 @@ -81,10 +82,10 @@ public void testDeleteBucketPubSubNotification() {
assertNotNull("Topic Admin Client did not start up", topicAdminClient);

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

@Test
Expand All @@ -96,9 +97,8 @@ public void testNotificationNotFound() {
// Do a delete first.
storage.deleteNotification(bucketName, notification.getNotificationId());
// Now try to delete again.
com.example.storage.bucket.DeleteBucketPubSubNotification.deleteBucketPubSubNotification(bucketName,
notification.getNotificationId());
com.example.storage.bucket.DeleteBucketPubSubNotification.deleteBucketPubSubNotification(
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 4c3fd41

Please sign in to comment.