From 4cf7bcf0a1c09fd12ebfbe5e3480e55f72a53b4c Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 20 Oct 2020 00:35:16 +0200 Subject: [PATCH] chore(deps): update dependency google-cloud-pubsub to v2 (#46) Updated sample to use pubsub v2 --- .../samples/snippets/requirements.txt | 2 +- .../samples/snippets/samples.py | 4 ++-- .../samples/snippets/samples_test.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/google-cloud-containeranalysis/samples/snippets/requirements.txt b/packages/google-cloud-containeranalysis/samples/snippets/requirements.txt index 605f7e85a4d7..33b4937a9bb2 100644 --- a/packages/google-cloud-containeranalysis/samples/snippets/requirements.txt +++ b/packages/google-cloud-containeranalysis/samples/snippets/requirements.txt @@ -1,4 +1,4 @@ -google-cloud-pubsub==1.7.0 +google-cloud-pubsub==2.1.0 google-cloud-containeranalysis==2.0.0 grafeas==1.0.1 pytest==5.3.0; python_version > "3.0" diff --git a/packages/google-cloud-containeranalysis/samples/snippets/samples.py b/packages/google-cloud-containeranalysis/samples/snippets/samples.py index caf08990ba84..48d193be7919 100644 --- a/packages/google-cloud-containeranalysis/samples/snippets/samples.py +++ b/packages/google-cloud-containeranalysis/samples/snippets/samples.py @@ -265,11 +265,11 @@ def create_occurrence_subscription(subscription_id, project_id): topic_id = 'container-analysis-occurrences-v1' client = SubscriberClient() - topic_name = client.topic_path(project_id, topic_id) + topic_name = f"projects/{project_id}/topics/{topic_id}" subscription_name = client.subscription_path(project_id, subscription_id) success = True try: - client.create_subscription(subscription_name, topic_name) + client.create_subscription({"name": subscription_name, "topic": topic_name}) except AlreadyExists: # if subscription already exists, do nothing pass diff --git a/packages/google-cloud-containeranalysis/samples/snippets/samples_test.py b/packages/google-cloud-containeranalysis/samples/snippets/samples_test.py index 7a1bd8152cfb..7145dd75943a 100644 --- a/packages/google-cloud-containeranalysis/samples/snippets/samples_test.py +++ b/packages/google-cloud-containeranalysis/samples/snippets/samples_test.py @@ -152,7 +152,7 @@ def test_pubsub(self): client = SubscriberClient() try: topic_id = 'container-analysis-occurrences-v1' - topic_name = client.topic_path(PROJECT_ID, topic_id) + topic_name = {"name": f"projects/{PROJECT_ID}/topics/{topic_id}"} publisher = PublisherClient() publisher.create_topic(topic_name) except AlreadyExists: @@ -185,7 +185,7 @@ def test_pubsub(self): assert message_count <= receiver.msg_count finally: # clean up - client.delete_subscription(subscription_name) + client.delete_subscription({"subscription": subscription_name}) def test_poll_discovery_occurrence(self): # try with no discovery occurrence