Class: Google::Cloud::Tasks::V2beta2::CloudTasksClient

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb

Overview

Cloud Tasks allows developers to manage the execution of background work in their applications.

Constant Summary collapse

SERVICE_ADDRESS =

The default address of the service.

"cloudtasks.googleapis.com".freeze
DEFAULT_SERVICE_PORT =

The default port of the service.

443
GRPC_INTERCEPTORS =

The default set of gRPC interceptors.

[]
DEFAULT_TIMEOUT =
30
ALL_SCOPES =

The scopes needed to make gRPC calls to all of the methods defined in this service.

[
  "https://www.googleapis.com/auth/cloud-platform"
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ CloudTasksClient

Returns a new instance of CloudTasksClient

Parameters:

  • credentials (Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc)

    Provides the means for authenticating requests made by the client. This parameter can be many types. A Google::Auth::Credentials uses a the properties of its represented keyfile for authenticating requests made by this client. A String will be treated as the path to the keyfile to be used for the construction of credentials for this client. A Hash will be treated as the contents of a keyfile to be used for the construction of credentials for this client. A GRPC::Core::Channel will be used to make calls through. A GRPC::Core::ChannelCredentials for the setting up the RPC client. The channel credentials should already be composed with a GRPC::Core::CallCredentials object. A Proc will be used as an updater_proc for the Grpc channel. The proc transforms the metadata for requests, generally, to give OAuth credentials.

  • scopes (Array<String>)

    The OAuth scopes for this service. This parameter is ignored if an updater_proc is supplied.

  • client_config (Hash)

    A Hash for call options for each method. See Google::Gax#construct_settings for the structure of this data. Falls back to the default config if not specified or the specified config is missing data points.

  • timeout (Numeric)

    The default timeout, in seconds, for calls made through this client.

  • metadata (Hash)

    Default metadata to be sent with each request. This can be overridden on a per call basis.

  • exception_transformer (Proc)

    An optional proc that intercepts any exceptions raised during an API call to inject custom error handling.



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
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 174

def initialize \
    credentials: nil,
    scopes: ALL_SCOPES,
    client_config: {},
    timeout: DEFAULT_TIMEOUT,
    metadata: nil,
    exception_transformer: nil,
    lib_name: nil,
    lib_version: ""
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "google/gax/grpc"
  require "google/cloud/tasks/v2beta2/cloudtasks_services_pb"

  credentials ||= Google::Cloud::Tasks::V2beta2::Credentials.default

  if credentials.is_a?(String) || credentials.is_a?(Hash)
    updater_proc = Google::Cloud::Tasks::V2beta2::Credentials.new(credentials).updater_proc
  end
  if credentials.is_a?(GRPC::Core::Channel)
    channel = credentials
  end
  if credentials.is_a?(GRPC::Core::ChannelCredentials)
    chan_creds = credentials
  end
  if credentials.is_a?(Proc)
    updater_proc = credentials
  end
  if credentials.is_a?(Google::Auth::Credentials)
    updater_proc = credentials.updater_proc
  end

  package_version = Gem.loaded_specs['google-cloud-tasks'].version.version

  google_api_client = "gl-ruby/#{RUBY_VERSION}"
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
  google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
  google_api_client << " grpc/#{GRPC::VERSION}"
  google_api_client.freeze

  headers = { :"x-goog-api-client" => google_api_client }
  headers.merge!() unless .nil?
  client_config_file = Pathname.new(__dir__).join(
    "cloud_tasks_client_config.json"
  )
  defaults = client_config_file.open do |f|
    Google::Gax.construct_settings(
      "google.cloud.tasks.v2beta2.CloudTasks",
      JSON.parse(f.read),
      client_config,
      Google::Gax::Grpc::STATUS_CODE_NAMES,
      timeout,
      page_descriptors: PAGE_DESCRIPTORS,
      errors: Google::Gax::Grpc::API_ERRORS,
      metadata: headers
    )
  end

  # Allow overriding the service path/port in subclasses.
  service_path = self.class::SERVICE_ADDRESS
  port = self.class::DEFAULT_SERVICE_PORT
  interceptors = self.class::GRPC_INTERCEPTORS
  @cloud_tasks_stub = Google::Gax::Grpc.create_stub(
    service_path,
    port,
    chan_creds: chan_creds,
    channel: channel,
    updater_proc: updater_proc,
    scopes: scopes,
    interceptors: interceptors,
    &Google::Cloud::Tasks::V2beta2::CloudTasks::Stub.method(:new)
  )

  @list_queues = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:list_queues),
    defaults["list_queues"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @get_queue = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:get_queue),
    defaults["get_queue"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @create_queue = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:create_queue),
    defaults["create_queue"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @update_queue = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:update_queue),
    defaults["update_queue"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'queue.name' => request.queue.name}
    end
  )
  @delete_queue = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:delete_queue),
    defaults["delete_queue"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @purge_queue = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:purge_queue),
    defaults["purge_queue"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @pause_queue = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:pause_queue),
    defaults["pause_queue"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @resume_queue = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:resume_queue),
    defaults["resume_queue"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @get_iam_policy = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:get_iam_policy),
    defaults["get_iam_policy"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'resource' => request.resource}
    end
  )
  @set_iam_policy = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:set_iam_policy),
    defaults["set_iam_policy"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'resource' => request.resource}
    end
  )
  @test_iam_permissions = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:test_iam_permissions),
    defaults["test_iam_permissions"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'resource' => request.resource}
    end
  )
  @list_tasks = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:list_tasks),
    defaults["list_tasks"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @get_task = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:get_task),
    defaults["get_task"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @create_task = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:create_task),
    defaults["create_task"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @delete_task = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:delete_task),
    defaults["delete_task"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @lease_tasks = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:lease_tasks),
    defaults["lease_tasks"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'parent' => request.parent}
    end
  )
  @acknowledge_task = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:acknowledge_task),
    defaults["acknowledge_task"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @renew_lease = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:renew_lease),
    defaults["renew_lease"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @cancel_lease = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:cancel_lease),
    defaults["cancel_lease"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
  @run_task = Google::Gax.create_api_call(
    @cloud_tasks_stub.method(:run_task),
    defaults["run_task"],
    exception_transformer: exception_transformer,
    params_extractor: proc do |request|
      {'name' => request.name}
    end
  )
end

Instance Attribute Details

#cloud_tasks_stubGoogle::Cloud::Tasks::V2beta2::CloudTasks::Stub (readonly)

Returns:

  • (Google::Cloud::Tasks::V2beta2::CloudTasks::Stub)


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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 39

class CloudTasksClient
  attr_reader :cloud_tasks_stub

  # The default address of the service.
  SERVICE_ADDRESS = "cloudtasks.googleapis.com".freeze

  # The default port of the service.
  DEFAULT_SERVICE_PORT = 443

  # The default set of gRPC interceptors.
  GRPC_INTERCEPTORS = []

  DEFAULT_TIMEOUT = 30

  PAGE_DESCRIPTORS = {
    "list_queues" => Google::Gax::PageDescriptor.new(
      "page_token",
      "next_page_token",
      "queues"),
    "list_tasks" => Google::Gax::PageDescriptor.new(
      "page_token",
      "next_page_token",
      "tasks")
  }.freeze

  private_constant :PAGE_DESCRIPTORS

  # The scopes needed to make gRPC calls to all of the methods defined in
  # this service.
  ALL_SCOPES = [
    "https://www.googleapis.com/auth/cloud-platform"
  ].freeze


  PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
    "projects/{project}"
  )

  private_constant :PROJECT_PATH_TEMPLATE

  LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
    "projects/{project}/locations/{location}"
  )

  private_constant :LOCATION_PATH_TEMPLATE

  QUEUE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
    "projects/{project}/locations/{location}/queues/{queue}"
  )

  private_constant :QUEUE_PATH_TEMPLATE

  TASK_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
    "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}"
  )

  private_constant :TASK_PATH_TEMPLATE

  # Returns a fully-qualified project resource name string.
  # @param project [String]
  # @return [String]
  def self.project_path project
    PROJECT_PATH_TEMPLATE.render(
      :"project" => project
    )
  end

  # Returns a fully-qualified location resource name string.
  # @param project [String]
  # @param location [String]
  # @return [String]
  def self.location_path project, location
    LOCATION_PATH_TEMPLATE.render(
      :"project" => project,
      :"location" => location
    )
  end

  # Returns a fully-qualified queue resource name string.
  # @param project [String]
  # @param location [String]
  # @param queue [String]
  # @return [String]
  def self.queue_path project, location, queue
    QUEUE_PATH_TEMPLATE.render(
      :"project" => project,
      :"location" => location,
      :"queue" => queue
    )
  end

  # Returns a fully-qualified task resource name string.
  # @param project [String]
  # @param location [String]
  # @param queue [String]
  # @param task [String]
  # @return [String]
  def self.task_path project, location, queue, task
    TASK_PATH_TEMPLATE.render(
      :"project" => project,
      :"location" => location,
      :"queue" => queue,
      :"task" => task
    )
  end

  # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
  #   Provides the means for authenticating requests made by the client. This parameter can
  #   be many types.
  #   A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
  #   authenticating requests made by this client.
  #   A `String` will be treated as the path to the keyfile to be used for the construction of
  #   credentials for this client.
  #   A `Hash` will be treated as the contents of a keyfile to be used for the construction of
  #   credentials for this client.
  #   A `GRPC::Core::Channel` will be used to make calls through.
  #   A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
  #   should already be composed with a `GRPC::Core::CallCredentials` object.
  #   A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
  #   metadata for requests, generally, to give OAuth credentials.
  # @param scopes [Array<String>]
  #   The OAuth scopes for this service. This parameter is ignored if
  #   an updater_proc is supplied.
  # @param client_config [Hash]
  #   A Hash for call options for each method. See
  #   Google::Gax#construct_settings for the structure of
  #   this data. Falls back to the default config if not specified
  #   or the specified config is missing data points.
  # @param timeout [Numeric]
  #   The default timeout, in seconds, for calls made through this client.
  # @param metadata [Hash]
  #   Default metadata to be sent with each request. This can be overridden on a per call basis.
  # @param exception_transformer [Proc]
  #   An optional proc that intercepts any exceptions raised during an API call to inject
  #   custom error handling.
  def initialize \
      credentials: nil,
      scopes: ALL_SCOPES,
      client_config: {},
      timeout: DEFAULT_TIMEOUT,
      metadata: nil,
      exception_transformer: nil,
      lib_name: nil,
      lib_version: ""
    # These require statements are intentionally placed here to initialize
    # the gRPC module only when it's required.
    # See https://github.com/googleapis/toolkit/issues/446
    require "google/gax/grpc"
    require "google/cloud/tasks/v2beta2/cloudtasks_services_pb"

    credentials ||= Google::Cloud::Tasks::V2beta2::Credentials.default

    if credentials.is_a?(String) || credentials.is_a?(Hash)
      updater_proc = Google::Cloud::Tasks::V2beta2::Credentials.new(credentials).updater_proc
    end
    if credentials.is_a?(GRPC::Core::Channel)
      channel = credentials
    end
    if credentials.is_a?(GRPC::Core::ChannelCredentials)
      chan_creds = credentials
    end
    if credentials.is_a?(Proc)
      updater_proc = credentials
    end
    if credentials.is_a?(Google::Auth::Credentials)
      updater_proc = credentials.updater_proc
    end

    package_version = Gem.loaded_specs['google-cloud-tasks'].version.version

    google_api_client = "gl-ruby/#{RUBY_VERSION}"
    google_api_client << " #{lib_name}/#{lib_version}" if lib_name
    google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
    google_api_client << " grpc/#{GRPC::VERSION}"
    google_api_client.freeze

    headers = { :"x-goog-api-client" => google_api_client }
    headers.merge!() unless .nil?
    client_config_file = Pathname.new(__dir__).join(
      "cloud_tasks_client_config.json"
    )
    defaults = client_config_file.open do |f|
      Google::Gax.construct_settings(
        "google.cloud.tasks.v2beta2.CloudTasks",
        JSON.parse(f.read),
        client_config,
        Google::Gax::Grpc::STATUS_CODE_NAMES,
        timeout,
        page_descriptors: PAGE_DESCRIPTORS,
        errors: Google::Gax::Grpc::API_ERRORS,
        metadata: headers
      )
    end

    # Allow overriding the service path/port in subclasses.
    service_path = self.class::SERVICE_ADDRESS
    port = self.class::DEFAULT_SERVICE_PORT
    interceptors = self.class::GRPC_INTERCEPTORS
    @cloud_tasks_stub = Google::Gax::Grpc.create_stub(
      service_path,
      port,
      chan_creds: chan_creds,
      channel: channel,
      updater_proc: updater_proc,
      scopes: scopes,
      interceptors: interceptors,
      &Google::Cloud::Tasks::V2beta2::CloudTasks::Stub.method(:new)
    )

    @list_queues = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:list_queues),
      defaults["list_queues"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'parent' => request.parent}
      end
    )
    @get_queue = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:get_queue),
      defaults["get_queue"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @create_queue = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:create_queue),
      defaults["create_queue"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'parent' => request.parent}
      end
    )
    @update_queue = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:update_queue),
      defaults["update_queue"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'queue.name' => request.queue.name}
      end
    )
    @delete_queue = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:delete_queue),
      defaults["delete_queue"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @purge_queue = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:purge_queue),
      defaults["purge_queue"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @pause_queue = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:pause_queue),
      defaults["pause_queue"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @resume_queue = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:resume_queue),
      defaults["resume_queue"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @get_iam_policy = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:get_iam_policy),
      defaults["get_iam_policy"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'resource' => request.resource}
      end
    )
    @set_iam_policy = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:set_iam_policy),
      defaults["set_iam_policy"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'resource' => request.resource}
      end
    )
    @test_iam_permissions = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:test_iam_permissions),
      defaults["test_iam_permissions"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'resource' => request.resource}
      end
    )
    @list_tasks = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:list_tasks),
      defaults["list_tasks"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'parent' => request.parent}
      end
    )
    @get_task = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:get_task),
      defaults["get_task"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @create_task = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:create_task),
      defaults["create_task"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'parent' => request.parent}
      end
    )
    @delete_task = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:delete_task),
      defaults["delete_task"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @lease_tasks = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:lease_tasks),
      defaults["lease_tasks"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'parent' => request.parent}
      end
    )
    @acknowledge_task = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:acknowledge_task),
      defaults["acknowledge_task"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @renew_lease = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:renew_lease),
      defaults["renew_lease"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @cancel_lease = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:cancel_lease),
      defaults["cancel_lease"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
    @run_task = Google::Gax.create_api_call(
      @cloud_tasks_stub.method(:run_task),
      defaults["run_task"],
      exception_transformer: exception_transformer,
      params_extractor: proc do |request|
        {'name' => request.name}
      end
    )
  end

  # Service calls

  # Lists queues.
  #
  # Queues are returned in lexicographical order.
  #
  # @param parent [String]
  #   Required.
  #
  #   The location name.
  #   For example: +projects/PROJECT_ID/locations/LOCATION_ID+
  # @param filter [String]
  #   +filter+ can be used to specify a subset of queues. Any {Google::Cloud::Tasks::V2beta2::Queue Queue}
  #   field can be used as a filter and several operators as supported.
  #   For example: +<=, <, >=, >, !=, =, :+. The filter syntax is the same as
  #   described in
  #   [Stackdriver's Advanced Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
  #
  #   Sample filter "app_engine_http_target: *".
  #
  #   Note that using filters might cause fewer queues than the
  #   requested_page size to be returned.
  # @param page_size [Integer]
  #   The maximum number of resources contained in the underlying API
  #   response. If page streaming is performed per-resource, this
  #   parameter does not affect the return value. If page streaming is
  #   performed per-page, this determines the maximum number of
  #   resources in a page.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Queue>]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Queue>]
  #   An enumerable of Google::Cloud::Tasks::V2beta2::Queue instances.
  #   See Google::Gax::PagedEnumerable documentation for other
  #   operations such as per-page iteration or access to the response
  #   object.
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
  #
  #   # Iterate over all results.
  #   cloud_tasks_client.list_queues(formatted_parent).each do |element|
  #     # Process element.
  #   end
  #
  #   # Or iterate over results one page at a time.
  #   cloud_tasks_client.list_queues(formatted_parent).each_page do |page|
  #     # Process each page at a time.
  #     page.each do |element|
  #       # Process element.
  #     end
  #   end

  def list_queues \
      parent,
      filter: nil,
      page_size: nil,
      options: nil,
      &block
    req = {
      parent: parent,
      filter: filter,
      page_size: page_size
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ListQueuesRequest)
    @list_queues.call(req, options, &block)
  end

  # Gets a queue.
  #
  # @param name [String]
  #   Required.
  #
  #   The resource name of the queue. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Queue]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #   response = cloud_tasks_client.get_queue(formatted_name)

  def get_queue \
      name,
      options: nil,
      &block
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::GetQueueRequest)
    @get_queue.call(req, options, &block)
  end

  # Creates a queue.
  #
  # Queues created with this method allow tasks to live for a maximum of 31
  # days. After a task is 31 days old, the task will be deleted regardless of whether
  # it was dispatched or not.
  #
  # WARNING: Using this method may have unintended side effects if you are
  # using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues.
  # Read
  # [Overview of Queue Management and queue.yaml](https://cloud.google.com/cloud-tasks/docs/queue-yaml)
  # before using this method.
  #
  # @param parent [String]
  #   Required.
  #
  #   The location name in which the queue will be created.
  #   For example: +projects/PROJECT_ID/locations/LOCATION_ID+
  #
  #   The list of allowed locations can be obtained by calling Cloud
  #   Tasks' implementation of
  #   {Google::Cloud::Location::Locations::ListLocations ListLocations}.
  # @param queue [Google::Cloud::Tasks::V2beta2::Queue | Hash]
  #   Required.
  #
  #   The queue to create.
  #
  #   {Google::Cloud::Tasks::V2beta2::Queue#name Queue's name} cannot be the same as an existing queue.
  #   A hash of the same form as `Google::Cloud::Tasks::V2beta2::Queue`
  #   can also be provided.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Queue]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
  #
  #   # TODO: Initialize +queue+:
  #   queue = {}
  #   response = cloud_tasks_client.create_queue(formatted_parent, queue)

  def create_queue \
      parent,
      queue,
      options: nil,
      &block
    req = {
      parent: parent,
      queue: queue
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CreateQueueRequest)
    @create_queue.call(req, options, &block)
  end

  # Updates a queue.
  #
  # This method creates the queue if it does not exist and updates
  # the queue if it does exist.
  #
  # Queues created with this method allow tasks to live for a maximum of 31
  # days. After a task is 31 days old, the task will be deleted regardless of whether
  # it was dispatched or not.
  #
  # WARNING: Using this method may have unintended side effects if you are
  # using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues.
  # Read
  # [Overview of Queue Management and queue.yaml](https://cloud.google.com/cloud-tasks/docs/queue-yaml)
  # before using this method.
  #
  # @param queue [Google::Cloud::Tasks::V2beta2::Queue | Hash]
  #   Required.
  #
  #   The queue to create or update.
  #
  #   The queue's {Google::Cloud::Tasks::V2beta2::Queue#name name} must be specified.
  #
  #   Output only fields cannot be modified using UpdateQueue.
  #   Any value specified for an output only field will be ignored.
  #   The queue's {Google::Cloud::Tasks::V2beta2::Queue#name name} cannot be changed.
  #   A hash of the same form as `Google::Cloud::Tasks::V2beta2::Queue`
  #   can also be provided.
  # @param update_mask [Google::Protobuf::FieldMask | Hash]
  #   A mask used to specify which fields of the queue are being updated.
  #
  #   If empty, then all fields will be updated.
  #   A hash of the same form as `Google::Protobuf::FieldMask`
  #   can also be provided.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Queue]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #
  #   # TODO: Initialize +queue+:
  #   queue = {}
  #   response = cloud_tasks_client.update_queue(queue)

  def update_queue \
      queue,
      update_mask: nil,
      options: nil,
      &block
    req = {
      queue: queue,
      update_mask: update_mask
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::UpdateQueueRequest)
    @update_queue.call(req, options, &block)
  end

  # Deletes a queue.
  #
  # This command will delete the queue even if it has tasks in it.
  #
  # Note: If you delete a queue, a queue with the same name can't be created
  # for 7 days.
  #
  # WARNING: Using this method may have unintended side effects if you are
  # using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues.
  # Read
  # [Overview of Queue Management and queue.yaml](https://cloud.google.com/cloud-tasks/docs/queue-yaml)
  # before using this method.
  #
  # @param name [String]
  #   Required.
  #
  #   The queue name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result []
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #   cloud_tasks_client.delete_queue(formatted_name)

  def delete_queue \
      name,
      options: nil,
      &block
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::DeleteQueueRequest)
    @delete_queue.call(req, options, &block)
    nil
  end

  # Purges a queue by deleting all of its tasks.
  #
  # All tasks created before this method is called are permanently deleted.
  #
  # Purge operations can take up to one minute to take effect. Tasks
  # might be dispatched before the purge takes effect. A purge is irreversible.
  #
  # @param name [String]
  #   Required.
  #
  #   The queue name. For example:
  #   +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Queue]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #   response = cloud_tasks_client.purge_queue(formatted_name)

  def purge_queue \
      name,
      options: nil,
      &block
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::PurgeQueueRequest)
    @purge_queue.call(req, options, &block)
  end

  # Pauses the queue.
  #
  # If a queue is paused then the system will stop dispatching tasks
  # until the queue is resumed via
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::ResumeQueue ResumeQueue}. Tasks can still be added
  # when the queue is paused. A queue is paused if its
  # {Google::Cloud::Tasks::V2beta2::Queue#state state} is {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
  #
  # @param name [String]
  #   Required.
  #
  #   The queue name. For example:
  #   +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Queue]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #   response = cloud_tasks_client.pause_queue(formatted_name)

  def pause_queue \
      name,
      options: nil,
      &block
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::PauseQueueRequest)
    @pause_queue.call(req, options, &block)
  end

  # Resume a queue.
  #
  # This method resumes a queue after it has been
  # {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED} or
  # {Google::Cloud::Tasks::V2beta2::Queue::State::DISABLED DISABLED}. The state of a queue is stored
  # in the queue's {Google::Cloud::Tasks::V2beta2::Queue#state state}; after calling this method it
  # will be set to {Google::Cloud::Tasks::V2beta2::Queue::State::RUNNING RUNNING}.
  #
  # WARNING: Resuming many high-QPS queues at the same time can
  # lead to target overloading. If you are resuming high-QPS
  # queues, follow the 500/50/5 pattern described in
  # [Managing Cloud Tasks Scaling Risks](https://cloud.google.com/cloud-tasks/pdfs/managing-cloud-tasks-scaling-risks-2017-06-05.pdf).
  #
  # @param name [String]
  #   Required.
  #
  #   The queue name. For example:
  #   +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Queue]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #   response = cloud_tasks_client.resume_queue(formatted_name)

  def resume_queue \
      name,
      options: nil,
      &block
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ResumeQueueRequest)
    @resume_queue.call(req, options, &block)
  end

  # Gets the access control policy for a {Google::Cloud::Tasks::V2beta2::Queue Queue}.
  # Returns an empty policy if the resource exists and does not have a policy
  # set.
  #
  # Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the
  # specified resource parent:
  #
  # * +cloudtasks.queues.getIamPolicy+
  #
  # @param resource [String]
  #   REQUIRED: The resource for which the policy is being requested.
  #   +resource+ is usually specified as a path. For example, a Project
  #   resource is specified as +projects/{project}+.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Iam::V1::Policy]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Iam::V1::Policy]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #   response = cloud_tasks_client.get_iam_policy(formatted_resource)

  def get_iam_policy \
      resource,
      options: nil,
      &block
    req = {
      resource: resource
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
    @get_iam_policy.call(req, options, &block)
  end

  # Sets the access control policy for a {Google::Cloud::Tasks::V2beta2::Queue Queue}. Replaces any existing
  # policy.
  #
  # Note: The Cloud Console does not check queue-level IAM permissions yet.
  # Project-level permissions are required to use the Cloud Console.
  #
  # Authorization requires the following [Google IAM](https://cloud.google.com/iam) permission on the
  # specified resource parent:
  #
  # * +cloudtasks.queues.setIamPolicy+
  #
  # @param resource [String]
  #   REQUIRED: The resource for which the policy is being specified.
  #   +resource+ is usually specified as a path. For example, a Project
  #   resource is specified as +projects/{project}+.
  # @param policy [Google::Iam::V1::Policy | Hash]
  #   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.
  #   A hash of the same form as `Google::Iam::V1::Policy`
  #   can also be provided.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Iam::V1::Policy]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Iam::V1::Policy]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #
  #   # TODO: Initialize +policy+:
  #   policy = {}
  #   response = cloud_tasks_client.set_iam_policy(formatted_resource, policy)

  def set_iam_policy \
      resource,
      policy,
      options: nil,
      &block
    req = {
      resource: resource,
      policy: policy
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
    @set_iam_policy.call(req, options, &block)
  end

  # Returns permissions that a caller has on a {Google::Cloud::Tasks::V2beta2::Queue Queue}.
  # If the resource does not exist, this will return an empty set of
  # permissions, not a {Google::Rpc::Code::NOT_FOUND NOT_FOUND} error.
  #
  # 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.
  #
  # @param resource [String]
  #   REQUIRED: The resource for which the policy detail is being requested.
  #   +resource+ is usually specified as a path. For example, a Project
  #   resource is specified as +projects/{project}+.
  # @param permissions [Array<String>]
  #   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).
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #
  #   # TODO: Initialize +permissions+:
  #   permissions = []
  #   response = cloud_tasks_client.test_iam_permissions(formatted_resource, permissions)

  def test_iam_permissions \
      resource,
      permissions,
      options: nil,
      &block
    req = {
      resource: resource,
      permissions: permissions
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
    @test_iam_permissions.call(req, options, &block)
  end

  # Lists the tasks in a queue.
  #
  # By default, only the {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC} view is retrieved
  # due to performance considerations;
  # {Google::Cloud::Tasks::V2beta2::ListTasksRequest#response_view response_view} controls the
  # subset of information which is returned.
  #
  # @param parent [String]
  #   Required.
  #
  #   The queue name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
  # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
  #   The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
  #   returned.
  #
  #   By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
  #   information is retrieved by default because some data, such as
  #   payloads, might be desirable to return only when needed because
  #   of its large size or because of the sensitivity of data that it
  #   contains.
  #
  #   Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
  #   +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
  #   {Google::Cloud::Tasks::V2beta2::Task Task} resource.
  # @param order_by [String]
  #   Sort order used for the query. The only fields supported for sorting
  #   are +schedule_time+ and +pull_message.tag+. All results will be
  #   returned in approximately ascending order. The default ordering is by
  #   +schedule_time+.
  # @param page_size [Integer]
  #   The maximum number of resources contained in the underlying API
  #   response. If page streaming is performed per-resource, this
  #   parameter does not affect the return value. If page streaming is
  #   performed per-page, this determines the maximum number of
  #   resources in a page.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Task>]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Task>]
  #   An enumerable of Google::Cloud::Tasks::V2beta2::Task instances.
  #   See Google::Gax::PagedEnumerable documentation for other
  #   operations such as per-page iteration or access to the response
  #   object.
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #
  #   # Iterate over all results.
  #   cloud_tasks_client.list_tasks(formatted_parent).each do |element|
  #     # Process element.
  #   end
  #
  #   # Or iterate over results one page at a time.
  #   cloud_tasks_client.list_tasks(formatted_parent).each_page do |page|
  #     # Process each page at a time.
  #     page.each do |element|
  #       # Process element.
  #     end
  #   end

  def list_tasks \
      parent,
      response_view: nil,
      order_by: nil,
      page_size: nil,
      options: nil,
      &block
    req = {
      parent: parent,
      response_view: response_view,
      order_by: order_by,
      page_size: page_size
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ListTasksRequest)
    @list_tasks.call(req, options, &block)
  end

  # Gets a task.
  #
  # @param name [String]
  #   Required.
  #
  #   The task name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
  # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
  #   The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
  #   returned.
  #
  #   By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
  #   information is retrieved by default because some data, such as
  #   payloads, might be desirable to return only when needed because
  #   of its large size or because of the sensitivity of data that it
  #   contains.
  #
  #   Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
  #   +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
  #   {Google::Cloud::Tasks::V2beta2::Task Task} resource.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Task]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
  #   response = cloud_tasks_client.get_task(formatted_name)

  def get_task \
      name,
      response_view: nil,
      options: nil,
      &block
    req = {
      name: name,
      response_view: response_view
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::GetTaskRequest)
    @get_task.call(req, options, &block)
  end

  # Creates a task and adds it to a queue.
  #
  # Tasks cannot be updated after creation; there is no UpdateTask command.
  #
  # * For [App Engine queues](https://cloud.google.comgoogle.cloud.tasks.v2beta2.AppEngineHttpTarget),
  #   the maximum task size is 100KB.
  # * For [pull queues](https://cloud.google.comgoogle.cloud.tasks.v2beta2.PullTarget), this
  #   the maximum task size is 1MB.
  #
  # @param parent [String]
  #   Required.
  #
  #   The queue name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
  #
  #   The queue must already exist.
  # @param task [Google::Cloud::Tasks::V2beta2::Task | Hash]
  #   Required.
  #
  #   The task to add.
  #
  #   Task names have the following format:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+.
  #   The user can optionally specify a task {Google::Cloud::Tasks::V2beta2::Task#name name}. If a
  #   name is not specified then the system will generate a random
  #   unique task id, which will be set in the task returned in the
  #   {Google::Cloud::Tasks::V2beta2::Task#name response}.
  #
  #   If {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} is not set or is in the
  #   past then Cloud Tasks will set it to the current time.
  #
  #   Task De-duplication:
  #
  #   Explicitly specifying a task ID enables task de-duplication.  If
  #   a task's ID is identical to that of an existing task or a task
  #   that was deleted or completed recently then the call will fail
  #   with {Google::Rpc::Code::ALREADY_EXISTS ALREADY_EXISTS}.
  #   If the task's queue was created using Cloud Tasks, then another task with
  #   the same name can't be created for ~1hour after the original task was
  #   deleted or completed. If the task's queue was created using queue.yaml or
  #   queue.xml, then another task with the same name can't be created
  #   for ~9days after the original task was deleted or completed.
  #
  #   Because there is an extra lookup cost to identify duplicate task
  #   names, these {Google::Cloud::Tasks::V2beta2::CloudTasks::CreateTask CreateTask} calls have significantly
  #   increased latency. Using hashed strings for the task id or for
  #   the prefix of the task id is recommended. Choosing task ids that
  #   are sequential or have sequential prefixes, for example using a
  #   timestamp, causes an increase in latency and error rates in all
  #   task commands. The infrastructure relies on an approximately
  #   uniform distribution of task ids to store and serve tasks
  #   efficiently.
  #   A hash of the same form as `Google::Cloud::Tasks::V2beta2::Task`
  #   can also be provided.
  # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
  #   The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
  #   returned.
  #
  #   By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
  #   information is retrieved by default because some data, such as
  #   payloads, might be desirable to return only when needed because
  #   of its large size or because of the sensitivity of data that it
  #   contains.
  #
  #   Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
  #   +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
  #   {Google::Cloud::Tasks::V2beta2::Task Task} resource.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Task]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #
  #   # TODO: Initialize +task+:
  #   task = {}
  #   response = cloud_tasks_client.create_task(formatted_parent, task)

  def create_task \
      parent,
      task,
      response_view: nil,
      options: nil,
      &block
    req = {
      parent: parent,
      task: task,
      response_view: response_view
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CreateTaskRequest)
    @create_task.call(req, options, &block)
  end

  # Deletes a task.
  #
  # A task can be deleted if it is scheduled or dispatched. A task
  # cannot be deleted if it has completed successfully or permanently
  # failed.
  #
  # @param name [String]
  #   Required.
  #
  #   The task name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result []
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
  #   cloud_tasks_client.delete_task(formatted_name)

  def delete_task \
      name,
      options: nil,
      &block
    req = {
      name: name
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::DeleteTaskRequest)
    @delete_task.call(req, options, &block)
    nil
  end

  # Leases tasks from a pull queue for
  # {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration}.
  #
  # This method is invoked by the worker to obtain a lease. The
  # worker must acknowledge the task via
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::AcknowledgeTask AcknowledgeTask} after they have
  # performed the work associated with the task.
  #
  # The {Google::Cloud::Tasks::V2beta2::PullMessage#payload payload} is intended to store data that
  # the worker needs to perform the work associated with the task. To
  # return the payloads in the {Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response}, set
  # {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#response_view response_view} to
  # {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL}.
  #
  # A maximum of 10 qps of {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks}
  # requests are allowed per
  # queue. {Google::Rpc::Code::RESOURCE_EXHAUSTED RESOURCE_EXHAUSTED}
  # is returned when this limit is
  # exceeded. {Google::Rpc::Code::RESOURCE_EXHAUSTED RESOURCE_EXHAUSTED}
  # is also returned when
  # {Google::Cloud::Tasks::V2beta2::RateLimits#max_tasks_dispatched_per_second max_tasks_dispatched_per_second}
  # is exceeded.
  #
  # @param parent [String]
  #   Required.
  #
  #   The queue name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+
  # @param lease_duration [Google::Protobuf::Duration | Hash]
  #   After the worker has successfully finished the work associated
  #   with the task, the worker must call via
  #   {Google::Cloud::Tasks::V2beta2::CloudTasks::AcknowledgeTask AcknowledgeTask} before the
  #   {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}. Otherwise the task will be
  #   returned to a later {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} call so
  #   that another worker can retry it.
  #
  #   The maximum lease duration is 1 week.
  #   +lease_duration+ will be truncated to the nearest second.
  #   A hash of the same form as `Google::Protobuf::Duration`
  #   can also be provided.
  # @param max_tasks [Integer]
  #   The maximum number of tasks to lease.
  #
  #   The system will make a best effort to return as close to as
  #   +max_tasks+ as possible.
  #
  #   The largest that +max_tasks+ can be is 1000.
  # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
  #   The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
  #   returned.
  #
  #   By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
  #   information is retrieved by default because some data, such as
  #   payloads, might be desirable to return only when needed because
  #   of its large size or because of the sensitivity of data that it
  #   contains.
  #
  #   Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
  #   +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
  #   {Google::Cloud::Tasks::V2beta2::Task Task} resource.
  # @param filter [String]
  #   +filter+ can be used to specify a subset of tasks to lease.
  #
  #   When +filter+ is set to +tag=<my-tag>+ then the
  #   {Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response} will contain only tasks whose
  #   {Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} is equal to +<my-tag>+. +<my-tag>+ must be
  #   less than 500 characters.
  #
  #   When +filter+ is set to +tag_function=oldest_tag()+, only tasks which have
  #   the same tag as the task with the oldest
  #   {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be returned.
  #
  #   Grammar Syntax:
  #
  #   * +filter = "tag=" tag | "tag_function=" function+
  #
  #   * +tag = string+
  #
  #   * +function = "oldest_tag()"+
  #
  #   The +oldest_tag()+ function returns tasks which have the same tag as the
  #   oldest task (ordered by schedule time).
  #
  #   SDK compatibility: Although the SDK allows tags to be either
  #   string or
  #   [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-),
  #   only UTF-8 encoded tags can be used in Cloud Tasks. Tag which
  #   aren't UTF-8 encoded can't be used in the
  #   {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#filter filter} and the task's
  #   {Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} will be displayed as empty in Cloud Tasks.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::LeaseTasksResponse]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::LeaseTasksResponse]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
  #
  #   # TODO: Initialize +lease_duration+:
  #   lease_duration = {}
  #   response = cloud_tasks_client.lease_tasks(formatted_parent, lease_duration)

  def lease_tasks \
      parent,
      lease_duration,
      max_tasks: nil,
      response_view: nil,
      filter: nil,
      options: nil,
      &block
    req = {
      parent: parent,
      lease_duration: lease_duration,
      max_tasks: max_tasks,
      response_view: response_view,
      filter: filter
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::LeaseTasksRequest)
    @lease_tasks.call(req, options, &block)
  end

  # Acknowledges a pull task.
  #
  # The worker, that is, the entity that
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks leased} this task must call this method
  # to indicate that the work associated with the task has finished.
  #
  # The worker must acknowledge a task within the
  # {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration} or the lease
  # will expire and the task will become available to be leased
  # again. After the task is acknowledged, it will not be returned
  # by a later {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks},
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::GetTask GetTask}, or
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::ListTasks ListTasks}.
  #
  # @param name [String]
  #   Required.
  #
  #   The task name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
  # @param schedule_time [Google::Protobuf::Timestamp | Hash]
  #   Required.
  #
  #   The task's current schedule time, available in the
  #   {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
  #   {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
  #   {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
  #   to ensure that your worker currently holds the lease.
  #   A hash of the same form as `Google::Protobuf::Timestamp`
  #   can also be provided.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result []
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
  #
  #   # TODO: Initialize +schedule_time+:
  #   schedule_time = {}
  #   cloud_tasks_client.acknowledge_task(formatted_name, schedule_time)

  def acknowledge_task \
      name,
      schedule_time,
      options: nil,
      &block
    req = {
      name: name,
      schedule_time: schedule_time
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest)
    @acknowledge_task.call(req, options, &block)
    nil
  end

  # Renew the current lease of a pull task.
  #
  # The worker can use this method to extend the lease by a new
  # duration, starting from now. The new task lease will be
  # returned in the task's {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}.
  #
  # @param name [String]
  #   Required.
  #
  #   The task name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
  # @param schedule_time [Google::Protobuf::Timestamp | Hash]
  #   Required.
  #
  #   The task's current schedule time, available in the
  #   {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
  #   {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
  #   {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
  #   to ensure that your worker currently holds the lease.
  #   A hash of the same form as `Google::Protobuf::Timestamp`
  #   can also be provided.
  # @param lease_duration [Google::Protobuf::Duration | Hash]
  #   Required.
  #
  #   The desired new lease duration, starting from now.
  #
  #
  #   The maximum lease duration is 1 week.
  #   +lease_duration+ will be truncated to the nearest second.
  #   A hash of the same form as `Google::Protobuf::Duration`
  #   can also be provided.
  # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
  #   The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
  #   returned.
  #
  #   By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
  #   information is retrieved by default because some data, such as
  #   payloads, might be desirable to return only when needed because
  #   of its large size or because of the sensitivity of data that it
  #   contains.
  #
  #   Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
  #   +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
  #   {Google::Cloud::Tasks::V2beta2::Task Task} resource.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Task]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
  #
  #   # TODO: Initialize +schedule_time+:
  #   schedule_time = {}
  #
  #   # TODO: Initialize +lease_duration+:
  #   lease_duration = {}
  #   response = cloud_tasks_client.renew_lease(formatted_name, schedule_time, lease_duration)

  def renew_lease \
      name,
      schedule_time,
      lease_duration,
      response_view: nil,
      options: nil,
      &block
    req = {
      name: name,
      schedule_time: schedule_time,
      lease_duration: lease_duration,
      response_view: response_view
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::RenewLeaseRequest)
    @renew_lease.call(req, options, &block)
  end

  # Cancel a pull task's lease.
  #
  # The worker can use this method to cancel a task's lease by
  # setting its {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} to now. This will
  # make the task available to be leased to the next caller of
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks}.
  #
  # @param name [String]
  #   Required.
  #
  #   The task name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
  # @param schedule_time [Google::Protobuf::Timestamp | Hash]
  #   Required.
  #
  #   The task's current schedule time, available in the
  #   {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
  #   {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
  #   {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
  #   to ensure that your worker currently holds the lease.
  #   A hash of the same form as `Google::Protobuf::Timestamp`
  #   can also be provided.
  # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
  #   The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
  #   returned.
  #
  #   By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
  #   information is retrieved by default because some data, such as
  #   payloads, might be desirable to return only when needed because
  #   of its large size or because of the sensitivity of data that it
  #   contains.
  #
  #   Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
  #   +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
  #   {Google::Cloud::Tasks::V2beta2::Task Task} resource.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Task]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
  #
  #   # TODO: Initialize +schedule_time+:
  #   schedule_time = {}
  #   response = cloud_tasks_client.cancel_lease(formatted_name, schedule_time)

  def cancel_lease \
      name,
      schedule_time,
      response_view: nil,
      options: nil,
      &block
    req = {
      name: name,
      schedule_time: schedule_time,
      response_view: response_view
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CancelLeaseRequest)
    @cancel_lease.call(req, options, &block)
  end

  # Forces a task to run now.
  #
  # When this method is called, Cloud Tasks will dispatch the task, even if
  # the task is already running, the queue has reached its {Google::Cloud::Tasks::V2beta2::RateLimits RateLimits} or
  # is {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
  #
  # This command is meant to be used for manual debugging. For
  # example, {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} can be used to retry a failed
  # task after a fix has been made or to manually force a task to be
  # dispatched now.
  #
  # The dispatched task is returned. That is, the task that is returned
  # contains the {Google::Cloud::Tasks::V2beta2::Task#status status} after the task is dispatched but
  # before the task is received by its target.
  #
  # If Cloud Tasks receives a successful response from the task's
  # target, then the task will be deleted; otherwise the task's
  # {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be reset to the time that
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} was called plus the retry delay specified
  # in the queue's {Google::Cloud::Tasks::V2beta2::RetryConfig RetryConfig}.
  #
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} returns
  # {Google::Rpc::Code::NOT_FOUND NOT_FOUND} when it is called on a
  # task that has already succeeded or permanently failed.
  #
  # {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} cannot be called on a
  # {Google::Cloud::Tasks::V2beta2::PullMessage pull task}.
  #
  # @param name [String]
  #   Required.
  #
  #   The task name. For example:
  #   +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+
  # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
  #   The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
  #   returned.
  #
  #   By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
  #   information is retrieved by default because some data, such as
  #   payloads, might be desirable to return only when needed because
  #   of its large size or because of the sensitivity of data that it
  #   contains.
  #
  #   Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
  #   +cloudtasks.tasks.fullView+ [Google IAM](https://cloud.google.com/iam/) permission on the
  #   {Google::Cloud::Tasks::V2beta2::Task Task} resource.
  # @param options [Google::Gax::CallOptions]
  #   Overrides the default settings for this call, e.g, timeout,
  #   retries, etc.
  # @yield [result, operation] Access the result along with the RPC operation
  # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
  # @yieldparam operation [GRPC::ActiveCall::Operation]
  # @return [Google::Cloud::Tasks::V2beta2::Task]
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
  # @example
  #   require "google/cloud/tasks/v2beta2"
  #
  #   cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
  #   formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
  #   response = cloud_tasks_client.run_task(formatted_name)

  def run_task \
      name,
      response_view: nil,
      options: nil,
      &block
    req = {
      name: name,
      response_view: response_view
    }.delete_if { |_, v| v.nil? }
    req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::RunTaskRequest)
    @run_task.call(req, options, &block)
  end
