Skip to content

Commit

Permalink
Use permission constants in usage docs.
Browse files Browse the repository at this point in the history
Addresses:
#1646 (comment)
  • Loading branch information
tseaver committed Mar 23, 2016
1 parent 53f5ebf commit 537424e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions docs/pubsub-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ Test permissions allowed by the current IAM policy on a topic:
.. doctest::

>>> from gcloud import pubsub
>>> from gcloud.pubsub.iam import OWNER_ROLE, WRITER_ROLE, READER_ROLE
>>> client = pubsub.Client()
>>> topic = client.topic('topic_name')
>>> topic.test_iam_permissions(
... ['roles/reader', 'roles/writer', 'roles/owner']) # API request
['roles/reader', 'roles/writer']
>>> allowed = topic.test_iam_permissions(
... [READER_ROLE, WRITER_ROLE, OWNER_ROLE]) # API request
>>> allowed == [READER_ROLE, WRITER_ROLE]
True


Publish messages to a topic
Expand Down Expand Up @@ -347,9 +349,11 @@ Test permissions allowed by the current IAM policy on a subscription:
.. doctest::

>>> from gcloud import pubsub
>>> from gcloud.pubsub.iam import OWNER_ROLE, WRITER_ROLE, READER_ROLE
>>> client = pubsub.Client()
>>> topic = client.topic('topic_name')
>>> subscription = topic.subscription('subscription_name')
>>> subscription.test_iam_permissions(
... ['roles/reader', 'roles/writer', 'roles/owner']) # API request
['roles/reader', 'roles/writer']
>>> allowed = subscription.test_iam_permissions(
... [READER_ROLE, WRITER_ROLE, OWNER_ROLE]) # API request
>>> allowed == [READER_ROLE, WRITER_ROLE]
True

0 comments on commit 537424e

Please sign in to comment.