@snippet
def sink_pubsub(client, to_delete):
 topic = _sink_pubsub_setup(client)
 to_delete.append(topic)
 SINK_NAME = ('robots-pubsub-%d' % (_millis(),))
 FILTER = 'logName:apache-access AND textPayload:robot'
 UPDATED_FILTER = 'textPayload:robot'
 DESTINATION = ('pubsub.googleapis.com/%s' % (topic.full_name,))
 sink = client.sink(SINK_NAME, filter_=FILTER, destination=DESTINATION)
 assert (not sink.exists())
 sink.create()
 assert sink.exists()
 to_delete.insert(0, sink)
 for sink in client.list_sinks():
  do_something_with(sink)
 existing_sink = client.sink(SINK_NAME)
 existing_sink.reload()
 assert (existing_sink.filter_ == FILTER)
 assert (existing_sink.destination == DESTINATION)
 existing_sink.filter_ = UPDATED_FILTER
 existing_sink.update()
 existing_sink.reload()
 assert (existing_sink.filter_ == UPDATED_FILTER)
 sink.delete()
 to_delete.pop(0)

@ snippet def sink_pubsub ( client , to_delete ) : topic = _sink_pubsub_setup ( client ) to_delete . append ( topic ) SINK_NAME = ( 'robots-pubsub-%d' % ( _millis ( ) , ) ) FILTER = 'logName:apache-access AND textPayload:robot' UPDATED_FILTER = 'textPayload:robot' DESTINATION = ( 'pubsub.googleapis.com/%s' % ( topic . full_name , ) ) sink = client . sink ( SINK_NAME , filter_ = FILTER , destination = DESTINATION ) assert ( not sink . exists ( ) ) sink . create ( ) assert sink . exists ( ) to_delete . insert ( 0 , sink ) for sink in client . list_sinks ( ) : do_something_with ( sink ) existing_sink = client . sink ( SINK_NAME ) existing_sink . reload ( ) assert ( existing_sink . filter_ == FILTER ) assert ( existing_sink . destination == DESTINATION ) existing_sink . filter_ = UPDATED_FILTER existing_sink . update ( ) existing_sink . reload ( ) assert ( existing_sink . filter_ == UPDATED_FILTER ) sink . delete ( ) to_delete . pop ( 0 )
sink log entries to pubsub .