end

Class Method Details

.location_path(project, location) ⇒ String

Returns a fully-qualified location resource name string.

Parameters:

  • project (String)
  • location (String)

Returns:

  • (String)


110
111
112
113
114
115
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 110

def self.location_path project, location
  LOCATION_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location
  )
end

.project_path(project) ⇒ String

Returns a fully-qualified project resource name string.

Parameters:

  • project (String)

Returns:

  • (String)


100
101
102
103
104
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 100

def self.project_path project
  PROJECT_PATH_TEMPLATE.render(
    :"project" => project
  )
end

.queue_path(project, location, queue) ⇒ String

Returns a fully-qualified queue resource name string.

Parameters:

  • project (String)
  • location (String)
  • queue (String)

Returns:

  • (String)


122
123
124
125
126
127
128
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 122

def self.queue_path project, location, queue
  QUEUE_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location,
    :"queue" => queue
  )
end

.task_path(project, location, queue, task) ⇒ String

Returns a fully-qualified task resource name string.

Parameters:

  • project (String)
  • location (String)
  • queue (String)
  • task (String)

Returns:

  • (String)


136
137
138
139
140
141
142
143
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 136

def self.task_path project, location, queue, task
  TASK_PATH_TEMPLATE.render(
    :"project" => project,
    :"location" => location,
    :"queue" => queue,
    :"task" => task
  )
