Skip to content

Commit ff46bec

Browse files
authored
docs: use new call syntax in subscriber docs (googleapis#203)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [X] Appropriate docs were updated (if necessary) Fixes googleapis#198 🦕
1 parent 9667ef1 commit ff46bec

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

docs/subscriber/index.rst

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ to subscribe to, and it must already exist. Once you have that, it is easy:
3838
# your application.
3939
sub_path = subscriber.subscription_path(PROJECT, SUBSCRIPTION)
4040
topic_path = subscriber.topic_path(PROJECT, TOPIC)
41-
subscriber.create_subscription(sub_path, topic_path)
41+
subscriber.create_subscription(request={"name": sub_path, "topic": topic_path})
4242
4343
Once you have created a subscription (or if you already had one), the next
4444
step is to pull data from it.
@@ -55,13 +55,23 @@ To pull the messages synchronously, use the client's
5555
# Substitute PROJECT and SUBSCRIPTION with appropriate values for your
5656
# application.
5757
subscription_path = subscriber.subscription_path(PROJECT, SUBSCRIPTION)
58-
response = subscriber.pull(subscription_path, max_messages=5)
58+
response = subscriber.pull(
59+
request={
60+
"subscription": subscription_path,
61+
"max_messages": 5,
62+
}
63+
)
5964
6065
for msg in response.received_messages:
6166
print("Received message:", msg.message.data)
6267
6368
ack_ids = [msg.ack_id for msg in response.received_messages]
64-
subscriber.acknowledge(subscription_path, ack_ids)
69+
subscriber.acknowledge(
70+
request={
71+
"subscription": subscription_path,
72+
"ack_ids": ack_ids,
73+
}
74+
)
6575
6676
The method returns a :class:`~.pubsub_v1.types.PullResponse` instance that
6777
contains a list of received :class:`~.pubsub_v1.types.ReceivedMessage`
@@ -76,7 +86,13 @@ be dropped by this client and the backend will try to re-deliver them.
7686
7787
ack_ids = [] # TODO: populate with `ack_ids` of the messages to NACK
7888
ack_deadline_seconds = 0
79-
subscriber.modify_ack_deadline(subscription_path, ack_ids, ack_deadline_seconds)
89+
subscriber.modify_ack_deadline(
90+
request={
91+
"subscription": subscription_path,
92+
"ack_ids": ack_ids,
93+
"ack_deadline_seconds": ack_deadline_seconds,
94+
}
95+
)
8096
8197
8298
Pulling a Subscription Asynchronously

0 commit comments

Comments
 (0)