Class Sink
- All Implemented Interfaces:
Serializable
Sink destination can either be a Google Cloud Storage bucket (see SinkInfo.Destination.BucketDestination, a Google Cloud BigQuery dataset (see SinkInfo.Destination.DatasetDestination) or a Google CloudPub/Sub topic (see SinkInfo.Destination.TopicDestination).
Sink adds a layer of service-related functionality over SinkInfo. Objects of
this class are immutable. To get a Sink object with the most recent information use
reload() or reloadAsync().
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.google.cloud.logging.SinkInfo
SinkInfo.Destination, SinkInfo.VersionFormat -
Method Summary
Modifier and TypeMethodDescriptionbooleandelete()Deletes this sink.com.google.api.core.ApiFuture<Boolean>Sends a request for deleting this sink.final booleanReturns the sinks'sLoggingobject used to issue requests.final inthashCode()reload()Fetches current sink's latest information.com.google.api.core.ApiFuture<Sink>Sends a request to fetch current sink's latest information.Returns a builder for thisSinkInfoobject.update()Updates current sink.com.google.api.core.ApiFuture<Sink>Sends a request to update current sink.Methods inherited from class com.google.cloud.logging.SinkInfo
getDestination, getFilter, getName, getVersionFormat, newBuilder, of, toString
-
Method Details
-
toBuilder
Description copied from class:SinkInfoReturns a builder for thisSinkInfoobject. -
hashCode
public final int hashCode() -
equals
-
getLogging
Returns the sinks'sLoggingobject used to issue requests. -
delete
public boolean delete()Deletes this sink.Example of deleting the sink.
boolean deleted = sink.delete(); if (deleted) { // the sink was deleted } else { // the sink was not found }- Returns:
trueif the sink was deleted,falseif it was not found- Throws:
LoggingException- upon failure
-
deleteAsync
Sends a request for deleting this sink. This method returns aApiFutureobject to consume the result.Future.get()returnstrueif the sink was deleted,falseif it was not found.Example of asynchronously deleting the sink.
ApiFuture<Boolean> future = sink.deleteAsync(); // ... boolean deleted = future.get(); if (deleted) { // the sink was deleted } else { // the sink was not found }- Throws:
LoggingException- upon failure
-
reload
Fetches current sink's latest information. Returnsnullif the sink does not exist.Example of getting the sink's latest information.
Sink latestSink = sink.reload(); if (latestSink == null) { // the sink was not found }- Returns:
- a
Sinkobject with latest information ornullif not found - Throws:
LoggingException- upon failure
-
reloadAsync
Sends a request to fetch current sink's latest information. This method returns aApiFutureobject to consume the result.Future.get()returns aSinkobject with latest information ornullif not found.Example of asynchronously getting the sink's latest information.
ApiFuture<Sink> future = sink.reloadAsync(); // ... Sink latestSink = future.get(); if (latestSink == null) { // the sink was not found }- Throws:
LoggingException- upon failure
-
update
Updates current sink. If the sink does not exist, it is created.Example of updating the sink's information.
Sink updatedSink = sink.toBuilder() .setFilter("severity<=ERROR") .build() .update();- Returns:
- a
Sinkobject with updated information - Throws:
LoggingException- upon failure
-
updateAsync
Sends a request to update current sink. If the sink does not exist, it is created. This method returns aApiFutureobject to consume the result.Future.get()returns aSinkobject with updated information.Example of asynchronously updating the sink's information.
ApiFuture<Sink> future = sink.toBuilder() .setFilter("severity<=ERROR") .build() .updateAsync(); // ... Sink updatedSink = future.get();- Throws:
LoggingException- upon failure
-