@snippet
def topic_iam_policy(client, to_delete):
 TOPIC_NAME = ('topic_iam_policy-%d' % (_millis(),))
 topic = client.topic(TOPIC_NAME)
 topic.create()
 to_delete.append(topic)
 policy = topic.get_iam_policy()
 assert (len(policy.viewers) == 0)
 assert (len(policy.editors) == 0)
 assert (len(policy.owners) == 0)
 ALL_USERS = policy.all_users()
 policy.viewers.add(ALL_USERS)
 LOGS_GROUP = policy.group('cloud-logs@google.com')
 policy.editors.add(LOGS_GROUP)
 new_policy = topic.set_iam_policy(policy)
 assert (ALL_USERS in new_policy.viewers)
 assert (LOGS_GROUP in new_policy.editors)

@ snippet def topic_iam_policy ( client , to_delete ) : TOPIC_NAME = ( 'topic_iam_policy-%d' % ( _millis ( ) , ) ) topic = client . topic ( TOPIC_NAME ) topic . create ( ) to_delete . append ( topic ) policy = topic . get_iam_policy ( ) assert ( len ( policy . viewers ) == 0 ) assert ( len ( policy . editors ) == 0 ) assert ( len ( policy . owners ) == 0 ) ALL_USERS = policy . all_users ( ) policy . viewers . add ( ALL_USERS ) LOGS_GROUP = policy . group ( 'cloud-logs@google.com' ) policy . editors . add ( LOGS_GROUP ) new_policy = topic . set_iam_policy ( policy ) assert ( ALL_USERS in new_policy . viewers ) assert ( LOGS_GROUP in new_policy . editors )
fetch / set a topics iam policy .