forked from googleapis/java-pubsub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
owlbot.py
1213 lines (1147 loc) · 55.9 KB
/
owlbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import synthtool as s
from synthtool.languages import java
service = 'pubsub'
version = 'v1'
GET_IAM_POLICY_TOPIC = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Gets the access control policy for a resource. Returns an empty policy if the resource exists
* and does not have a policy set.
*
* <p>Sample code:
*
* <pre><code>
* try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
* String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
* Policy response = topicAdminClient.getIamPolicy(formattedResource);
* }
* </code></pre>
*
* @param resource REQUIRED: The resource for which the policy is being requested. See the
* operation documentation for the appropriate value for this field.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #getIamPolicy(GetIamPolicyRequest)} instead.
*/
@Deprecated
public final Policy getIamPolicy(String resource) {
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(resource).build();
return getIamPolicy(request);
}
"""
GET_IAM_POLICY_SUBSCRIPTION = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Gets the access control policy for a resource. Returns an empty policy if the resource exists
* and does not have a policy set.
*
* <p>Sample code:
*
* <pre><code>
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
* Policy response = subscriptionAdminClient.getIamPolicy(formattedResource);
* }
* </code></pre>
*
* @param resource REQUIRED: The resource for which the policy is being requested. See the
* operation documentation for the appropriate value for this field.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #getIamPolicy(GetIamPolicyRequest)} instead.
*/
@Deprecated
public final Policy getIamPolicy(String resource) {
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(resource).build();
return getIamPolicy(request);
}
"""
GET_IAM_POLICY_PREVIOUS = r'(\s+public final Policy getIamPolicy\(GetIamPolicyRequest request\) {\n\s+return .*\n\s+})'
SET_IAM_POLICY_TOPIC = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Sets the access control policy on the specified resource. Replaces any existing policy.
*
* <p>Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED
*
* <p>Sample code:
*
* <pre><code>
* try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
* String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
* Policy policy = Policy.newBuilder().build();
* Policy response = topicAdminClient.setIamPolicy(formattedResource, policy);
* }
* </code></pre>
*
* @param resource REQUIRED: The resource for which the policy is being specified. See the
* operation documentation for the appropriate value for this field.
* @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
* policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
* Platform services (such as Projects) might reject them.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #setIamPolicy(SetIamPolicyRequest)} instead.
*/
@Deprecated
public final Policy setIamPolicy(String resource, Policy policy) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build();
return setIamPolicy(request);
}
"""
SET_IAM_POLICY_SUBSCRIPTION = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Sets the access control policy on the specified resource. Replaces any existing policy.
*
* <p>Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED
*
* <p>Sample code:
*
* <pre><code>
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
* Policy policy = Policy.newBuilder().build();
* Policy response = subscriptionAdminClient.setIamPolicy(formattedResource, policy);
* }
* </code></pre>
*
* @param resource REQUIRED: The resource for which the policy is being specified. See the
* operation documentation for the appropriate value for this field.
* @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the
* policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
* Platform services (such as Projects) might reject them.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #setIamPolicy(SetIamPolicyRequest)} instead.
*/
@Deprecated
public final Policy setIamPolicy(String resource, Policy policy) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build();
return setIamPolicy(request);
}
"""
SET_IAM_POLICY_PREVIOUS = r'(\s+public final Policy setIamPolicy\(SetIamPolicyRequest request\) {\n\s+return .*\n\s+})'
TEST_IAM_PERMISSIONS_TOPIC = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Returns permissions that a caller has on the specified resource. If the resource does not
* exist, this will return an empty set of permissions, not a NOT_FOUND error.
*
* <p>Note: This operation is designed to be used for building permission-aware UIs and
* command-line tools, not for authorization checking. This operation may "fail open" without
* warning.
*
* <p>Sample code:
*
* <pre><code>
* try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
* String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
* List<String> permissions = new ArrayList<>();
* TestIamPermissionsResponse response = topicAdminClient.testIamPermissions(formattedResource, permissions);
* }
* </code></pre>
*
* @param resource REQUIRED: The resource for which the policy detail is being requested. See the
* operation documentation for the appropriate value for this field.
* @param permissions The set of permissions to check for the `resource`. Permissions with
* wildcards (such as '*' or 'storage.*') are not allowed. For more information see
* [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #testIamPermissions(TestIamPermissionsRequest)} instead.
*/
@Deprecated
public final TestIamPermissionsResponse testIamPermissions(
String resource, List<String> permissions) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(resource)
.addAllPermissions(permissions)
.build();
return testIamPermissions(request);
}
"""
TEST_IAM_PERMISSIONS_SUBSCRIPTION = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Returns permissions that a caller has on the specified resource. If the resource does not
* exist, this will return an empty set of permissions, not a NOT_FOUND error.
*
* <p>Note: This operation is designed to be used for building permission-aware UIs and
* command-line tools, not for authorization checking. This operation may "fail open" without
* warning.
*
* <p>Sample code:
*
* <pre><code>
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* String formattedResource = ProjectTopicName.format("[PROJECT]", "[TOPIC]");
* List<String> permissions = new ArrayList<>();
* TestIamPermissionsResponse response = subscriptionAdminClient.testIamPermissions(formattedResource, permissions);
* }
* </code></pre>
*
* @param resource REQUIRED: The resource for which the policy detail is being requested. See the
* operation documentation for the appropriate value for this field.
* @param permissions The set of permissions to check for the `resource`. Permissions with
* wildcards (such as '*' or 'storage.*') are not allowed. For more information see
* [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #testIamPermissions(TestIamPermissionsRequest)} instead.
*/
@Deprecated
public final TestIamPermissionsResponse testIamPermissions(
String resource, List<String> permissions) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(resource)
.addAllPermissions(permissions)
.build();
return testIamPermissions(request);
}
"""
TEST_IAM_PERMISSIONS_PREVIOUS = r'(\s+public final TestIamPermissionsResponse testIamPermissions\(TestIamPermissionsRequest request\) {\n\s+return .*\n\s+})'
CREATE_TOPIC = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Creates the given topic with the given name. See the <a
* href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource name
* rules</a>.
*
* <p>Sample code:
*
* <pre><code>
* try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
* ProjectTopicName name = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
* Topic response = topicAdminClient.createTopic(name);
* }
* </code></pre>
*
* @param name Required. The name of the topic. It must have the format
* `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only
* letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`),
* tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in
* length, and it must not start with `"goog"`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #createTopic(TopicName)} instead.
*/
@Deprecated
public final Topic createTopic(ProjectTopicName name) {
Topic request = Topic.newBuilder().setName(name == null ? null : name.toString()).build();
return createTopic(request);
}
"""
CREATE_TOPIC_PREVIOUS = r'(\s+public final Topic createTopic\(String name\) {\n\s+.*\n\s+return.*\n\s+})'
DELETE_TOPIC = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a
* topic is deleted, a new topic may be created with the same name; this is an entirely new topic
* with none of the old configuration or subscriptions. Existing subscriptions to this topic are
* not deleted, but their `topic` field is set to `_deleted-topic_`.
*
* <p>Sample code:
*
* <pre><code>
* try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
* ProjectTopicName topic = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
* topicAdminClient.deleteTopic(topic);
* }
* </code></pre>
*
* @param topic Required. Name of the topic to delete. Format is
* `projects/{project}/topics/{topic}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #deleteTopic(TopicName)} instead.
*/
@Deprecated
public final void deleteTopic(ProjectTopicName topic) {
DeleteTopicRequest request =
DeleteTopicRequest.newBuilder().setTopic(topic == null ? null : topic.toString()).build();
deleteTopic(request);
}
"""
GET_TOPIC_PREVIOUS = r'(\s+public final Topic getTopic\(String topic\) {\n\s+.*\n\s+return.*\n\s+})'
GET_TOPIC = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Gets the configuration of a topic.
*
* <p>Sample code:
*
* <pre><code>
* try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
* ProjectTopicName topic = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
* Topic response = topicAdminClient.getTopic(topic);
* }
* </code></pre>
*
* @param topic Required. The name of the topic to get. Format is
* `projects/{project}/topics/{topic}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #getTopic(TopicName)} instead.
*/
@Deprecated
public final Topic getTopic(ProjectTopicName topic) {
GetTopicRequest request =
GetTopicRequest.newBuilder().setTopic(topic == null ? null : topic.toString()).build();
return getTopic(request);
}
"""
DELETE_TOPIC_PREVIOUS = r'(\s+public final void deleteTopic\(String topic\) {\n\s+.*\n\s+deleteTopic.*\n\s+})'
LIST_TOPIC_SUBSCRIPTIONS = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Lists the names of the subscriptions on this topic.
*
* <p>Sample code:
*
* <pre><code>
* try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
* ProjectTopicName topic = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
* for (ProjectSubscriptionName element : topicAdminClient.listTopicSubscriptions(topic).iterateAllAsProjectSubscriptionName()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*
* @param topic Required. The name of the topic that subscriptions are attached to. Format is
* `projects/{project}/topics/{topic}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #listTopicSubscriptions(TopicName)} instead.
*/
@Deprecated
public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions(ProjectTopicName topic) {
ListTopicSubscriptionsRequest request =
ListTopicSubscriptionsRequest.newBuilder()
.setTopic(topic == null ? null : topic.toString())
.build();
return listTopicSubscriptions(request);
}
"""
LIST_TOPIC_SUBSCRIPTIONS_PREVIOUS = r'(\s+public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions\(String topic\) {\n\s+.*\n\s+.*\n\s+return.*\n\s+})'
CREATE_SUBSCRIPTION_PREVIOUS = r'(\s+public final Subscription createSubscription\(Subscription request\) {\n\s+return.*\n\s+})'
CREATE_SUBSCRIPTION = """
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Creates a subscription to a given topic. See the <a
* href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource name
* rules</a>. If the subscription already exists, returns `ALREADY_EXISTS`. If the
* corresponding topic doesn't exist, returns `NOT_FOUND`.
*
* <p>If the name is not provided in the request, the server will assign a random name for this
* subscription on the same project as the topic, conforming to the [resource name
* format](https://cloud.google.com/pubsub/docs/admin#resource_names). The generated name is
* populated in the returned Subscription object. Note that for REST API requests, you must
* specify a name in the request.
*
* <p>Sample code:
*
* <pre><code>
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName name = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* ProjectTopicName topic = ProjectTopicName.of("[PROJECT]", "[TOPIC]");
* PushConfig pushConfig = PushConfig.newBuilder().build();
* int ackDeadlineSeconds = 0;
* Subscription response = subscriptionAdminClient.createSubscription(name, topic, pushConfig, ackDeadlineSeconds);
* }
* </code></pre>
*
* @param name Required. The name of the subscription. It must have the format
* `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a
* letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores
* (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3
* and 255 characters in length, and it must not start with `"goog"`.
* @param topic Required. The name of the topic from which this subscription is receiving
* messages. Format is `projects/{project}/topics/{topic}`. The value of this field will be
* `_deleted-topic_` if the topic has been deleted.
* @param pushConfig If push delivery is used with this subscription, this field is used to
* configure it. An empty `pushConfig` signifies that the subscriber will pull and ack
* messages using API methods.
* @param ackDeadlineSeconds The approximate amount of time (on a best-effort basis) Pub/Sub waits
* for the subscriber to acknowledge receipt before resending the message. In the interval
* after the message is delivered and before it is acknowledged, it is considered to be
* <i>outstanding</i>. During that time period, the message will not be
* redelivered (on a best-effort basis).
* <p>For pull subscriptions, this value is used as the initial value for the ack deadline. To
* override this value for a given message, call `ModifyAckDeadline` with the corresponding
* `ack_id` if using non-streaming pull or send the `ack_id` in a
* `StreamingModifyAckDeadlineRequest` if using streaming pull. The minimum custom deadline
* you can specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds
* (10 minutes). If this parameter is 0, a default value of 10 seconds is used.
* <p>For push delivery, this value is also used to set the request timeout for the call to
* the push endpoint.
* <p>If the subscriber never acknowledges the message, the Pub/Sub system will eventually
* redeliver the message.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #createSubscription(SubscriptionName, TopicName, PushConfig, int)} instead.
*/
@Deprecated
public final Subscription createSubscription(
ProjectSubscriptionName name,
ProjectTopicName topic,
PushConfig pushConfig,
int ackDeadlineSeconds) {
Subscription request =
Subscription.newBuilder()
.setName(name == null ? null : name.toString())
.setTopic(topic == null ? null : topic.toString())
.setPushConfig(pushConfig)
.setAckDeadlineSeconds(ackDeadlineSeconds)
.build();
return createSubscription(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a subscription to a given topic. See the [resource name rules]
* (https://cloud.google.com/pubsub/docs/admin#resource_names). If the subscription already
* exists, returns `ALREADY_EXISTS`. If the corresponding topic doesn't exist, returns
* `NOT_FOUND`.
*
* <p>If the name is not provided in the request, the server will assign a random name for this
* subscription on the same project as the topic, conforming to the [resource name format]
* (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated name is populated in
* the returned Subscription object. Note that for REST API requests, you must specify a name in
* the request.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName name = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* String topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString();
* PushConfig pushConfig = PushConfig.newBuilder().build();
* int ackDeadlineSeconds = 2135351438;
* Subscription response =
* subscriptionAdminClient.createSubscription(name, topic, pushConfig, ackDeadlineSeconds);
* }
* }</pre>
*
* @param name Required. The name of the subscription. It must have the format
* `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a
* letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores
* (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3
* and 255 characters in length, and it must not start with `"goog"`.
* @param topic Required. The name of the topic from which this subscription is receiving
* messages. Format is `projects/{project}/topics/{topic}`. The value of this field will be
* `_deleted-topic_` if the topic has been deleted.
* @param pushConfig If push delivery is used with this subscription, this field is used to
* configure it. An empty `pushConfig` signifies that the subscriber will pull and ack
* messages using API methods.
* @param ackDeadlineSeconds The approximate amount of time (on a best-effort basis) Pub/Sub waits
* for the subscriber to acknowledge receipt before resending the message. In the interval
* after the message is delivered and before it is acknowledged, it is considered to be
* <i>outstanding</i>. During that time period, the message will not be
* redelivered (on a best-effort basis).
* <p>For pull subscriptions, this value is used as the initial value for the ack deadline. To
* override this value for a given message, call `ModifyAckDeadline` with the corresponding
* `ack_id` if using non-streaming pull or send the `ack_id` in a
* `StreamingModifyAckDeadlineRequest` if using streaming pull. The minimum custom deadline
* you can specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds
* (10 minutes). If this parameter is 0, a default value of 10 seconds is used.
* <p>For push delivery, this value is also used to set the request timeout for the call to
* the push endpoint.
* <p>If the subscriber never acknowledges the message, the Pub/Sub system will eventually
* redeliver the message.
* @deprecated Use {@link #createSubscription(SubscriptionName, String, PushConfig, int)} instead.
*/
@Deprecated
public final Subscription createSubscription(
ProjectSubscriptionName name, String topic, PushConfig pushConfig, int ackDeadlineSeconds) {
Subscription request =
Subscription.newBuilder()
.setName(name == null ? null : name.toString())
.setTopic(topic)
.setPushConfig(pushConfig)
.setAckDeadlineSeconds(ackDeadlineSeconds)
.build();
return createSubscription(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a subscription to a given topic. See the [resource name rules]
* (https://cloud.google.com/pubsub/docs/admin#resource_names). If the subscription already
* exists, returns `ALREADY_EXISTS`. If the corresponding topic doesn't exist, returns
* `NOT_FOUND`.
*
* <p>If the name is not provided in the request, the server will assign a random name for this
* subscription on the same project as the topic, conforming to the [resource name format]
* (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated name is populated in
* the returned Subscription object. Note that for REST API requests, you must specify a name in
* the request.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName name = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]");
* PushConfig pushConfig = PushConfig.newBuilder().build();
* int ackDeadlineSeconds = 2135351438;
* Subscription response =
* subscriptionAdminClient.createSubscription(name, topic, pushConfig, ackDeadlineSeconds);
* }
* }</pre>
*
* @param name Required. The name of the subscription. It must have the format
* `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a
* letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores
* (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3
* and 255 characters in length, and it must not start with `"goog"`.
* @param topic Required. The name of the topic from which this subscription is receiving
* messages. Format is `projects/{project}/topics/{topic}`. The value of this field will be
* `_deleted-topic_` if the topic has been deleted.
* @param pushConfig If push delivery is used with this subscription, this field is used to
* configure it. An empty `pushConfig` signifies that the subscriber will pull and ack
* messages using API methods.
* @param ackDeadlineSeconds The approximate amount of time (on a best-effort basis) Pub/Sub waits
* for the subscriber to acknowledge receipt before resending the message. In the interval
* after the message is delivered and before it is acknowledged, it is considered to be
* <i>outstanding</i>. During that time period, the message will not be
* redelivered (on a best-effort basis).
* <p>For pull subscriptions, this value is used as the initial value for the ack deadline. To
* override this value for a given message, call `ModifyAckDeadline` with the corresponding
* `ack_id` if using non-streaming pull or send the `ack_id` in a
* `StreamingModifyAckDeadlineRequest` if using streaming pull. The minimum custom deadline
* you can specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds
* (10 minutes). If this parameter is 0, a default value of 10 seconds is used.
* <p>For push delivery, this value is also used to set the request timeout for the call to
* the push endpoint.
* <p>If the subscriber never acknowledges the message, the Pub/Sub system will eventually
* redeliver the message.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #createSubscription(SubscriptionName, TopicName, PushConfig, int)} instead.
*/
@Deprecated
public final Subscription createSubscription(
ProjectSubscriptionName name,
TopicName topic,
PushConfig pushConfig,
int ackDeadlineSeconds) {
Subscription request =
Subscription.newBuilder()
.setName(name == null ? null : name.toString())
.setTopic(topic == null ? null : topic.toString())
.setPushConfig(pushConfig)
.setAckDeadlineSeconds(ackDeadlineSeconds)
.build();
return createSubscription(request);
}
"""
GET_SUBSCRIPTION_PREVIOUS = r'(\s+public final Subscription getSubscription\(GetSubscriptionRequest request\) {\n\s+return.*\n\s+})'
GET_SUBSCRIPTION = """
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the configuration details of a subscription.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* Subscription response = subscriptionAdminClient.getSubscription(subscription);
* }
* }</pre>
*
* @param subscription Required. The name of the subscription to get. Format is
* `projects/{project}/subscriptions/{sub}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #getSubscription(SubscriptionName)} instead.
*/
@Deprecated
public final Subscription getSubscription(ProjectSubscriptionName subscription) {
GetSubscriptionRequest request =
GetSubscriptionRequest.newBuilder()
.setSubscription(subscription == null ? null : subscription.toString())
.build();
return getSubscription(request);
}
"""
DELETE_SUBSCRIPTION_PREVIOUS = r'(\s+public final void deleteSubscription\(DeleteSubscriptionRequest request\) {\n\s+deleteSubscription.*\n\s+})'
DELETE_SUBSCRIPTION = """
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes an existing subscription. All messages retained in the subscription are immediately
* dropped. Calls to `Pull` after deletion will return `NOT_FOUND`. After a subscription is
* deleted, a new one may be created with the same name, but the new one has no association with
* the old subscription or its topic unless the same topic is specified.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* subscriptionAdminClient.deleteSubscription(subscription);
* }
* }</pre>
*
* @param subscription Required. The subscription to delete. Format is
* `projects/{project}/subscriptions/{sub}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #deleteSubscription(SubscriptionName)} instead.
*/
@Deprecated
public final void deleteSubscription(ProjectSubscriptionName subscription) {
DeleteSubscriptionRequest request =
DeleteSubscriptionRequest.newBuilder()
.setSubscription(subscription == null ? null : subscription.toString())
.build();
deleteSubscription(request);
}
"""
MODIFY_ACK_DEADLINE_PREVIOUS = r'(\s+public final void modifyAckDeadline\(ModifyAckDeadlineRequest request\) {\n\s+modifyAckDeadline.*\n\s+})'
MODIFY_ACK_DEADLINE = """
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Modifies the ack deadline for a specific message. This method is useful to indicate that more
* time is needed to process a message by the subscriber, or to make the message available for
* redelivery if the processing was interrupted. Note that this does not modify the
* subscription-level `ackDeadlineSeconds` used for subsequent messages.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* List<String> ackIds = new ArrayList<>();
* int ackDeadlineSeconds = 2135351438;
* subscriptionAdminClient.modifyAckDeadline(subscription, ackIds, ackDeadlineSeconds);
* }
* }</pre>
*
* @param subscription Required. The name of the subscription. Format is
* `projects/{project}/subscriptions/{sub}`.
* @param ackIds Required. List of acknowledgment IDs.
* @param ackDeadlineSeconds Required. The new ack deadline with respect to the time this request
* was sent to the Pub/Sub system. For example, if the value is 10, the new ack deadline will
* expire 10 seconds after the `ModifyAckDeadline` call was made. Specifying zero might
* immediately make the message available for delivery to another subscriber client. This
* typically results in an increase in the rate of message redeliveries (that is, duplicates).
* The minimum deadline you can specify is 0 seconds. The maximum deadline you can specify is
* 600 seconds (10 minutes).
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #modifyAckDeadline(SubscriptionName, List<String>, int)} instead.
*/
@Deprecated
final void modifyAckDeadline(
ProjectSubscriptionName subscription, List<String> ackIds, int ackDeadlineSeconds) {
ModifyAckDeadlineRequest request =
ModifyAckDeadlineRequest.newBuilder()
.setSubscription(subscription == null ? null : subscription.toString())
.addAllAckIds(ackIds)
.setAckDeadlineSeconds(ackDeadlineSeconds)
.build();
modifyAckDeadline(request);
}
"""
ACKNOWLEDGE_PREVIOUS = r'(\s+public final void acknowledge\(AcknowledgeRequest request\) {\n\s+acknowledge.*\n\s+})'
ACKNOWLEDGE = """
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Acknowledges the messages associated with the `ack_ids` in the `AcknowledgeRequest`. The
* Pub/Sub system can remove the relevant messages from the subscription.
*
* <p>Acknowledging a message whose ack deadline has expired may succeed, but such a message may
* be redelivered later. Acknowledging a message more than once will not result in an error.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* List<String> ackIds = new ArrayList<>();
* subscriptionAdminClient.acknowledge(subscription, ackIds);
* }
* }</pre>
*
* @param subscription Required. The subscription whose message is being acknowledged. Format is
* `projects/{project}/subscriptions/{sub}`.
* @param ackIds Required. The acknowledgment ID for the messages being acknowledged that was
* returned by the Pub/Sub system in the `Pull` response. Must not be empty.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #acknowledge(SubscriptionName, List<String>)} instead.
*/
@Deprecated
public final void acknowledge(ProjectSubscriptionName subscription, List<String> ackIds) {
AcknowledgeRequest request =
AcknowledgeRequest.newBuilder()
.setSubscription(subscription == null ? null : subscription.toString())
.addAllAckIds(ackIds)
.build();
acknowledge(request);
}
"""
PULL_PREVIOUS = r'(\s+public final PullResponse pull\(PullRequest request\) {\n\s+return.*\n\s+})'
PULL = """
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Pulls messages from the server. The server may return `UNAVAILABLE` if there are too many
* concurrent pull requests pending for the given subscription.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* int maxMessages = 496131527;
* PullResponse response = subscriptionAdminClient.pull(subscription, maxMessages);
* }
* }</pre>
*
* @param subscription Required. The subscription from which messages should be pulled. Format is
* `projects/{project}/subscriptions/{sub}`.
* @param maxMessages Required. The maximum number of messages to return for this request. Must be
* a positive integer. The Pub/Sub system may return fewer than the number specified.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #pull(SubscriptionName, int)} instead.
*/
@Deprecated
public final PullResponse pull(ProjectSubscriptionName subscription, int maxMessages) {
PullRequest request =
PullRequest.newBuilder()
.setSubscription(subscription == null ? null : subscription.toString())
.setMaxMessages(maxMessages)
.build();
return pull(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Pulls messages from the server. The server may return `UNAVAILABLE` if there are too many
* concurrent pull requests pending for the given subscription.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* boolean returnImmediately = true;
* int maxMessages = 496131527;
* PullResponse response =
* subscriptionAdminClient.pull(subscription, returnImmediately, maxMessages);
* }
* }</pre>
*
* @param subscription Required. The subscription from which messages should be pulled. Format is
* `projects/{project}/subscriptions/{sub}`.
* @param returnImmediately Optional. If this field set to true, the system will respond
* immediately even if it there are no messages available to return in the `Pull` response.
* Otherwise, the system may wait (for a bounded amount of time) until at least one message is
* available, rather than returning no messages. Warning: setting this field to `true` is
* discouraged because it adversely impacts the performance of `Pull` operations. We recommend
* that users do not set this field.
* @param maxMessages Required. The maximum number of messages to return for this request. Must be
* a positive integer. The Pub/Sub system may return fewer than the number specified.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #pull(SubscriptionName, boolean, int)} instead.
*/
@Deprecated
final PullResponse pull(
ProjectSubscriptionName subscription, boolean returnImmediately, int maxMessages) {
PullRequest request =
PullRequest.newBuilder()
.setSubscription(subscription == null ? null : subscription.toString())
.setReturnImmediately(returnImmediately)
.setMaxMessages(maxMessages)
.build();
return pull(request);
}
"""
MODIFY_PUSH_CONFIG_PREVIOUS = r'(\s+public final void modifyPushConfig\(ModifyPushConfigRequest request\) {\n\s+modifyPushConfig.*\n\s+})'
MODIFY_PUSH_CONFIG = """
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Modifies the `PushConfig` for a specified subscription.
*
* <p>This may be used to change a push subscription to a pull one (signified by an empty
* `PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push
* subscription. Messages will accumulate for delivery continuously through the call regardless of
* changes to the `PushConfig`.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* PushConfig pushConfig = PushConfig.newBuilder().build();
* subscriptionAdminClient.modifyPushConfig(subscription, pushConfig);
* }
* }</pre>
*
* @param subscription Required. The name of the subscription. Format is
* `projects/{project}/subscriptions/{sub}`.
* @param pushConfig Required. The push configuration for future deliveries.
* <p>An empty `pushConfig` indicates that the Pub/Sub system should stop pushing messages
* from the given subscription and allow messages to be pulled and acknowledged - effectively
* pausing the subscription if `Pull` or `StreamingPull` is not called.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use {@link #modifyPushConfig(SubscriptionName, PushConfig)} instead.
*/
@Deprecated
public final void modifyPushConfig(ProjectSubscriptionName subscription, PushConfig pushConfig) {
ModifyPushConfigRequest request =
ModifyPushConfigRequest.newBuilder()
.setSubscription(subscription == null ? null : subscription.toString())
.setPushConfig(pushConfig)
.build();
modifyPushConfig(request);
}
"""
CREATE_SNAPSHOT_PREVIOUS = r'(\s+public final Snapshot createSnapshot\(CreateSnapshotRequest request\) {\n\s+return.*\n\s+})'
CREATE_SNAPSHOT = """
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a snapshot from the requested subscription. Snapshots are used in
* [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to
* manage message acknowledgments in bulk. That is, you can set the acknowledgment state of
* messages in an existing subscription to the state captured by a snapshot. If the snapshot
* already exists, returns `ALREADY_EXISTS`. If the requested subscription doesn't exist, returns
* `NOT_FOUND`. If the backlog in the subscription is too old -- and the resulting snapshot would
* expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned. See also the
* `Snapshot.expire_time` field. If the name is not provided in the request, the server will
* assign a random name for this snapshot on the same project as the subscription, conforming to
* the [resource name format] (https://cloud.google.com/pubsub/docs/admin#resource_names). The
* generated name is populated in the returned Snapshot object. Note that for REST API requests,
* you must specify a name in the request.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSnapshotName name = ProjectSnapshotName.of("[PROJECT]", "[SNAPSHOT]");
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* Snapshot response = subscriptionAdminClient.createSnapshot(name, subscription);
* }
* }</pre>
*
* @param name Required. User-provided name for this snapshot. If the name is not provided in the
* request, the server will assign a random name for this snapshot on the same project as the
* subscription. Note that for REST API requests, you must specify a name. See the <a
* href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource name
* rules</a>. Format is `projects/{project}/snapshots/{snap}`.
* @param subscription Required. The subscription whose backlog the snapshot retains.
* Specifically, the created snapshot is guaranteed to retain: (a) The existing backlog on the
* subscription. More precisely, this is defined as the messages in the subscription's backlog
* that are unacknowledged upon the successful completion of the `CreateSnapshot` request; as
* well as: (b) Any messages published to the subscription's topic following the successful
* completion of the CreateSnapshot request. Format is
* `projects/{project}/subscriptions/{sub}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use Use {@link #createSnapshot(SnapshotName, SubscriptionName)} instead.
*/
@Deprecated
public final Snapshot createSnapshot(
ProjectSnapshotName name, ProjectSubscriptionName subscription) {
CreateSnapshotRequest request =
CreateSnapshotRequest.newBuilder()
.setName(name == null ? null : name.toString())
.setSubscription(subscription == null ? null : subscription.toString())
.build();
return createSnapshot(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a snapshot from the requested subscription. Snapshots are used in
* [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to
* manage message acknowledgments in bulk. That is, you can set the acknowledgment state of
* messages in an existing subscription to the state captured by a snapshot. If the snapshot
* already exists, returns `ALREADY_EXISTS`. If the requested subscription doesn't exist, returns
* `NOT_FOUND`. If the backlog in the subscription is too old -- and the resulting snapshot would
* expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned. See also the
* `Snapshot.expire_time` field. If the name is not provided in the request, the server will
* assign a random name for this snapshot on the same project as the subscription, conforming to
* the [resource name format] (https://cloud.google.com/pubsub/docs/admin#resource_names). The
* generated name is populated in the returned Snapshot object. Note that for REST API requests,
* you must specify a name in the request.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* String name = ProjectSnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString();
* ProjectSubscriptionName subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]");
* Snapshot response = subscriptionAdminClient.createSnapshot(name, subscription);
* }
* }</pre>
*
* @param name Required. User-provided name for this snapshot. If the name is not provided in the
* request, the server will assign a random name for this snapshot on the same project as the
* subscription. Note that for REST API requests, you must specify a name. See the <a
* href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource name
* rules</a>. Format is `projects/{project}/snapshots/{snap}`.
* @param subscription Required. The subscription whose backlog the snapshot retains.
* Specifically, the created snapshot is guaranteed to retain: (a) The existing backlog on the
* subscription. More precisely, this is defined as the messages in the subscription's backlog
* that are unacknowledged upon the successful completion of the `CreateSnapshot` request; as
* well as: (b) Any messages published to the subscription's topic following the successful
* completion of the CreateSnapshot request. Format is
* `projects/{project}/subscriptions/{sub}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use Use {@link #createSnapshot(String, SubscriptionName)} instead.
*/
@Deprecated
public final Snapshot createSnapshot(String name, ProjectSubscriptionName subscription) {
CreateSnapshotRequest request =
CreateSnapshotRequest.newBuilder()
.setName(name)
.setSubscription(subscription == null ? null : subscription.toString())
.build();
return createSnapshot(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a snapshot from the requested subscription. Snapshots are used in
* [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to
* manage message acknowledgments in bulk. That is, you can set the acknowledgment state of
* messages in an existing subscription to the state captured by a snapshot. If the snapshot
* already exists, returns `ALREADY_EXISTS`. If the requested subscription doesn't exist, returns
* `NOT_FOUND`. If the backlog in the subscription is too old -- and the resulting snapshot would
* expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned. See also the
* `Snapshot.expire_time` field. If the name is not provided in the request, the server will
* assign a random name for this snapshot on the same project as the subscription, conforming to
* the [resource name format] (https://cloud.google.com/pubsub/docs/admin#resource_names). The
* generated name is populated in the returned Snapshot object. Note that for REST API requests,
* you must specify a name in the request.
*
* <p>Sample code:
*
* <pre>{@code
* try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
* ProjectSnapshotName name = ProjectSnapshotName.of("[PROJECT]", "[SNAPSHOT]");
* String subscription = ProjectSubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString();
* Snapshot response = subscriptionAdminClient.createSnapshot(name, subscription);
* }
* }</pre>
*
* @param name Required. User-provided name for this snapshot. If the name is not provided in the
* request, the server will assign a random name for this snapshot on the same project as the
* subscription. Note that for REST API requests, you must specify a name. See the <a
* href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource name
* rules</a>. Format is `projects/{project}/snapshots/{snap}`.
* @param subscription Required. The subscription whose backlog the snapshot retains.
* Specifically, the created snapshot is guaranteed to retain: (a) The existing backlog on the
* subscription. More precisely, this is defined as the messages in the subscription's backlog
* that are unacknowledged upon the successful completion of the `CreateSnapshot` request; as
* well as: (b) Any messages published to the subscription's topic following the successful
* completion of the CreateSnapshot request. Format is
* `projects/{project}/subscriptions/{sub}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
* @deprecated Use Use {@link #createSnapshot(SnapshotName, String)} instead.
*/
@Deprecated
public final Snapshot createSnapshot(ProjectSnapshotName name, String subscription) {
CreateSnapshotRequest request =
CreateSnapshotRequest.newBuilder()
.setName(name == null ? null : name.toString())
.setSubscription(subscription)
.build();
return createSnapshot(request);
}
"""
DELETE_SNAPSHOT_PREVIOUS = r'(\s+public final void deleteSnapshot\(DeleteSnapshotRequest request\) {\n\s+deleteSnapshot.*\n\s+})'
DELETE_SNAPSHOT = """
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Removes an existing snapshot. Snapshots are used in [Seek]
* (https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage
* message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in
* an existing subscription to the state captured by a snapshot. When the snapshot is deleted, all
* messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new
* one may be created with the same name, but the new one has no association with the old snapshot
* or its subscription, unless the same subscription is specified.
*