@@ -62,7 +62,10 @@ def create_push_subscription(project,
62
62
topic_name ,
63
63
subscription_name ,
64
64
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
+ """
66
69
subscriber = pubsub_v1 .SubscriberClient ()
67
70
topic_path = subscriber .topic_path (project , topic_name )
68
71
subscription_path = subscriber .subscription_path (
@@ -89,32 +92,36 @@ def delete_subscription(project, subscription_name):
89
92
print ('Subscription deleted: {}' .format (subscription_path ))
90
93
91
94
92
- def update_subscription (project , subscription_name , ack_deadline_seconds ):
95
+ def update_subscription (project , subscription_name , endpoint ):
93
96
"""
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".
97
101
"""
98
102
subscriber = pubsub_v1 .SubscriberClient ()
99
103
subscription_path = subscriber .subscription_path (
100
104
project , subscription_name )
101
105
106
+ push_config = pubsub_v1 .types .PushConfig (
107
+ push_endpoint = endpoint )
108
+
102
109
subscription = pubsub_v1 .types .Subscription (
103
110
name = subscription_path ,
104
- ack_deadline_seconds = ack_deadline_seconds )
111
+ push_config = push_config )
105
112
106
113
update_mask = {
107
114
'paths' : {
108
- 'ack_deadline_seconds ' ,
115
+ 'push_config ' ,
109
116
}
110
117
}
111
118
112
119
subscriber .update_subscription (subscription , update_mask )
113
120
result = subscriber .get_subscription (subscription_path )
114
121
115
122
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 ))
118
125
119
126
120
127
def receive_messages (project , subscription_name ):
@@ -214,7 +221,7 @@ def callback(message):
214
221
update_parser = subparsers .add_parser (
215
222
'update' , help = update_subscription .__doc__ )
216
223
update_parser .add_argument ('subscription_name' )
217
- update_parser .add_argument ('ack_deadline_seconds' , type = int )
224
+ update_parser .add_argument ('endpoint' )
218
225
219
226
receive_parser = subparsers .add_parser (
220
227
'receive' , help = receive_messages .__doc__ )
@@ -249,7 +256,7 @@ def callback(message):
249
256
args .project , args .subscription_name )
250
257
elif args .command == 'update' :
251
258
update_subscription (
252
- args .project , args .subscription_name , args .ack_deadline_seconds )
259
+ args .project , args .subscription_name , args .endpoint )
253
260
elif args .command == 'receive' :
254
261
receive_messages (args .project , args .subscription_name )
255
262
elif args .command == 'receive-flow-control' :
0 commit comments