end

Instance Method Details

#acknowledge_task(name, schedule_time, options: nil) {|result, operation| ... } ⇒ Object

Acknowledges a pull task.

The worker, that is, the entity that leased this task must call this method to indicate that the work associated with the task has finished.

The worker must acknowledge a task within the lease_duration or the lease will expire and the task will become available to be leased again. After the task is acknowledged, it will not be returned by a later LeaseTasks, GetTask, or ListTasks.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")

# TODO: Initialize +schedule_time+:
schedule_time = {}
cloud_tasks_client.acknowledge_task(formatted_name, schedule_time)

Parameters:

  • name (String)

    Required.

    The task name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+

  • schedule_time (Google::Protobuf::Timestamp | Hash)

    Required.

    The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. A hash of the same form as Google::Protobuf::Timestamp can also be provided.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • result

    []

  • operation (GRPC::ActiveCall::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1387

def acknowledge_task \
    name,
    schedule_time,
    options: nil,
    &block
  req = {
    name: name,
    schedule_time: schedule_time
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest)
  @acknowledge_task.call(req, options, &block)
  nil
end

#cancel_lease(name, schedule_time, response_view: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Task

Cancel a pull task's lease.

The worker can use this method to cancel a task's lease by setting its schedule_time to now. This will make the task available to be leased to the next caller of LeaseTasks.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")

# TODO: Initialize +schedule_time+:
schedule_time = {}
response = cloud_tasks_client.cancel_lease(formatted_name, schedule_time)

Parameters:

  • name (String)

    Required.

    The task name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+

  • schedule_time (Google::Protobuf::Timestamp | Hash)

    Required.

    The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. A hash of the same form as Google::Protobuf::Timestamp can also be provided.

  • response_view (Google::Cloud::Tasks::V2beta2::Task::View)

    The response_view specifies which subset of the Task will be returned.

    By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

    Authorization for FULL requires +cloudtasks.tasks.fullView+ Google IAM permission on the Task resource.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1536

def cancel_lease \
    name,
    schedule_time,
    response_view: nil,
    options: nil,
    &block
  req = {
    name: name,
    schedule_time: schedule_time,
    response_view: response_view
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CancelLeaseRequest)
  @cancel_lease.call(req, options, &block)
end

#create_queue(parent, queue, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Queue

Creates a queue.

Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.

WARNING: Using this method may have unintended side effects if you are using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")

# TODO: Initialize +queue+:
queue = {}
response = cloud_tasks_client.create_queue(formatted_parent, queue)

Parameters:

  • parent (String)

    Required.

    The location name in which the queue will be created. For example: +projects/PROJECT_ID/locations/LOCATION_ID+

    The list of allowed locations can be obtained by calling Cloud Tasks' implementation of ListLocations.

  • queue (Google::Cloud::Tasks::V2beta2::Queue | Hash)

    Required.

    The queue to create.

    Queue's name cannot be the same as an existing queue. A hash of the same form as Google::Cloud::Tasks::V2beta2::Queue can also be provided.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 564

def create_queue \
    parent,
    queue,
    options: nil,
    &block
  req = {
    parent: parent,
    queue: queue
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CreateQueueRequest)
  @create_queue.call(req, options, &block)
end

#create_task(parent, task, response_view: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Task

Creates a task and adds it to a queue.

Tasks cannot be updated after creation; there is no UpdateTask command.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")

# TODO: Initialize +task+:
task = {}
response = cloud_tasks_client.create_task(formatted_parent, task)

Parameters:

  • parent (String)

    Required.

    The queue name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+

    The queue must already exist.

  • task (Google::Cloud::Tasks::V2beta2::Task | Hash)

    Required.

    The task to add.

    Task names have the following format: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+. The user can optionally specify a task name. If a name is not specified then the system will generate a random unique task id, which will be set in the task returned in the response.

    If schedule_time is not set or is in the past then Cloud Tasks will set it to the current time.

    Task De-duplication:

    Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical to that of an existing task or a task that was deleted or completed recently then the call will fail with ALREADY_EXISTS. If the task's queue was created using Cloud Tasks, then another task with the same name can't be created for ~1hour after the original task was deleted or completed. If the task's queue was created using queue.yaml or queue.xml, then another task with the same name can't be created for ~9days after the original task was deleted or completed.

    Because there is an extra lookup cost to identify duplicate task names, these CreateTask calls have significantly increased latency. Using hashed strings for the task id or for the prefix of the task id is recommended. Choosing task ids that are sequential or have sequential prefixes, for example using a timestamp, causes an increase in latency and error rates in all task commands. The infrastructure relies on an approximately uniform distribution of task ids to store and serve tasks efficiently. A hash of the same form as Google::Cloud::Tasks::V2beta2::Task can also be provided.

  • response_view (Google::Cloud::Tasks::V2beta2::Task::View)

    The response_view specifies which subset of the Task will be returned.

    By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

    Authorization for FULL requires +cloudtasks.tasks.fullView+ Google IAM permission on the Task resource.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1162

def create_task \
    parent,
    task,
    response_view: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    task: task,
    response_view: response_view
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CreateTaskRequest)
  @create_task.call(req, options, &block)
