Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix update subscription/snapshot/topic samples #113

Merged
merged 3 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions google/cloud/pubsub_v1/gapic/publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,13 @@ def update_topic(
>>>
>>> client = pubsub_v1.PublisherClient()
>>>
>>> # TODO: Initialize `topic`:
>>> topic = {}
>>> topic_name = 'projects/my-project/topics/my-topic'
>>> topic_labels = {'source': 'external'}
>>> topic = {'name': topic_name, 'labels': topic_labels}
>>>
>>> # TODO: Initialize `update_mask`:
>>> update_mask = {}
>>> paths_element = 'labels'
>>> paths = [paths_element]
>>> update_mask = {'paths': paths}
>>>
>>> response = client.update_topic(topic, update_mask)

Expand Down
12 changes: 10 additions & 2 deletions google/cloud/pubsub_v1/gapic/subscriber_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,11 @@ def update_subscription(
>>> client = pubsub_v1.SubscriberClient()
>>>
>>> ack_deadline_seconds = 42
>>> subscription = {'ack_deadline_seconds': ack_deadline_seconds}
>>> subscription_name = 'projects/my-project/subscriptions/my-subscription'
>>> subscription = {
... 'name': subscription_name,
... 'ack_deadline_seconds': ack_deadline_seconds,
... }
>>> paths_element = 'ack_deadline_seconds'
>>> paths = [paths_element]
>>> update_mask = {'paths': paths}
Expand Down Expand Up @@ -1493,7 +1497,11 @@ def update_snapshot(
>>>
>>> seconds = 123456
>>> expire_time = {'seconds': seconds}
>>> snapshot = {'expire_time': expire_time}
>>> snapshot_name = 'projects/my-project/snapshots/my-snapshot'
>>> snapshot = {
... 'name': snapshot_name,
... 'expire_time': expire_time,
... }
>>> paths_element = 'expire_time'
>>> paths = [paths_element]
>>> update_mask = {'paths': paths}
Expand Down
56 changes: 56 additions & 0 deletions synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

"""This script is used to synthesize generated parts of this library."""

import textwrap

import synthtool as s
from synthtool import gcp

Expand Down Expand Up @@ -183,6 +185,60 @@ def _merge_dict(d1, d2):
"from google.iam.v1 import iam_policy_pb2_grpc as iam_policy_pb2",
)

# Fix incomplete docstring examples.
s.replace(
"google/cloud/pubsub_v1/gapic/subscriber_client.py",
r"\s+>>> subscription = \{'ack_deadline_seconds': ack_deadline_seconds\}",
textwrap.indent(
"""
>>> subscription_name = 'projects/my-project/subscriptions/my-subscription'
>>> subscription = {
... 'name': subscription_name,
... 'ack_deadline_seconds': ack_deadline_seconds,
... }""",
prefix=" " * 12,
)
)

s.replace(
"google/cloud/pubsub_v1/gapic/subscriber_client.py",
r"\s+>>> snapshot = \{'expire_time': expire_time\}",
textwrap.indent(
"""
>>> snapshot_name = 'projects/my-project/snapshots/my-snapshot'
>>> snapshot = {
... 'name': snapshot_name,
... 'expire_time': expire_time,
... }""",
prefix=" " * 12,
)
)

s.replace(
"google/cloud/pubsub_v1/gapic/publisher_client.py",
r"\s+>>> # TODO: Initialize `topic`:\n\s+>>> topic = \{\}\n",
textwrap.indent(
"""
>>> topic_name = 'projects/my-project/topics/my-topic'
>>> topic_labels = {'source': 'external'}
>>> topic = {'name': topic_name, 'labels': topic_labels}
""",
prefix=" " * 12,
),
)

s.replace(
"google/cloud/pubsub_v1/gapic/publisher_client.py",
r"\s+>>> # TODO: Initialize `update_mask`:\n\s+>>> update_mask = \{\}\n",
textwrap.indent(
"""
>>> paths_element = 'labels'
>>> paths = [paths_element]
>>> update_mask = {'paths': paths}
""",
prefix=" " * 12,
),
)

# ----------------------------------------------------------------------------
# Add templated files
Expand Down