Skip to content

Commit

Permalink
Addressing PR comments on ETAG and Selflink not being included in the…
Browse files Browse the repository at this point in the history
… sample
  • Loading branch information
sydney-munro committed Mar 31, 2022
1 parent ddbc554 commit acb0115
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
Expand Up @@ -33,9 +33,7 @@ public static void createBucketPubSubNotification(String bucketName,
Map<String, String> customAttributes,
EventType[] eventTypes,
String objectNamePrefix,
PayloadFormat payloadFormat,
String selfLink,
String etag) {
PayloadFormat payloadFormat) {
// The ID to give your GCS bucket
// String bucketName = "your-unique-bucket-name";

Expand All @@ -51,17 +49,9 @@ public static void createBucketPubSubNotification(String bucketName,
// Desired content of the Payload
// PayloadFormat payloadFormat = PayloadFormat.JSON_API_V1.JSON_API_V1;

// The canonical URI of this topic as a string
// String selfLink = "//pubsub.googleapis.com/projects/{project-identifier}/topics/{my-topic}";

// HTTP 1.1 Entity tag for this subscription notification
// 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)
Expand Down
Expand Up @@ -41,8 +41,6 @@ public class CreateBucketPubSubNotificationTest extends TestBase {
private static final Map<String, String> CUSTOM_ATTRIBUTES = ImmutableMap.of("label1", "value1");
private static final String PROJECT = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String TOPIC = String.format("projects/%s/topics/new-topic-create", PROJECT);
private static final String ETAG = "0xFF00";
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
Expand Down Expand Up @@ -89,9 +87,7 @@ public void testCreateBucketPubSubNotification() {
CUSTOM_ATTRIBUTES,
EVENT_TYPES,
OBJECT_NAME_PREFIX,
PAYLOAD_FORMAT,
SELF_LINK,
ETAG);
PAYLOAD_FORMAT);
assertThat(stdOut.getCapturedOutputAsUtf8String()).contains(TOPIC);
}

Expand Down

0 comments on commit acb0115

Please sign in to comment.