end

#delete_queue(name, options: nil) {|result, operation| ... } ⇒ Object

Deletes a queue.

This command will delete the queue even if it has tasks in it.

Note: If you delete a queue, a queue with the same name can't be created for 7 days.

WARNING: Using this method may have unintended side effects if you are using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
cloud_tasks_client.delete_queue(formatted_name)

Parameters:

  • name (String)

    Required.

    The queue name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • result

    []

  • operation (GRPC::ActiveCall::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



672
673
674
675
676
677
678
679
680
681
682
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 672

def delete_queue \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::DeleteQueueRequest)
  @delete_queue.call(req, options, &block)
  nil
end

#delete_task(name, options: nil) {|result, operation| ... } ⇒ Object

Deletes a task.

A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has completed successfully or permanently failed.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
cloud_tasks_client.delete_task(formatted_name)

Parameters:

  • name (String)

    Required.

    The task name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • result

    []

  • operation (GRPC::ActiveCall::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1202

def delete_task \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::DeleteTaskRequest)
  @delete_task.call(req, options, &block)
  nil
end

#get_iam_policy(resource, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::Policy

Gets the access control policy for a Queue. Returns an empty policy if the resource exists and does not have a policy set.

Authorization requires the following Google IAM permission on the specified resource parent:

  • +cloudtasks.queues.getIamPolicy+

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
response = cloud_tasks_client.get_iam_policy(formatted_resource)

