diff --git a/google-cloud-storage/clirr-ignored-differences.xml b/google-cloud-storage/clirr-ignored-differences.xml
index 9f137f62c..04d2052ad 100644
--- a/google-cloud-storage/clirr-ignored-differences.xml
+++ b/google-cloud-storage/clirr-ignored-differences.xml
@@ -13,7 +13,7 @@
com/google/cloud/storage/Storage
- com.google.cloud.storage.Notification createNotification(java.lang.String, com.google.cloud.storage.NotificationInfo)
+ com.google.cloud.storage.Notification createNotification(java.lang.String, com.google.cloud.storage.Notification)
7012
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Notification.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Notification.java
index 33532f558..78a5dcc79 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Notification.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Notification.java
@@ -13,127 +13,301 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.google.cloud.storage;
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.api.pathtemplate.PathTemplate;
+import com.google.common.base.Function;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import java.io.Serializable;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
- * Google Storage Notification object;
+ * Google Storage Notification metadata;
*
- * @see notifications
+ * @see Concepts and
+ * Terminology
*/
-public class Notification extends NotificationInfo {
+public class Notification implements Serializable {
+
+ private static final long serialVersionUID = 5725883368559753810L;
+ private static final PathTemplate PATH_TEMPLATE =
+ PathTemplate.createWithoutUrlEncoding("projects/{project}/topics/{topic}");
+
+ public enum PayloadFormat {
+ JSON_API_V1,
+ NONE
+ }
+
+ static final Function
+ FROM_PB_FUNCTION =
+ new Function() {
+ @Override
+ public Notification apply(com.google.api.services.storage.model.Notification pb) {
+ return Notification.fromPb(pb);
+ }
+ };
+ static final Function
+ TO_PB_FUNCTION =
+ new Function() {
+ @Override
+ public com.google.api.services.storage.model.Notification apply(
+ Notification notification) {
+ return notification.toPb();
+ }
+ };
+ private final String generatedId;
+ private final String topic;
+ private final List eventTypes;
+ private final Map customAttributes;
+ private final PayloadFormat payloadFormat;
+ private final String objectNamePrefix;
+ private final String etag;
+ private final String selfLink;
+
+ /** Builder for {@code NotificatioInfo}. */
+ public static class Builder {
- private final StorageOptions options;
- private transient Storage storage;
+ private String generatedId;
+ private String topic;
+ private List eventTypes;
+ private Map customAttributes;
+ private PayloadFormat payloadFormat;
+ private String objectNamePrefix;
+ private String etag;
+ private String selfLink;
- /** Builder for {@code Notification}. */
- public static class Builder extends NotificationInfo.Builder {
- private final Storage storage;
- private final NotificationInfo.BuilderImpl infoBuilder;
+ private Builder(String topic) {
+ this.topic = topic;
+ }
- Builder(Notification notification) {
- this.storage = notification.storage;
- this.infoBuilder = new NotificationInfo.BuilderImpl(notification);
+ private Builder(Notification notification) {
+ generatedId = notification.generatedId;
+ etag = notification.etag;
+ selfLink = notification.selfLink;
+ topic = notification.topic;
+ eventTypes = notification.eventTypes;
+ customAttributes = notification.customAttributes;
+ payloadFormat = notification.payloadFormat;
+ objectNamePrefix = notification.objectNamePrefix;
}
- @Override
public Builder setGeneratedId(String generatedId) {
- infoBuilder.setGeneratedId(generatedId);
+ this.generatedId = generatedId;
return this;
}
- @Override
public Builder setSelfLink(String selfLink) {
- infoBuilder.setSelfLink(selfLink);
+ this.selfLink = selfLink;
return this;
}
- @Override
+ /** The name of the topic. It must have the format "projects/{project}/topics/{topic}". */
public Builder setTopic(String topic) {
- infoBuilder.setTopic(topic);
+ this.topic = topic;
return this;
}
- @Override
public Builder setPayloadFormat(PayloadFormat payloadFormat) {
- infoBuilder.setPayloadFormat(payloadFormat);
+ this.payloadFormat = payloadFormat;
return this;
}
- @Override
public Builder setObjectNamePrefix(String objectNamePrefix) {
- infoBuilder.setObjectNamePrefix(objectNamePrefix);
+ this.objectNamePrefix = objectNamePrefix;
return this;
}
- @Override
public Builder setEventTypes(Iterable eventTypes) {
- infoBuilder.setEventTypes(eventTypes);
+ this.eventTypes = eventTypes != null ? ImmutableList.copyOf(eventTypes) : null;
return this;
}
- @Override
public Builder setEtag(String etag) {
- infoBuilder.setEtag(etag);
+ this.etag = etag;
return this;
}
- @Override
public Builder setCustomAttributes(Map customAttributes) {
- infoBuilder.setCustomAttributes(customAttributes);
+ this.customAttributes =
+ customAttributes != null ? ImmutableMap.copyOf(customAttributes) : null;
return this;
}
- @Override
public Notification build() {
- return new Notification(storage, infoBuilder);
+ checkNotNull(topic);
+ return new Notification(this);
}
}
- Notification(Storage storage, NotificationInfo.BuilderImpl infoBuilder) {
- super(infoBuilder);
- this.storage = checkNotNull(storage);
- this.options = storage.getOptions();
+ private Notification(Builder builder) {
+ generatedId = builder.generatedId;
+ etag = builder.etag;
+ selfLink = builder.selfLink;
+ topic = builder.topic;
+ eventTypes = builder.eventTypes;
+ customAttributes = builder.customAttributes;
+ payloadFormat = builder.payloadFormat;
+ objectNamePrefix = builder.objectNamePrefix;
+ }
+
+ /** Returns the service-generated id for the notification. */
+ public String getGeneratedId() {
+ return generatedId;
}
- /** Returns the notification's {@code Storage} object used to issue requests. */
- public Storage getStorage() {
- return storage;
+ /** Returns the topic to which this subscription publishes. */
+ public String getTopic() {
+ return topic;
+ }
+
+ /** Returns the canonical URI of this topic as a string. */
+ public String getSelfLink() {
+ return selfLink;
+ }
+
+ /** Returns the desired content of the Payload. */
+ public PayloadFormat getPayloadFormat() {
+ return payloadFormat;
+ }
+
+ /** Returns the object name prefix for which this notification configuration applies. */
+ public String getObjectNamePrefix() {
+ return objectNamePrefix;
+ }
+
+ /**
+ * Returns HTTP 1.1 Entity tag for the notification.
+ *
+ * @see Entity Tags
+ */
+ public String getEtag() {
+ return etag;
+ }
+
+ /**
+ * Returns the list of event types that this notification will apply to. If empty, notifications
+ * will be sent on all event types.
+ *
+ * @see Cross-Origin Resource Sharing
+ * (CORS)
+ */
+ public List getEventTypes() {
+ return eventTypes;
+ }
+
+ /**
+ * Returns the list of additional attributes to attach to each Cloud PubSub message published for
+ * this notification subscription.
+ *
+ * @see
+ * About Access Control Lists
+ */
+ public Map getCustomAttributes() {
+ return customAttributes;
}
@Override
- public Builder toBuilder() {
- return new Notification.Builder(this);
+ public int hashCode() {
+ return Objects.hash(getTopic());
}
@Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
+ public boolean equals(Object obj) {
+ return obj == this
+ || obj != null
+ && obj.getClass().equals(Notification.class)
+ && Objects.equals(toPb(), ((Notification) obj).toPb());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("topic", getTopic()).toString();
+ }
+
+ com.google.api.services.storage.model.Notification toPb() {
+ com.google.api.services.storage.model.Notification notificationPb =
+ new com.google.api.services.storage.model.Notification();
+ notificationPb.setId(generatedId);
+ notificationPb.setEtag(etag);
+ if (customAttributes != null) {
+ notificationPb.setCustomAttributes(customAttributes);
+ }
+ if (eventTypes != null) {
+ notificationPb.setEventTypes(eventTypes);
}
- if (o == null || getClass() != o.getClass()) {
- return false;
+ if (objectNamePrefix != null) {
+ notificationPb.setObjectNamePrefix(objectNamePrefix);
}
- if (!super.equals(o)) {
- return false;
+ if (payloadFormat != null) {
+ notificationPb.setPayloadFormat(payloadFormat.toString());
+ } else {
+ notificationPb.setPayloadFormat(PayloadFormat.NONE.toString());
}
- Notification that = (Notification) o;
- return Objects.equals(toPb(), that.toPb()) && Objects.equals(options, that.options);
+ notificationPb.setSelfLink(selfLink);
+ notificationPb.setTopic(topic);
+
+ return notificationPb;
}
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), options, storage);
+ /**
+ * Creates a {@code Notification} object for the provided topic name.
+ *
+ * @param topic The name of the topic. It must have the format
+ * "projects/{project}/topics/{topic}".
+ */
+ public static Notification of(String topic) {
+ PATH_TEMPLATE.validatedMatch(topic, "topic name must be in valid format");
+ return newBuilder(topic).build();
+ }
+
+ /** Returns a builder for the current notification. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ /**
+ * Returns a {@code Notification} builder where the topic's name is set to the provided name.
+ *
+ * @param topic The name of the topic. It must have the format
+ * "projects/{project}/topics/{topic}".
+ */
+ public static Builder newBuilder(String topic) {
+ PATH_TEMPLATE.validatedMatch(topic, "topic name must be in valid format");
+ return new Builder(topic);
}
- static Notification fromPb(
- Storage storage, com.google.api.services.storage.model.Notification notificationPb) {
- return new Notification(
- storage, new NotificationInfo.BuilderImpl(NotificationInfo.fromPb(notificationPb)));
+ static Notification fromPb(com.google.api.services.storage.model.Notification notificationPb) {
+ Builder builder = newBuilder(notificationPb.getTopic());
+ if (notificationPb.getId() != null) {
+ builder.setGeneratedId(notificationPb.getId());
+ }
+ if (notificationPb.getEtag() != null) {
+ builder.setEtag(notificationPb.getEtag());
+ }
+ if (notificationPb.getCustomAttributes() != null) {
+ builder.setCustomAttributes(notificationPb.getCustomAttributes());
+ }
+ if (notificationPb.getSelfLink() != null) {
+ builder.setSelfLink(notificationPb.getSelfLink());
+ }
+ if (notificationPb.getObjectNamePrefix() != null) {
+ builder.setObjectNamePrefix(notificationPb.getObjectNamePrefix());
+ }
+ if (notificationPb.getTopic() != null) {
+ builder.setTopic(notificationPb.getTopic());
+ }
+ if (notificationPb.getEventTypes() != null) {
+ builder.setEventTypes(notificationPb.getEventTypes());
+ }
+ if (notificationPb.getPayloadFormat() != null) {
+ builder.setPayloadFormat(PayloadFormat.valueOf(notificationPb.getPayloadFormat()));
+ }
+ return builder.build();
}
}
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/NotificationInfo.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/NotificationInfo.java
deleted file mode 100644
index d9653fec7..000000000
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/NotificationInfo.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.cloud.storage;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.api.pathtemplate.PathTemplate;
-import com.google.api.services.storage.model.Notification;
-import com.google.common.base.Function;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Google Storage Notification metadata;
- *
- * @see Concepts and
- * Terminology
- */
-public class NotificationInfo implements Serializable {
-
- private static final long serialVersionUID = 5725883368559753810L;
- private static final PathTemplate PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/topics/{topic}");
-
- public enum PayloadFormat {
- JSON_API_V1,
- NONE
- }
-
- static final Function FROM_PB_FUNCTION =
- new Function() {
- @Override
- public NotificationInfo apply(Notification pb) {
- return NotificationInfo.fromPb(pb);
- }
- };
- static final Function TO_PB_FUNCTION =
- new Function() {
- @Override
- public Notification apply(NotificationInfo NotificationInfo) {
- return NotificationInfo.toPb();
- }
- };
- private final String generatedId;
- private final String topic;
- private final List eventTypes;
- private final Map customAttributes;
- private final PayloadFormat payloadFormat;
- private final String objectNamePrefix;
- private final String etag;
- private final String selfLink;
-
- /** Builder for {@code NotificatioInfo}. */
- public abstract static class Builder {
- Builder() {}
-
- public abstract Builder setGeneratedId(String generatedId);
-
- public abstract Builder setSelfLink(String selfLink);
-
- public abstract Builder setTopic(String topic);
-
- public abstract Builder setPayloadFormat(PayloadFormat payloadFormat);
-
- public abstract Builder setObjectNamePrefix(String objectNamePrefix);
-
- public abstract Builder setEventTypes(Iterable eventTypes);
-
- public abstract Builder setEtag(String etag);
-
- public abstract Builder setCustomAttributes(Map customAttributes);
-
- /** Creates a {@code NotificationInfo} object. */
- public abstract NotificationInfo build();
- }
-
- public static final class BuilderImpl extends Builder {
-
- private String generatedId;
- private String topic;
- private List eventTypes;
- private Map customAttributes;
- private PayloadFormat payloadFormat;
- private String objectNamePrefix;
- private String etag;
- private String selfLink;
-
- BuilderImpl(String topic) {
- this.topic = topic;
- }
-
- BuilderImpl(NotificationInfo NotificationInfo) {
- generatedId = NotificationInfo.generatedId;
- etag = NotificationInfo.etag;
- selfLink = NotificationInfo.selfLink;
- topic = NotificationInfo.topic;
- eventTypes = NotificationInfo.eventTypes;
- customAttributes = NotificationInfo.customAttributes;
- payloadFormat = NotificationInfo.payloadFormat;
- objectNamePrefix = NotificationInfo.objectNamePrefix;
- }
-
- @Override
- public Builder setGeneratedId(String generatedId) {
- this.generatedId = generatedId;
- return this;
- }
-
- @Override
- public Builder setSelfLink(String selfLink) {
- this.selfLink = selfLink;
- return this;
- }
-
- /** The name of the topic. It must have the format "projects/{project}/topics/{topic}". */
- @Override
- public Builder setTopic(String topic) {
- this.topic = topic;
- return this;
- }
-
- @Override
- public Builder setPayloadFormat(PayloadFormat payloadFormat) {
- this.payloadFormat = payloadFormat;
- return this;
- }
-
- @Override
- public Builder setObjectNamePrefix(String objectNamePrefix) {
- this.objectNamePrefix = objectNamePrefix;
- return this;
- }
-
- @Override
- public Builder setEventTypes(Iterable eventTypes) {
- this.eventTypes = eventTypes != null ? ImmutableList.copyOf(eventTypes) : null;
- return this;
- }
-
- @Override
- public Builder setEtag(String etag) {
- this.etag = etag;
- return this;
- }
-
- @Override
- public Builder setCustomAttributes(Map customAttributes) {
- this.customAttributes =
- customAttributes != null ? ImmutableMap.copyOf(customAttributes) : null;
- return this;
- }
-
- @Override
- public NotificationInfo build() {
- checkNotNull(topic);
- return new NotificationInfo(this);
- }
- }
-
- NotificationInfo(BuilderImpl builder) {
- generatedId = builder.generatedId;
- etag = builder.etag;
- selfLink = builder.selfLink;
- topic = builder.topic;
- eventTypes = builder.eventTypes;
- customAttributes = builder.customAttributes;
- payloadFormat = builder.payloadFormat;
- objectNamePrefix = builder.objectNamePrefix;
- }
-
- /** Returns the service-generated id for the notification. */
- public String getGeneratedId() {
- return generatedId;
- }
-
- /** Returns the topic to which this subscription publishes. */
- public String getTopic() {
- return topic;
- }
-
- /** Returns the canonical URI of this topic as a string. */
- public String getSelfLink() {
- return selfLink;
- }
-
- /** Returns the desired content of the Payload. */
- public PayloadFormat getPayloadFormat() {
- return payloadFormat;
- }
-
- /** Returns the object name prefix for which this notification configuration applies. */
- public String getObjectNamePrefix() {
- return objectNamePrefix;
- }
-
- /**
- * Returns HTTP 1.1 Entity tag for the notification.
- *
- * @see Entity Tags
- */
- public String getEtag() {
- return etag;
- }
-
- /**
- * Returns the list of event types that this notification will apply to. If empty, notifications
- * will be sent on all event types.
- *
- * @see Cross-Origin Resource Sharing
- * (CORS)
- */
- public List getEventTypes() {
- return eventTypes;
- }
-
- /**
- * Returns the list of additional attributes to attach to each Cloud PubSub message published for
- * this notification subscription.
- *
- * @see
- * About Access Control Lists
- */
- public Map getCustomAttributes() {
- return customAttributes;
- }
-
- /** Returns a builder for the current notification. */
- public Builder toBuilder() {
- return new BuilderImpl(this);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(getTopic());
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj == this
- || obj != null
- && obj.getClass().equals(NotificationInfo.class)
- && Objects.equals(toPb(), ((NotificationInfo) obj).toPb());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this).add("topic", getTopic()).toString();
- }
-
- Notification toPb() {
- Notification notificationPb = new Notification();
- notificationPb.setId(generatedId);
- notificationPb.setEtag(etag);
- if (customAttributes != null) {
- notificationPb.setCustomAttributes(customAttributes);
- }
- if (eventTypes != null) {
- notificationPb.setEventTypes(eventTypes);
- }
- if (objectNamePrefix != null) {
- notificationPb.setObjectNamePrefix(objectNamePrefix);
- }
- if (payloadFormat != null) {
- notificationPb.setPayloadFormat(payloadFormat.toString());
- } else {
- notificationPb.setPayloadFormat(PayloadFormat.NONE.toString());
- }
- notificationPb.setSelfLink(selfLink);
- notificationPb.setTopic(topic);
-
- return notificationPb;
- }
-
- /**
- * Creates a {@code NotificationInfo} object for the provided topic name.
- *
- * @param topic The name of the topic. It must have the format
- * "projects/{project}/topics/{topic}".
- */
- public static NotificationInfo of(String topic) {
- PATH_TEMPLATE.validatedMatch(topic, "topic name must be in valid format");
- return newBuilder(topic).build();
- }
-
- /**
- * Returns a {@code NotificationInfo} builder where the topic's name is set to the provided name.
- *
- * @param topic The name of the topic. It must have the format
- * "projects/{project}/topics/{topic}".
- */
- public static Builder newBuilder(String topic) {
- PATH_TEMPLATE.validatedMatch(topic, "topic name must be in valid format");
- return new BuilderImpl(topic);
- }
-
- static NotificationInfo fromPb(Notification notificationPb) {
- Builder builder = newBuilder(notificationPb.getTopic());
- if (notificationPb.getId() != null) {
- builder.setGeneratedId(notificationPb.getId());
- }
- if (notificationPb.getEtag() != null) {
- builder.setEtag(notificationPb.getEtag());
- }
- if (notificationPb.getCustomAttributes() != null) {
- builder.setCustomAttributes(notificationPb.getCustomAttributes());
- }
- if (notificationPb.getSelfLink() != null) {
- builder.setSelfLink(notificationPb.getSelfLink());
- }
- if (notificationPb.getObjectNamePrefix() != null) {
- builder.setObjectNamePrefix(notificationPb.getObjectNamePrefix());
- }
- if (notificationPb.getTopic() != null) {
- builder.setTopic(notificationPb.getTopic());
- }
- if (notificationPb.getEventTypes() != null) {
- builder.setEventTypes(notificationPb.getEventTypes());
- }
- if (notificationPb.getPayloadFormat() != null) {
- builder.setPayloadFormat(PayloadFormat.valueOf(notificationPb.getPayloadFormat()));
- }
- return builder.build();
- }
-}
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 d0cc60518..34761ef90 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
@@ -3627,33 +3627,40 @@ List testIamPermissions(
ServiceAccount getServiceAccount(String projectId);
/**
- * Creates a notification with the specified entity on the specified bucket.
+ * Creates a notification subscription for a given bucket.
*
- * @return the notification that was created.
+ * @param bucket name of the bucket
+ * @param notification a {@code Notification} object
+ * @return the notification that was created
* @throws StorageException upon failure
*/
- Notification createNotification(String bucket, NotificationInfo notificationInfo);
+ Notification createNotification(String bucket, Notification notification);
/**
- * Get the notification with the specified name on the specified object.
+ * Gets the notification with the specified name on the bucket.
*
- * @return the notification object that exist on the bucket.
+ * @param bucket name of the bucket
+ * @param notification notification ID
+ * @return the notification object that exist on the bucket or {@code null} if not found
* @throws StorageException upon failure
*/
Notification getNotification(String bucket, String notification);
/**
- * List the notifications for the provided bucket.
+ * Retrieves a list of notification subscriptions for a given bucket.
*
+ * @param bucket name of the bucket
* @return a list of {@link Notification} objects that exist on the bucket.
* @throws StorageException upon failure
*/
List listNotifications(String bucket);
/**
- * Deletes the notification with the specified name on the specified object.
+ * Deletes the notification subscription with the specified name on the bucket.
*
- * @return {@code true} if the notification was deleted, {@code false} if it was not found
+ * @param bucket name of the bucket
+ * @param notification ID of the notification to delete
+ * @return {@code true} if the notification has been deleted, {@code false} if not found
* @throws StorageException upon failure
*/
boolean deleteNotification(String bucket, String notification);
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 a4345e572..1cbf2957d 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
@@ -1375,13 +1375,10 @@ private U run(ResultRetryAlgorithm> algorithm, Callable c, Function<
}
@Override
- public Notification createNotification(
- final String bucket, final NotificationInfo notificationInfo) {
- final com.google.api.services.storage.model.Notification notificationPb =
- notificationInfo.toPb();
+ public Notification createNotification(final String bucket, final Notification notification) {
+ final com.google.api.services.storage.model.Notification notificationPb = notification.toPb();
try {
return Notification.fromPb(
- this,
runWithRetries(
new Callable() {
@Override
@@ -1411,7 +1408,7 @@ public com.google.api.services.storage.model.Notification call() {
getOptions().getRetrySettings(),
EXCEPTION_HANDLER,
getOptions().getClock());
- return answer == null ? null : Notification.fromPb(this, answer);
+ return answer == null ? null : Notification.fromPb(answer);
} catch (RetryHelperException e) {
throw StorageException.translateAndThrow(e);
}
@@ -1431,17 +1428,7 @@ public List call() {
getOptions().getRetrySettings(),
EXCEPTION_HANDLER,
getOptions().getClock());
- return answer == null
- ? null
- : Lists.transform(
- answer,
- new Function() {
- @Override
- public Notification apply(
- com.google.api.services.storage.model.Notification notificationPb) {
- return Notification.fromPb(getOptions().getService(), notificationPb);
- }
- });
+ return Lists.transform(answer, Notification.FROM_PB_FUNCTION);
} catch (RetryHelperException e) {
throw StorageException.translateAndThrow(e);
}
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java
index f9fbb1b51..932c11581 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java
@@ -561,15 +561,15 @@ TestIamPermissionsResponse testIamPermissions(
String bucket, List permissions, Map