34577913e8d62f0db23231f4882263b6825fa271,pubsub/cloud-client/iam.py,,set_subscription_policy,#Any#Any#,82
Before Change
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)
print("IAM policy for subscription {} on topic {} set.".format(
topic.name, subscription.name))
def check_topic_permissions(topic_name):
After Change
// Set the policy
policy = client.set_iam_policy(subscription_path, policy)
print("IAM policy for subscription {} set: {}".format(
subscription_name, policy))
def check_topic_permissions(project, topic_name):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 10
Instances
Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 34577913e8d62f0db23231f4882263b6825fa271
Time: 2017-08-28
Author: jonwayne@google.com
File Name: pubsub/cloud-client/iam.py
Class Name:
Method Name: set_subscription_policy
Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 34577913e8d62f0db23231f4882263b6825fa271
Time: 2017-08-28
Author: jonwayne@google.com
File Name: pubsub/cloud-client/subscriber.py
Class Name:
Method Name: delete_subscription
Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 34577913e8d62f0db23231f4882263b6825fa271
Time: 2017-08-28
Author: jonwayne@google.com
File Name: pubsub/cloud-client/iam.py
Class Name:
Method Name: set_subscription_policy
Project Name: GoogleCloudPlatform/python-docs-samples
Commit Name: 34577913e8d62f0db23231f4882263b6825fa271
Time: 2017-08-28
Author: jonwayne@google.com
File Name: pubsub/cloud-client/iam.py
Class Name:
Method Name: get_subscription_policy