Parameters:

  • resource (String)

    REQUIRED: The resource for which the policy is being requested. +resource+ is usually specified as a path. For example, a Project resource is specified as +projects/project+.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



833
834
835
836
837
838
839
840
841
842
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 833

def get_iam_policy \
    resource,
    options: nil,
    &block
  req = {
    resource: resource
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
  @get_iam_policy.call(req, options, &block)
end

#get_queue(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Queue

Gets a queue.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
response = cloud_tasks_client.get_queue(formatted_name)

Parameters:

  • name (String)

    Required.

    The resource name of the queue. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



506
507
508
509
510
511
512
513
514
515
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 506

def get_queue \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::GetQueueRequest)
  @get_queue.call(req, options, &block)
end

#get_task(name, response_view: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Task

Gets a task.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
response = cloud_tasks_client.get_task(formatted_name)

Parameters:

  • name (String)

    Required.

    The task name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+

  • response_view (Google::Cloud::Tasks::V2beta2::Task::View)

    The response_view specifies which subset of the Task will be returned.

    By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

    Authorization for FULL requires +cloudtasks.tasks.fullView+ Google IAM permission on the Task resource.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1064

def get_task \
    name,
    response_view: nil,
    options: nil,
    &block
  req = {
    name: name,
    response_view: response_view
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::GetTaskRequest)
  @get_task.call(req, options, &block)
