@snippet
def topic_subscription(client, to_delete):
 TOPIC_NAME = ('topic_subscription-%d' % (_millis(),))
 SUB_DEFAULTS = ('topic_subscription-defaults-%d' % (_millis(),))
 SUB_ACK90 = ('topic_subscription-ack90-%d' % (_millis(),))
 topic = client.topic(TOPIC_NAME)
 topic.create()
 to_delete.append(topic)
 sub_defaults = topic.subscription(SUB_DEFAULTS)
 sub_defaults.create()
 to_delete.append(sub_defaults)
 expected_names = set()
 expected_names.add(sub_defaults.full_name)
 sub_ack90 = topic.subscription(SUB_ACK90, ack_deadline=90)
 sub_ack90.create()
 to_delete.append(sub_ack90)
 expected_names.add(sub_ack90.full_name)
 sub_names = set()
 def do_something_with(sub):
  sub_names.add(sub.full_name)
 for subscription in topic.list_subscriptions():
  do_something_with(subscription)
 assert sub_names.issuperset(expected_names)

@ snippet def topic_subscription ( client , to_delete ) : TOPIC_NAME = ( 'topic_subscription-%d' % ( _millis ( ) , ) ) SUB_DEFAULTS = ( 'topic_subscription-defaults-%d' % ( _millis ( ) , ) ) SUB_ACK90 = ( 'topic_subscription-ack90-%d' % ( _millis ( ) , ) ) topic = client . topic ( TOPIC_NAME ) topic . create ( ) to_delete . append ( topic ) sub_defaults = topic . subscription ( SUB_DEFAULTS ) sub_defaults . create ( ) to_delete . append ( sub_defaults ) expected_names = set ( ) expected_names . add ( sub_defaults . full_name ) sub_ack90 = topic . subscription ( SUB_ACK90 , ack_deadline = 90 ) sub_ack90 . create ( ) to_delete . append ( sub_ack90 ) expected_names . add ( sub_ack90 . full_name ) sub_names = set ( ) def do_something_with ( sub ) : sub_names . add ( sub . full_name ) for subscription in topic . list_subscriptions ( ) : do_something_with ( subscription ) assert sub_names . issuperset ( expected_names )
create subscriptions to a topic .