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 1 commit
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
16 changes: 14 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,13 @@ 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'
>>> topic_name = 'projects/my-project/topics/my-topic'
>>> subscription = {
... 'name': subscription_name,
... 'topic': topic_name,
plamut marked this conversation as resolved.
Show resolved Hide resolved
... 'ack_deadline_seconds': ack_deadline_seconds,
... }
>>> paths_element = 'ack_deadline_seconds'
>>> paths = [paths_element]
>>> update_mask = {'paths': paths}
Expand Down Expand Up @@ -1493,7 +1499,13 @@ def update_snapshot(
>>>
>>> seconds = 123456
>>> expire_time = {'seconds': seconds}
>>> snapshot = {'expire_time': expire_time}
>>> snapshot_name = 'projects/my-project/snapshots/my-snapshot'
>>> topic_name = 'projects/my-project/topics/my-topic'
>>> snapshot = {
... 'name': snapshot_name,
... 'topic': topic_name,
plamut marked this conversation as resolved.
Show resolved Hide resolved
... 'expire_time': expire_time,
... }
>>> paths_element = 'expire_time'
>>> paths = [paths_element]
>>> update_mask = {'paths': paths}
Expand Down
35 changes: 35 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,39 @@ 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'
>>> topic_name = 'projects/my-project/topics/my-topic'
>>> subscription = {
... 'name': subscription_name,
... 'topic': topic_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'
>>> topic_name = 'projects/my-project/topics/my-topic'
>>> snapshot = {
... 'name': snapshot_name,
... 'topic': topic_name,
... 'expire_time': expire_time,
... }""",
prefix=" " * 12,
)
)


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