def set_subscription_policy(topic_name, subscription_name):
Sets the IAM policy for a topic.
pubsub_client = pubsub.Client()
topic = pubsub_client.topic(topic_name)
subscription = topic.subscription(subscription_name)
policy = subscription.get_iam_policy()
// Add all users as viewers.
policy["roles/viewer"] = [policy.all_users()]
// // Add a group as editors.
editors = policy.get("roles/editor", [])
editors.add(policy.group("cloud-logs@google.com"))
policy["roles/editor"] = editors
// Set the policy
subscription.set_iam_policy(policy)