end

#lease_tasks(parent, lease_duration, max_tasks: nil, response_view: nil, filter: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::LeaseTasksResponse

Leases tasks from a pull queue for lease_duration.

This method is invoked by the worker to obtain a lease. The worker must acknowledge the task via AcknowledgeTask after they have performed the work associated with the task.

The payload is intended to store data that the worker needs to perform the work associated with the task. To return the payloads in the response, set response_view to FULL.

A maximum of 10 qps of LeaseTasks requests are allowed per queue. RESOURCE_EXHAUSTED is returned when this limit is exceeded. RESOURCE_EXHAUSTED is also returned when max_tasks_dispatched_per_second is exceeded.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")

# TODO: Initialize +lease_duration+:
lease_duration = {}
response = cloud_tasks_client.lease_tasks(formatted_parent, lease_duration)

Parameters:

  • parent (String)

    Required.

    The queue name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+

  • lease_duration (Google::Protobuf::Duration | Hash)

    After the worker has successfully finished the work associated with the task, the worker must call via AcknowledgeTask before the schedule_time. Otherwise the task will be returned to a later LeaseTasks call so that another worker can retry it.

    The maximum lease duration is 1 week. +lease_duration+ will be truncated to the nearest second. A hash of the same form as Google::Protobuf::Duration can also be provided.

  • max_tasks (Integer)

    The maximum number of tasks to lease.

    The system will make a best effort to return as close to as +max_tasks+ as possible.

    The largest that +max_tasks+ can be is 1000.

  • response_view (Google::Cloud::Tasks::V2beta2::Task::View)

    The response_view specifies which subset of the Task will be returned.

    By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

    Authorization for FULL requires +cloudtasks.tasks.fullView+ Google IAM permission on the Task resource.

  • filter (String)

    +filter+ can be used to specify a subset of tasks to lease.

    When +filter+ is set to +tag=+ then the response will contain only tasks whose tag is equal to ++. ++ must be less than 500 characters.

    When +filter+ is set to +tag_function=oldest_tag()+, only tasks which have the same tag as the task with the oldest schedule_time will be returned.

    Grammar Syntax:

    • +filter = "tag=" tag | "tag_function=" function+

    • +tag = string+

    • +function = "oldest_tag()"+

    The +oldest_tag()+ function returns tasks which have the same tag as the oldest task (ordered by schedule time).

    SDK compatibility: Although the SDK allows tags to be either string or bytes, only UTF-8 encoded tags can be used in Cloud Tasks. Tag which aren't UTF-8 encoded can't be used in the filter and the task's tag will be displayed as empty in Cloud Tasks.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1322

