diff --git a/google/cloud/pubsub_v1/gapic/publisher_client.py b/google/cloud/pubsub_v1/gapic/publisher_client.py index 1a981fefa..d59c247af 100644 --- a/google/cloud/pubsub_v1/gapic/publisher_client.py +++ b/google/cloud/pubsub_v1/gapic/publisher_client.py @@ -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) diff --git a/google/cloud/pubsub_v1/gapic/subscriber_client.py b/google/cloud/pubsub_v1/gapic/subscriber_client.py index e98a686bf..502f11a7f 100644 --- a/google/cloud/pubsub_v1/gapic/subscriber_client.py +++ b/google/cloud/pubsub_v1/gapic/subscriber_client.py @@ -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} @@ -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} diff --git a/synth.py b/synth.py index 645b7955b..9e475e781 100644 --- a/synth.py +++ b/synth.py @@ -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 @@ -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