Skip to content

Commit df9b33d

Browse files
authored
chore(deps): update dependency google-cloud-pubsub to v2 (#46)
Updated sample to use pubsub v2
1 parent 594c83e commit df9b33d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

container_registry/container_analysis/snippets/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
google-cloud-pubsub==1.7.0
1+
google-cloud-pubsub==2.1.0
22
google-cloud-containeranalysis==2.0.0
33
grafeas==1.0.1
44
pytest==5.3.0; python_version > "3.0"

container_registry/container_analysis/snippets/samples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ def create_occurrence_subscription(subscription_id, project_id):
265265

266266
topic_id = 'container-analysis-occurrences-v1'
267267
client = SubscriberClient()
268-
topic_name = client.topic_path(project_id, topic_id)
268+
topic_name = f"projects/{project_id}/topics/{topic_id}"
269269
subscription_name = client.subscription_path(project_id, subscription_id)
270270
success = True
271271
try:
272-
client.create_subscription(subscription_name, topic_name)
272+
client.create_subscription({"name": subscription_name, "topic": topic_name})
273273
except AlreadyExists:
274274
# if subscription already exists, do nothing
275275
pass

container_registry/container_analysis/snippets/samples_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_pubsub(self):
152152
client = SubscriberClient()
153153
try:
154154
topic_id = 'container-analysis-occurrences-v1'
155-
topic_name = client.topic_path(PROJECT_ID, topic_id)
155+
topic_name = {"name": f"projects/{PROJECT_ID}/topics/{topic_id}"}
156156
publisher = PublisherClient()
157157
publisher.create_topic(topic_name)
158158
except AlreadyExists:
@@ -185,7 +185,7 @@ def test_pubsub(self):
185185
assert message_count <= receiver.msg_count
186186
finally:
187187
# clean up
188-
client.delete_subscription(subscription_name)
188+
client.delete_subscription({"subscription": subscription_name})
189189

190190
def test_poll_discovery_occurrence(self):
191191
# try with no discovery occurrence

0 commit comments

Comments
 (0)