Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c43329

Browse filesBrowse files
noerogdpebot
authored andcommitted
Change update_subscription to change endpoint URL. (GoogleCloudPlatform#1344)
The documentation specifies that the update subscription commands show how to update an endpoint URL: https://cloud.google.com/pubsub/docs/admin#update_a_subscription.
1 parent afd083d commit 2c43329
Copy full SHA for 2c43329

File tree

Expand file treeCollapse file tree

1 file changed

+18
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-11
lines changed

‎pubsub/cloud-client/subscriber.py

Copy file name to clipboardExpand all lines: pubsub/cloud-client/subscriber.py
+18-11Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ def create_push_subscription(project,
6262
topic_name,
6363
subscription_name,
6464
endpoint):
65-
"""Create a new push subscription on the given topic."""
65+
"""Create a new push subscription on the given topic.
66+
For example, endpoint is
67+
"https://my-test-project.appspot.com/push".
68+
"""
6669
subscriber = pubsub_v1.SubscriberClient()
6770
topic_path = subscriber.topic_path(project, topic_name)
6871
subscription_path = subscriber.subscription_path(
@@ -89,32 +92,36 @@ def delete_subscription(project, subscription_name):
8992
print('Subscription deleted: {}'.format(subscription_path))
9093

9194

92-
def update_subscription(project, subscription_name, ack_deadline_seconds):
95+
def update_subscription(project, subscription_name, endpoint):
9396
"""
94-
Updates an existing Pub/Sub subscription's ackDeadlineSeconds
95-
from 10 seconds (default). Note that certain properties of a
96-
subscription, such as its topic, are not modifiable.
97+
Updates an existing Pub/Sub subscription's push endpoint URL.
98+
Note that certain properties of a subscription, such as
99+
its topic, are not modifiable. For example, endpoint is
100+
"https://my-test-project.appspot.com/push".
97101
"""
98102
subscriber = pubsub_v1.SubscriberClient()
99103
subscription_path = subscriber.subscription_path(
100104
project, subscription_name)
101105

106+
push_config = pubsub_v1.types.PushConfig(
107+
push_endpoint=endpoint)
108+
102109
subscription = pubsub_v1.types.Subscription(
103110
name=subscription_path,
104-
ack_deadline_seconds=ack_deadline_seconds)
111+
push_config=push_config)
105112

106113
update_mask = {
107114
'paths': {
108-
'ack_deadline_seconds',
115+
'push_config',
109116
}
110117
}
111118

112119
subscriber.update_subscription(subscription, update_mask)
113120
result = subscriber.get_subscription(subscription_path)
114121

115122
print('Subscription updated: {}'.format(subscription_path))
116-
print('New ack_deadline_seconds value is: {}'.format(
117-
result.ack_deadline_seconds))
123+
print('New endpoint for subscription is: {}'.format(
124+
result.push_config))
118125

119126

120127
def receive_messages(project, subscription_name):
@@ -214,7 +221,7 @@ def callback(message):
214221
update_parser = subparsers.add_parser(
215222
'update', help=update_subscription.__doc__)
216223
update_parser.add_argument('subscription_name')
217-
update_parser.add_argument('ack_deadline_seconds', type=int)
224+
update_parser.add_argument('endpoint')
218225

219226
receive_parser = subparsers.add_parser(
220227
'receive', help=receive_messages.__doc__)
@@ -249,7 +256,7 @@ def callback(message):
249256
args.project, args.subscription_name)
250257
elif args.command == 'update':
251258
update_subscription(
252-
args.project, args.subscription_name, args.ack_deadline_seconds)
259+
args.project, args.subscription_name, args.endpoint)
253260
elif args.command == 'receive':
254261
receive_messages(args.project, args.subscription_name)
255262
elif args.command == 'receive-flow-control':

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.