def lease_tasks \
    parent,
    lease_duration,
    max_tasks: nil,
    response_view: nil,
    filter: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    lease_duration: lease_duration,
    max_tasks: max_tasks,
    response_view: response_view,
    filter: filter
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::LeaseTasksRequest)
  @lease_tasks.call(req, options, &block)
end

#list_queues(parent, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Queue>

Lists queues.

Queues are returned in lexicographical order.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")

# Iterate over all results.
cloud_tasks_client.list_queues(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
cloud_tasks_client.list_queues(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    Required.

    The location name. For example: +projects/PROJECT_ID/locations/LOCATION_ID+

  • filter (String)

    +filter+ can be used to specify a subset of queues. Any Queue field can be used as a filter and several operators as supported. For example: +<=, <, >=, >, !=, =, :+. The filter syntax is the same as described in Stackdriver's Advanced Logs Filters.

    Sample filter "app_engine_http_target: *".

    Note that using filters might cause fewer queues than the requested_page size to be returned.

  • page_size (Integer)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Queue>)

    An enumerable of Google::Cloud::Tasks::V2beta2::Queue instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 469

def list_queues \
    parent,
    filter: nil,
    page_size: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    filter: filter,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ListQueuesRequest)
  @list_queues.call(req, options, &block)
end

#list_tasks(parent, response_view: nil, order_by: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Task>

Lists the tasks in a queue.

By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")

