diff --git a/samples/snippets/publisher.py b/samples/snippets/publisher.py index d1b760280..78dff307d 100644 --- a/samples/snippets/publisher.py +++ b/samples/snippets/publisher.py @@ -134,7 +134,7 @@ def publish_messages_with_custom_attributes(project_id, topic_id): def publish_messages_with_error_handler(project_id, topic_id): - # [START pubsub_publish_messages_error_handler] + # [START pubsub_publish_with_error_handler] """Publishes multiple messages to a Pub/Sub topic with an error handler.""" import time @@ -173,7 +173,7 @@ def callback(f): time.sleep(5) print("Published message with error handler.") - # [END pubsub_publish_messages_error_handler] + # [END pubsub_publish_with_error_handler] def publish_messages_with_batch_settings(project_id, topic_id): diff --git a/samples/snippets/quickstart/pub.py b/samples/snippets/quickstart/pub.py index 8585711f3..404bcbb77 100644 --- a/samples/snippets/quickstart/pub.py +++ b/samples/snippets/quickstart/pub.py @@ -14,15 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START pubsub_quickstart_pub_all] import argparse import time -# [START pubsub_quickstart_pub_deps] from google.cloud import pubsub_v1 -# [END pubsub_quickstart_pub_deps] - def get_callback(api_future, data, ref): """Wrap message data in the context of the callback function.""" @@ -48,10 +44,8 @@ def callback(api_future): def pub(project_id, topic_id): """Publishes a message to a Pub/Sub topic.""" - # [START pubsub_quickstart_pub_client] # Initialize a Publisher client. client = pubsub_v1.PublisherClient() - # [END pubsub_quickstart_pub_client] # Create a fully qualified identifier in the form of # `projects/{project_id}/topics/{topic_id}` topic_path = client.topic_path(project_id, topic_id) @@ -83,4 +77,3 @@ def pub(project_id, topic_id): args = parser.parse_args() pub(args.project_id, args.topic_id) -# [END pubsub_quickstart_pub_all] diff --git a/samples/snippets/quickstart/sub.py b/samples/snippets/quickstart/sub.py index efe008915..492d312f9 100644 --- a/samples/snippets/quickstart/sub.py +++ b/samples/snippets/quickstart/sub.py @@ -14,21 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START pubsub_quickstart_sub_all] import argparse -# [START pubsub_quickstart_sub_deps] from google.cloud import pubsub_v1 -# [END pubsub_quickstart_sub_deps] - def sub(project_id, subscription_id): """Receives messages from a Pub/Sub subscription.""" - # [START pubsub_quickstart_sub_client] # Initialize a Subscriber client subscriber_client = pubsub_v1.SubscriberClient() - # [END pubsub_quickstart_sub_client] # Create a fully qualified identifier in the form of # `projects/{project_id}/subscriptions/{subscription_id}` subscription_path = subscriber_client.subscription_path(project_id, subscription_id) @@ -66,4 +60,3 @@ def callback(message): args = parser.parse_args() sub(args.project_id, args.subscription_id) -# [END pubsub_quickstart_sub_all]