Class Sink
- java.lang.Object
-
- com.google.cloud.logging.SinkInfo
-
- com.google.cloud.logging.Sink
-
- All Implemented Interfaces:
Serializable
public class Sink extends SinkInfo
Cloud Logging sinks can be used to control the export of your logs. Each sink specifies the export of a set of log entries to a certain destination. A sink consists of a name, unique to the project, a filter for choosing the log entries to export and a destination for the log entries.Sink destination can either be a Google Cloud Storage bucket (see
SinkInfo.Destination.BucketDestination
, a Google Cloud BigQuery dataset (seeSinkInfo.Destination.DatasetDestination
) or a Google CloudPub/Sub topic (seeSinkInfo.Destination.TopicDestination
).Sink
adds a layer of service-related functionality overSinkInfo
. Objects of this class are immutable. To get aSink
object with the most recent information usereload()
orreloadAsync()
.- See Also:
- About Sinks, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Sink.Builder
A builder forSink
objects.-
Nested classes/interfaces inherited from class com.google.cloud.logging.SinkInfo
SinkInfo.Destination, SinkInfo.VersionFormat
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
delete()
Deletes this sink.com.google.api.core.ApiFuture<Boolean>
deleteAsync()
Sends a request for deleting this sink.boolean
equals(Object obj)
Logging
getLogging()
Returns the sinks'sLogging
object used to issue requests.int
hashCode()
Sink
reload()
Fetches current sink's latest information.com.google.api.core.ApiFuture<Sink>
reloadAsync()
Sends a request to fetch current sink's latest information.Sink.Builder
toBuilder()
Returns a builder for thisSinkInfo
object.Sink
update()
Updates current sink.com.google.api.core.ApiFuture<Sink>
updateAsync()
Sends a request to update current sink.-
Methods inherited from class com.google.cloud.logging.SinkInfo
getDestination, getFilter, getName, getVersionFormat, newBuilder, of, toString
-
-
-
-
Method Detail
-
toBuilder
public Sink.Builder toBuilder()
Description copied from class:SinkInfo
Returns a builder for thisSinkInfo
object.
-
getLogging
public Logging getLogging()
Returns the sinks'sLogging
object 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:
true
if the sink was deleted,false
if it was not found- Throws:
LoggingException
- upon failure
-
deleteAsync
public com.google.api.core.ApiFuture<Boolean> deleteAsync()
Sends a request for deleting this sink. This method returns aApiFuture
object to consume the result.Future.get()
returnstrue
if the sink was deleted,false
if 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
public Sink reload()
Fetches current sink's latest information. Returnsnull
if 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
Sink
object with latest information ornull
if not found - Throws:
LoggingException
- upon failure
-
reloadAsync
public com.google.api.core.ApiFuture<Sink> reloadAsync()
Sends a request to fetch current sink's latest information. This method returns aApiFuture
object to consume the result.Future.get()
returns aSink
object with latest information ornull
if 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
public Sink 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
Sink
object with updated information - Throws:
LoggingException
- upon failure
-
updateAsync
public com.google.api.core.ApiFuture<Sink> updateAsync()
Sends a request to update current sink. If the sink does not exist, it is created. This method returns aApiFuture
object to consume the result.Future.get()
returns aSink
object 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
-
-