# Iterate over all results.
cloud_tasks_client.list_tasks(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
cloud_tasks_client.list_tasks(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    Required.

    The queue name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID+

  • response_view (Google::Cloud::Tasks::V2beta2::Task::View)

    The response_view specifies which subset of the Task will be returned.

    By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

    Authorization for FULL requires +cloudtasks.tasks.fullView+ Google IAM permission on the Task resource.

  • order_by (String)

    Sort order used for the query. The only fields supported for sorting are +schedule_time+ and +pull_message.tag+. All results will be returned in approximately ascending order. The default ordering is by +schedule_time+.

  • page_size (Integer)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Task>)

    An enumerable of Google::Cloud::Tasks::V2beta2::Task instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1012

def list_tasks \
    parent,
    response_view: nil,
    order_by: nil,
    page_size: nil,
    options: nil,
    &block
  req = {
    parent: parent,
    response_view: response_view,
    order_by: order_by,
    page_size: page_size
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ListTasksRequest)
  @list_tasks.call(req, options, &block)
end

#pause_queue(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Queue

Pauses the queue.

If a queue is paused then the system will stop dispatching tasks until the queue is resumed via ResumeQueue. Tasks can still be added when the queue is paused. A queue is paused if its state is PAUSED.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
response = cloud_tasks_client.pause_queue(formatted_name)

Parameters:

  • name (String)

    Required.

    The queue name. For example: +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



750
751
752
753
754
755
756
757
758
759
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 750

def pause_queue \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::PauseQueueRequest)
  @pause_queue.call(req, options, &block)
end

#purge_queue(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Queue

Purges a queue by deleting all of its tasks.

All tasks created before this method is called are permanently deleted.

Purge operations can take up to one minute to take effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
response = cloud_tasks_client.purge_queue(formatted_name)

Parameters:

  • name (String)

    Required.

    The queue name. For example: +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



711
712
713
714
715
716
717
718
719
720
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 711

def purge_queue \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::PurgeQueueRequest)
  @purge_queue.call(req, options, &block)
end

#renew_lease(name, schedule_time, lease_duration, response_view: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Task

Renew the current lease of a pull task.

The worker can use this method to extend the lease by a new duration, starting from now. The new task lease will be returned in the task's schedule_time.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")

# TODO: Initialize +schedule_time+:
schedule_time = {}

# TODO: Initialize +lease_duration+:
lease_duration = {}
response = cloud_tasks_client.renew_lease(formatted_name, schedule_time, lease_duration)

Parameters:

  • name (String)

    Required.

    The task name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+

  • schedule_time (Google::Protobuf::Timestamp | Hash)

    Required.

    The task's current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. A hash of the same form as Google::Protobuf::Timestamp can also be provided.

  • lease_duration (Google::Protobuf::Duration | Hash)

    Required.

    The desired new lease duration, starting from now.

    The maximum lease duration is 1 week. +lease_duration+ will be truncated to the nearest second. A hash of the same form as Google::Protobuf::Duration can also be provided.

  • response_view (Google::Cloud::Tasks::V2beta2::Task::View)

    The response_view specifies which subset of the Task will be returned.

    By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

    Authorization for FULL requires +cloudtasks.tasks.fullView+ Google IAM permission on the Task resource.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1466

def renew_lease \
    name,
    schedule_time,
    lease_duration,
    response_view: nil,
    options: nil,
    &block
  req = {
    name: name,
    schedule_time: schedule_time,
    lease_duration: lease_duration,
    response_view: response_view
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::RenewLeaseRequest)
  @renew_lease.call(req, options, &block)
end

#resume_queue(name, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Queue

Resume a queue.

This method resumes a queue after it has been PAUSED or DISABLED. The state of a queue is stored in the queue's state; after calling this method it will be set to RUNNING.

WARNING: Resuming many high-QPS queues at the same time can lead to target overloading. If you are resuming high-QPS queues, follow the 500/50/5 pattern described in Managing Cloud Tasks Scaling Risks.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
response = cloud_tasks_client.resume_queue(formatted_name)

Parameters:

  • name (String)

    Required.

    The queue name. For example: +projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID+

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



794
795
796
797
798
799
800
801
802
803
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 794

def resume_queue \
    name,
    options: nil,
    &block
  req = {
    name: name
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ResumeQueueRequest)
  @resume_queue.call(req, options, &block)
end

#run_task(name, response_view: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Task

Forces a task to run now.

When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED.

This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now.

The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target.

If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig.

RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed.

RunTask cannot be called on a pull task.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
response = cloud_tasks_client.run_task(formatted_name)

Parameters:

  • name (String)

    Required.

    The task name. For example: +projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID+

  • response_view (Google::Cloud::Tasks::V2beta2::Task::View)

    The response_view specifies which subset of the Task will be returned.

    By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.

    Authorization for FULL requires +cloudtasks.tasks.fullView+ Google IAM permission on the Task resource.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 1612

def run_task \
    name,
    response_view: nil,
    options: nil,
    &block
  req = {
    name: name,
    response_view: response_view
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::RunTaskRequest)
  @run_task.call(req, options, &block)
end

#set_iam_policy(resource, policy, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::Policy

Sets the access control policy for a Queue. Replaces any existing policy.

Note: The Cloud Console does not check queue-level IAM permissions yet. Project-level permissions are required to use the Cloud Console.

Authorization requires the following Google IAM permission on the specified resource parent:

  • +cloudtasks.queues.setIamPolicy+

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")

# TODO: Initialize +policy+:
policy = {}
response = cloud_tasks_client.set_iam_policy(formatted_resource, policy)

Parameters:

  • resource (String)

    REQUIRED: The resource for which the policy is being specified. +resource+ is usually specified as a path. For example, a Project resource is specified as +projects/project+.

  • policy (Google::Iam::V1::Policy | Hash)

    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. A hash of the same form as Google::Iam::V1::Policy can also be provided.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



884
885
886
887
888
889
890
891
892
893
894
895
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 884

def set_iam_policy \
    resource,
    policy,
    options: nil,
    &block
  req = {
    resource: resource,
    policy: policy
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
  @set_iam_policy.call(req, options, &block)
end

#test_iam_permissions(resource, permissions, options: nil) {|result, operation| ... } ⇒ Google::Iam::V1::TestIamPermissionsResponse

Returns permissions that a caller has on a Queue. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

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.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new
formatted_resource = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")

# TODO: Initialize +permissions+:
permissions = []
response = cloud_tasks_client.test_iam_permissions(formatted_resource, permissions)

Parameters:

  • resource (String)

    REQUIRED: The resource for which the policy detail is being requested. +resource+ is usually specified as a path. For example, a Project resource is specified as +projects/project+.

  • permissions (Array<String>)

    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.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



932
933
934
935
936
937
938
939
940
941
942
943
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 932

def test_iam_permissions \
    resource,
    permissions,
    options: nil,
    &block
  req = {
    resource: resource,
    permissions: permissions
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
  @test_iam_permissions.call(req, options, &block)
end

#update_queue(queue, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Google::Cloud::Tasks::V2beta2::Queue

Updates a queue.

This method creates the queue if it does not exist and updates the queue if it does exist.

Queues created with this method allow tasks to live for a maximum of 31 days. After a task is 31 days old, the task will be deleted regardless of whether it was dispatched or not.

WARNING: Using this method may have unintended side effects if you are using an App Engine +queue.yaml+ or +queue.xml+ file to manage your queues. Read Overview of Queue Management and queue.yaml before using this method.

Examples:

require "google/cloud/tasks/v2beta2"

cloud_tasks_client = Google::Cloud::Tasks::V2beta2.new

# TODO: Initialize +queue+:
queue = {}
response = cloud_tasks_client.update_queue(queue)

Parameters:

  • queue (Google::Cloud::Tasks::V2beta2::Queue | Hash)

    Required.

    The queue to create or update.

    The queue's name must be specified.

    Output only fields cannot be modified using UpdateQueue. Any value specified for an output only field will be ignored. The queue's name cannot be changed. A hash of the same form as Google::Cloud::Tasks::V2beta2::Queue can also be provided.

  • update_mask (Google::Protobuf::FieldMask | Hash)

    A mask used to specify which fields of the queue are being updated.

    If empty, then all fields will be updated. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb', line 627

def update_queue \
    queue,
    update_mask: nil,
    options: nil,
    &block
  req = {
    queue: queue,
    update_mask: update_mask
  }.delete_if { |_, v| v.nil? }
  req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::UpdateQueueRequest)
  @update_queue.call(req, options, &block)
end