google-cloud-tasks-v2beta2 0.9.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a804be22ca6b33b25a9ed09d9db17ee0763ab1a1e6d334f889bfbee4ecc256c1
4
- data.tar.gz: c606a48d1da796fe8e7ee7f25d541f5642b0e4d4c87c3f953cee5e911fcb59be
3
+ metadata.gz: fabc756db549ba9f98195bd7a9a0988f7f88d3238b4dea83d10351816cc3a800
4
+ data.tar.gz: ba58ed444a9212ad25a240b7e4a625fea9de18f9b5d95fe9047d5a45b77a4878
5
5
  SHA512:
6
- metadata.gz: ed66657668e606d5901c7d215eed514fb041c8a115e8df3e1c1d81a80c17d5bede502d4954bb58f4ab560884428668605d09d5bd305a2c5b4abf9a14f5f2fff8
7
- data.tar.gz: 500cc4682cc2692d3cee2f5d8cdc2ad22b3168ce12275288b8c38a315d6a40abef709a5629f76e6dbe136fbd4bc2084d589e3f2342333aa054b659bb31ea0e04
6
+ metadata.gz: b5a04de28b05c1e51eeadaa95c8b805664c7a589ce11d1dd75ac0b1811e9021fa7c0aad2ba1339e654c2ea9a6dd2fcdb2fc3a14816a25a672d9c4ecdef014048
7
+ data.tar.gz: 86ea891f6f425138b2cc003936b14c22db8c5b10e3ec50fc4bb1a4b8c76f1d53d8cfc24639335559e19e5eb64a4c63466e7dad7ebdcfff043fb6c820395a1cd1
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/config"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Tasks
24
+ ##
25
+ # @example Loading just the REST part of this package, including all its services, and instantiating a REST client
26
+ #
27
+ # require "google/cloud/tasks/v2beta2/rest"
28
+ # client = ::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client.new
29
+ #
30
+ module V2beta2
31
+ ##
32
+ # @private
33
+ # Initialize the mixin bindings configuration
34
+ #
35
+ def self.configure
36
+ @configure ||= begin
37
+ namespace = ["Google", "Cloud", "Tasks"]
38
+ parent_config = while namespace.any?
39
+ parent_name = namespace.join "::"
40
+ parent_const = const_get parent_name
41
+ break parent_const.configure if parent_const.respond_to? :configure
42
+ namespace.pop
43
+ end
44
+
45
+ default_config = Configuration.new parent_config
46
+ default_config.bindings_override["google.cloud.location.Locations.GetLocation"] = [
47
+ Gapic::Rest::GrpcTranscoder::HttpBinding.create_with_validation(
48
+ uri_method: :get,
49
+ uri_template: "/v2beta2/{name}",
50
+ matches: [
51
+ ["name", %r{^projects/[^/]+/locations/[^/]+/?$}, false]
52
+ ],
53
+ body: nil
54
+ )
55
+ ]
56
+ default_config.bindings_override["google.cloud.location.Locations.ListLocations"] = [
57
+
58
+ Gapic::Rest::GrpcTranscoder::HttpBinding.create_with_validation(
59
+ uri_method: :get,
60
+ uri_template: "/v2beta2/{name}/locations",
61
+ matches: [
62
+ ["name", %r{^projects/[^/]+/?$}, false]
63
+ ],
64
+ body: nil
65
+ )
66
+ ]
67
+ default_config
68
+ end
69
+ yield @configure if block_given?
70
+ @configure
71
+ end
72
+
73
+ ##
74
+ # @private
75
+ # Configuration class for the google.cloud.tasks.v2beta2 package.
76
+ #
77
+ # This class contains common configuration for all services
78
+ # of the google.cloud.tasks.v2beta2 package.
79
+ #
80
+ # This configuration is for internal use of the client library classes,
81
+ # and it is not intended that the end-users will read or change it.
82
+ #
83
+ class Configuration
84
+ extend ::Gapic::Config
85
+
86
+ # @private
87
+ # Overrides for http bindings for the RPC of the mixins for this package.
88
+ # Services in this package should use these when creating clients for the mixin services.
89
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
90
+ config_attr :bindings_override, {}, ::Hash, nil
91
+
92
+ # @private
93
+ def initialize parent_config = nil
94
+ @parent_config = parent_config unless parent_config.nil?
95
+
96
+ yield self if block_given?
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -18,6 +18,7 @@
18
18
 
19
19
  require "google/cloud/errors"
20
20
  require "google/cloud/tasks/v2beta2/cloudtasks_pb"
21
+ require "google/cloud/location"
21
22
 
22
23
  module Google
23
24
  module Cloud
@@ -90,6 +91,8 @@ module Google
90
91
 
91
92
  default_config.rpcs.resume_queue.timeout = 20.0
92
93
 
94
+ default_config.rpcs.upload_queue_yaml.timeout = 20.0
95
+
93
96
  default_config.rpcs.get_iam_policy.timeout = 20.0
94
97
  default_config.rpcs.get_iam_policy.retry_policy = {
95
98
  initial_delay: 0.1, max_delay: 10.0, multiplier: 1.3, retry_codes: [14, 4]
@@ -129,6 +132,8 @@ module Google
129
132
 
130
133
  default_config.rpcs.run_task.timeout = 20.0
131
134
 
135
+ default_config.rpcs.buffer_task.timeout = 20.0
136
+
132
137
  default_config
133
138
  end
134
139
  yield @configure if block_given?
@@ -188,7 +193,7 @@ module Google
188
193
  credentials = @config.credentials
189
194
  # Use self-signed JWT if the endpoint is unchanged from default,
190
195
  # but only if the default endpoint does not have a region prefix.
191
- enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
196
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
192
197
  !@config.endpoint.split(".").first.include?("-")
193
198
  credentials ||= Credentials.default scope: @config.scope,
194
199
  enable_self_signed_jwt: enable_self_signed_jwt
@@ -198,6 +203,12 @@ module Google
198
203
  @quota_project_id = @config.quota_project
199
204
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
200
205
 
206
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
207
+ config.credentials = credentials
208
+ config.quota_project = @quota_project_id
209
+ config.endpoint = @config.endpoint
210
+ end
211
+
201
212
  @cloud_tasks_stub = ::Gapic::ServiceStub.new(
202
213
  ::Google::Cloud::Tasks::V2beta2::CloudTasks::Stub,
203
214
  credentials: credentials,
@@ -207,6 +218,13 @@ module Google
207
218
  )
208
219
  end
209
220
 
221
+ ##
222
+ # Get the associated client for mix-in of the Locations.
223
+ #
224
+ # @return [Google::Cloud::Location::Locations::Client]
225
+ #
226
+ attr_reader :location_client
227
+
210
228
  # Service calls
211
229
 
212
230
  ##
@@ -463,7 +481,7 @@ module Google
463
481
  #
464
482
  # The list of allowed locations can be obtained by calling Cloud
465
483
  # Tasks' implementation of
466
- # [ListLocations][google.cloud.location.Locations.ListLocations].
484
+ # `::Google::Cloud::Location::Locations::Client#list_locations`.
467
485
  # @param queue [::Google::Cloud::Tasks::V2beta2::Queue, ::Hash]
468
486
  # Required. The queue to create.
469
487
  #
@@ -1027,6 +1045,91 @@ module Google
1027
1045
  raise ::Google::Cloud::Error.from_error(e)
1028
1046
  end
1029
1047
 
1048
+ ##
1049
+ # Update queue list by uploading a queue.yaml file.
1050
+ #
1051
+ # The queue.yaml file is supplied in the request body as a YAML encoded
1052
+ # string. This method was added to support gcloud clients versions before
1053
+ # 322.0.0. New clients should use CreateQueue instead of this method.
1054
+ #
1055
+ # @overload upload_queue_yaml(request, options = nil)
1056
+ # Pass arguments to `upload_queue_yaml` via a request object, either of type
1057
+ # {::Google::Cloud::Tasks::V2beta2::UploadQueueYamlRequest} or an equivalent Hash.
1058
+ #
1059
+ # @param request [::Google::Cloud::Tasks::V2beta2::UploadQueueYamlRequest, ::Hash]
1060
+ # A request object representing the call parameters. Required. To specify no
1061
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1062
+ # @param options [::Gapic::CallOptions, ::Hash]
1063
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1064
+ #
1065
+ # @overload upload_queue_yaml(app_id: nil, http_body: nil)
1066
+ # Pass arguments to `upload_queue_yaml` via keyword arguments. Note that at
1067
+ # least one keyword argument is required. To specify no parameters, or to keep all
1068
+ # the default parameter values, pass an empty Hash as a request object (see above).
1069
+ #
1070
+ # @param app_id [::String]
1071
+ # Required. The App ID is supplied as an HTTP parameter. Unlike internal
1072
+ # usage of App ID, it does not include a region prefix. Rather, the App ID
1073
+ # represents the Project ID against which to make the request.
1074
+ # @param http_body [::Google::Api::HttpBody, ::Hash]
1075
+ # The http body contains the queue.yaml file which used to update queue lists
1076
+ #
1077
+ # @yield [response, operation] Access the result along with the RPC operation
1078
+ # @yieldparam response [::Google::Protobuf::Empty]
1079
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1080
+ #
1081
+ # @return [::Google::Protobuf::Empty]
1082
+ #
1083
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1084
+ #
1085
+ # @example Basic example
1086
+ # require "google/cloud/tasks/v2beta2"
1087
+ #
1088
+ # # Create a client object. The client can be reused for multiple calls.
1089
+ # client = Google::Cloud::Tasks::V2beta2::CloudTasks::Client.new
1090
+ #
1091
+ # # Create a request. To set request fields, pass in keyword arguments.
1092
+ # request = Google::Cloud::Tasks::V2beta2::UploadQueueYamlRequest.new
1093
+ #
1094
+ # # Call the upload_queue_yaml method.
1095
+ # result = client.upload_queue_yaml request
1096
+ #
1097
+ # # The returned object is of type Google::Protobuf::Empty.
1098
+ # p result
1099
+ #
1100
+ def upload_queue_yaml request, options = nil
1101
+ raise ::ArgumentError, "request must be provided" if request.nil?
1102
+
1103
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::UploadQueueYamlRequest
1104
+
1105
+ # Converts hash and nil to an options object
1106
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1107
+
1108
+ # Customize the options with defaults
1109
+ metadata = @config.rpcs.upload_queue_yaml.metadata.to_h
1110
+
1111
+ # Set x-goog-api-client and x-goog-user-project headers
1112
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1113
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1114
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION
1115
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1116
+
1117
+ options.apply_defaults timeout: @config.rpcs.upload_queue_yaml.timeout,
1118
+ metadata: metadata,
1119
+ retry_policy: @config.rpcs.upload_queue_yaml.retry_policy
1120
+
1121
+ options.apply_defaults timeout: @config.timeout,
1122
+ metadata: @config.metadata,
1123
+ retry_policy: @config.retry_policy
1124
+
1125
+ @cloud_tasks_stub.call_rpc :upload_queue_yaml, request, options: options do |response, operation|
1126
+ yield response, operation if block_given?
1127
+ return response
1128
+ end
1129
+ rescue ::GRPC::BadStatus => e
1130
+ raise ::Google::Cloud::Error.from_error(e)
1131
+ end
1132
+
1030
1133
  ##
1031
1134
  # Gets the access control policy for a
1032
1135
  # {::Google::Cloud::Tasks::V2beta2::Queue Queue}. Returns an empty policy if the
@@ -1612,10 +1715,10 @@ module Google
1612
1715
  # that was deleted or completed recently then the call will fail
1613
1716
  # with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS].
1614
1717
  # If the task's queue was created using Cloud Tasks, then another task with
1615
- # the same name can't be created for ~1hour after the original task was
1718
+ # the same name can't be created for ~1 hour after the original task was
1616
1719
  # deleted or completed. If the task's queue was created using queue.yaml or
1617
1720
  # queue.xml, then another task with the same name can't be created
1618
- # for ~9days after the original task was deleted or completed.
1721
+ # for ~9 days after the original task was deleted or completed.
1619
1722
  #
1620
1723
  # Because there is an extra lookup cost to identify duplicate task
1621
1724
  # names, these {::Google::Cloud::Tasks::V2beta2::CloudTasks::Client#create_task CreateTask}
@@ -2446,6 +2549,115 @@ module Google
2446
2549
  raise ::Google::Cloud::Error.from_error(e)
2447
2550
  end
2448
2551
 
2552
+ ##
2553
+ # Creates and buffers a new task without the need to explicitly define a Task
2554
+ # message. The queue must have [HTTP
2555
+ # target][google.cloud.tasks.v2beta2.HttpTarget]. To create the task with a
2556
+ # custom ID, use the following format and set TASK_ID to your desired ID:
2557
+ # projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID:buffer
2558
+ # To create the task with an automatically generated ID, use the following
2559
+ # format:
2560
+ # projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks:buffer.
2561
+ # Note: This feature is in its experimental stage. You must request access to
2562
+ # the API through the [Cloud Tasks BufferTask Experiment Signup
2563
+ # form](https://forms.gle/X8Zr5hiXH5tTGFqh8).
2564
+ #
2565
+ # @overload buffer_task(request, options = nil)
2566
+ # Pass arguments to `buffer_task` via a request object, either of type
2567
+ # {::Google::Cloud::Tasks::V2beta2::BufferTaskRequest} or an equivalent Hash.
2568
+ #
2569
+ # @param request [::Google::Cloud::Tasks::V2beta2::BufferTaskRequest, ::Hash]
2570
+ # A request object representing the call parameters. Required. To specify no
2571
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2572
+ # @param options [::Gapic::CallOptions, ::Hash]
2573
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
2574
+ #
2575
+ # @overload buffer_task(queue: nil, task_id: nil, body: nil)
2576
+ # Pass arguments to `buffer_task` via keyword arguments. Note that at
2577
+ # least one keyword argument is required. To specify no parameters, or to keep all
2578
+ # the default parameter values, pass an empty Hash as a request object (see above).
2579
+ #
2580
+ # @param queue [::String]
2581
+ # Required. The parent queue name. For example:
2582
+ # projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
2583
+ #
2584
+ # The queue must already exist.
2585
+ # @param task_id [::String]
2586
+ # Optional. Task ID for the task being created. If not provided, a random
2587
+ # task ID is assigned to the task.
2588
+ # @param body [::Google::Api::HttpBody, ::Hash]
2589
+ # Optional. Body of the HTTP request.
2590
+ #
2591
+ # The body can take any generic value. The value is written to the
2592
+ # [HttpRequest][payload] of the [Task].
2593
+ #
2594
+ # @yield [response, operation] Access the result along with the RPC operation
2595
+ # @yieldparam response [::Google::Cloud::Tasks::V2beta2::BufferTaskResponse]
2596
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
2597
+ #
2598
+ # @return [::Google::Cloud::Tasks::V2beta2::BufferTaskResponse]
2599
+ #
2600
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
2601
+ #
2602
+ # @example Basic example
2603
+ # require "google/cloud/tasks/v2beta2"
2604
+ #
2605
+ # # Create a client object. The client can be reused for multiple calls.
2606
+ # client = Google::Cloud::Tasks::V2beta2::CloudTasks::Client.new
2607
+ #
2608
+ # # Create a request. To set request fields, pass in keyword arguments.
2609
+ # request = Google::Cloud::Tasks::V2beta2::BufferTaskRequest.new
2610
+ #
2611
+ # # Call the buffer_task method.
2612
+ # result = client.buffer_task request
2613
+ #
2614
+ # # The returned object is of type Google::Cloud::Tasks::V2beta2::BufferTaskResponse.
2615
+ # p result
2616
+ #
2617
+ def buffer_task request, options = nil
2618
+ raise ::ArgumentError, "request must be provided" if request.nil?
2619
+
2620
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::BufferTaskRequest
2621
+
2622
+ # Converts hash and nil to an options object
2623
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2624
+
2625
+ # Customize the options with defaults
2626
+ metadata = @config.rpcs.buffer_task.metadata.to_h
2627
+
2628
+ # Set x-goog-api-client and x-goog-user-project headers
2629
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2630
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2631
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION
2632
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2633
+
2634
+ header_params = {}
2635
+ if request.queue
2636
+ header_params["queue"] = request.queue
2637
+ end
2638
+ if request.task_id
2639
+ header_params["task_id"] = request.task_id
2640
+ end
2641
+
2642
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
2643
+ metadata[:"x-goog-request-params"] ||= request_params_header
2644
+
2645
+ options.apply_defaults timeout: @config.rpcs.buffer_task.timeout,
2646
+ metadata: metadata,
2647
+ retry_policy: @config.rpcs.buffer_task.retry_policy
2648
+
2649
+ options.apply_defaults timeout: @config.timeout,
2650
+ metadata: @config.metadata,
2651
+ retry_policy: @config.retry_policy
2652
+
2653
+ @cloud_tasks_stub.call_rpc :buffer_task, request, options: options do |response, operation|
2654
+ yield response, operation if block_given?
2655
+ return response
2656
+ end
2657
+ rescue ::GRPC::BadStatus => e
2658
+ raise ::Google::Cloud::Error.from_error(e)
2659
+ end
2660
+
2449
2661
  ##
2450
2662
  # Configuration class for the CloudTasks API.
2451
2663
  #
@@ -2528,7 +2740,9 @@ module Google
2528
2740
  class Configuration
2529
2741
  extend ::Gapic::Config
2530
2742
 
2531
- config_attr :endpoint, "cloudtasks.googleapis.com", ::String
2743
+ DEFAULT_ENDPOINT = "cloudtasks.googleapis.com"
2744
+
2745
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
2532
2746
  config_attr :credentials, nil do |value|
2533
2747
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
2534
2748
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
@@ -2622,6 +2836,11 @@ module Google
2622
2836
  #
2623
2837
  attr_reader :resume_queue
2624
2838
  ##
2839
+ # RPC-specific configuration for `upload_queue_yaml`
2840
+ # @return [::Gapic::Config::Method]
2841
+ #
2842
+ attr_reader :upload_queue_yaml
2843
+ ##
2625
2844
  # RPC-specific configuration for `get_iam_policy`
2626
2845
  # @return [::Gapic::Config::Method]
2627
2846
  #
@@ -2681,6 +2900,11 @@ module Google
2681
2900
  # @return [::Gapic::Config::Method]
2682
2901
  #
2683
2902
  attr_reader :run_task
2903
+ ##
2904
+ # RPC-specific configuration for `buffer_task`
2905
+ # @return [::Gapic::Config::Method]
2906
+ #
2907
+ attr_reader :buffer_task
2684
2908
 
2685
2909
  # @private
2686
2910
  def initialize parent_rpcs = nil
@@ -2700,6 +2924,8 @@ module Google
2700
2924
  @pause_queue = ::Gapic::Config::Method.new pause_queue_config
2701
2925
  resume_queue_config = parent_rpcs.resume_queue if parent_rpcs.respond_to? :resume_queue
2702
2926
  @resume_queue = ::Gapic::Config::Method.new resume_queue_config
2927
+ upload_queue_yaml_config = parent_rpcs.upload_queue_yaml if parent_rpcs.respond_to? :upload_queue_yaml
2928
+ @upload_queue_yaml = ::Gapic::Config::Method.new upload_queue_yaml_config
2703
2929
  get_iam_policy_config = parent_rpcs.get_iam_policy if parent_rpcs.respond_to? :get_iam_policy
2704
2930
  @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
2705
2931
  set_iam_policy_config = parent_rpcs.set_iam_policy if parent_rpcs.respond_to? :set_iam_policy
@@ -2724,6 +2950,8 @@ module Google
2724
2950
  @cancel_lease = ::Gapic::Config::Method.new cancel_lease_config
2725
2951
  run_task_config = parent_rpcs.run_task if parent_rpcs.respond_to? :run_task
2726
2952
  @run_task = ::Gapic::Config::Method.new run_task_config
2953
+ buffer_task_config = parent_rpcs.buffer_task if parent_rpcs.respond_to? :buffer_task
2954
+ @buffer_task = ::Gapic::Config::Method.new buffer_task_config
2727
2955
 
2728
2956
  yield self if block_given?
2729
2957
  end
@@ -19,6 +19,7 @@
19
19
  require "google/cloud/errors"
20
20
  require "google/cloud/tasks/v2beta2/cloudtasks_pb"
21
21
  require "google/cloud/tasks/v2beta2/cloud_tasks/rest/service_stub"
22
+ require "google/cloud/location/rest"
22
23
 
23
24
  module Google
24
25
  module Cloud
@@ -131,6 +132,8 @@ module Google
131
132
 
132
133
  default_config.rpcs.run_task.timeout = 20.0
133
134
 
135
+ default_config.rpcs.buffer_task.timeout = 20.0
136
+
134
137
  default_config
135
138
  end
136
139
  yield @configure if block_given?
@@ -184,7 +187,7 @@ module Google
184
187
  credentials = @config.credentials
185
188
  # Use self-signed JWT if the endpoint is unchanged from default,
186
189
  # but only if the default endpoint does not have a region prefix.
187
- enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
190
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
188
191
  !@config.endpoint.split(".").first.include?("-")
189
192
  credentials ||= Credentials.default scope: @config.scope,
190
193
  enable_self_signed_jwt: enable_self_signed_jwt
@@ -195,9 +198,23 @@ module Google
195
198
  @quota_project_id = @config.quota_project
196
199
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
197
200
 
201
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
202
+ config.credentials = credentials
203
+ config.quota_project = @quota_project_id
204
+ config.endpoint = @config.endpoint
205
+ config.bindings_override = @config.bindings_override
206
+ end
207
+
198
208
  @cloud_tasks_stub = ::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
199
209
  end
200
210
 
211
+ ##
212
+ # Get the associated client for mix-in of the Locations.
213
+ #
214
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
215
+ #
216
+ attr_reader :location_client
217
+
201
218
  # Service calls
202
219
 
203
220
  ##
@@ -404,7 +421,7 @@ module Google
404
421
  #
405
422
  # The list of allowed locations can be obtained by calling Cloud
406
423
  # Tasks' implementation of
407
- # [ListLocations][google.cloud.location.Locations.ListLocations].
424
+ # `::Google::Cloud::Location::Locations::Rest::Client#list_locations`.
408
425
  # @param queue [::Google::Cloud::Tasks::V2beta2::Queue, ::Hash]
409
426
  # Required. The queue to create.
410
427
  #
@@ -1296,10 +1313,10 @@ module Google
1296
1313
  # that was deleted or completed recently then the call will fail
1297
1314
  # with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS].
1298
1315
  # If the task's queue was created using Cloud Tasks, then another task with
1299
- # the same name can't be created for ~1hour after the original task was
1316
+ # the same name can't be created for ~1 hour after the original task was
1300
1317
  # deleted or completed. If the task's queue was created using queue.yaml or
1301
1318
  # queue.xml, then another task with the same name can't be created
1302
- # for ~9days after the original task was deleted or completed.
1319
+ # for ~9 days after the original task was deleted or completed.
1303
1320
  #
1304
1321
  # Because there is an extra lookup cost to identify duplicate task
1305
1322
  # names, these {::Google::Cloud::Tasks::V2beta2::CloudTasks::Rest::Client#create_task CreateTask}
@@ -1969,6 +1986,89 @@ module Google
1969
1986
  raise ::Google::Cloud::Error.from_error(e)
1970
1987
  end
1971
1988
 
1989
+ ##
1990
+ # Creates and buffers a new task without the need to explicitly define a Task
1991
+ # message. The queue must have [HTTP
1992
+ # target][google.cloud.tasks.v2beta2.HttpTarget]. To create the task with a
1993
+ # custom ID, use the following format and set TASK_ID to your desired ID:
1994
+ # projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID:buffer
1995
+ # To create the task with an automatically generated ID, use the following
1996
+ # format:
1997
+ # projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks:buffer.
1998
+ # Note: This feature is in its experimental stage. You must request access to
1999
+ # the API through the [Cloud Tasks BufferTask Experiment Signup
2000
+ # form](https://forms.gle/X8Zr5hiXH5tTGFqh8).
2001
+ #
2002
+ # @overload buffer_task(request, options = nil)
2003
+ # Pass arguments to `buffer_task` via a request object, either of type
2004
+ # {::Google::Cloud::Tasks::V2beta2::BufferTaskRequest} or an equivalent Hash.
2005
+ #
2006
+ # @param request [::Google::Cloud::Tasks::V2beta2::BufferTaskRequest, ::Hash]
2007
+ # A request object representing the call parameters. Required. To specify no
2008
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2009
+ # @param options [::Gapic::CallOptions, ::Hash]
2010
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
2011
+ #
2012
+ # @overload buffer_task(queue: nil, task_id: nil, body: nil)
2013
+ # Pass arguments to `buffer_task` via keyword arguments. Note that at
2014
+ # least one keyword argument is required. To specify no parameters, or to keep all
2015
+ # the default parameter values, pass an empty Hash as a request object (see above).
2016
+ #
2017
+ # @param queue [::String]
2018
+ # Required. The parent queue name. For example:
2019
+ # projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
2020
+ #
2021
+ # The queue must already exist.
2022
+ # @param task_id [::String]
2023
+ # Optional. Task ID for the task being created. If not provided, a random
2024
+ # task ID is assigned to the task.
2025
+ # @param body [::Google::Api::HttpBody, ::Hash]
2026
+ # Optional. Body of the HTTP request.
2027
+ #
2028
+ # The body can take any generic value. The value is written to the
2029
+ # [HttpRequest][payload] of the [Task].
2030
+ # @yield [result, operation] Access the result along with the TransportOperation object
2031
+ # @yieldparam result [::Google::Cloud::Tasks::V2beta2::BufferTaskResponse]
2032
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
2033
+ #
2034
+ # @return [::Google::Cloud::Tasks::V2beta2::BufferTaskResponse]
2035
+ #
2036
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
2037
+ def buffer_task request, options = nil
2038
+ raise ::ArgumentError, "request must be provided" if request.nil?
2039
+
2040
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Tasks::V2beta2::BufferTaskRequest
2041
+
2042
+ # Converts hash and nil to an options object
2043
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2044
+
2045
+ # Customize the options with defaults
2046
+ call_metadata = @config.rpcs.buffer_task.metadata.to_h
2047
+
2048
+ # Set x-goog-api-client and x-goog-user-project headers
2049
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2050
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2051
+ gapic_version: ::Google::Cloud::Tasks::V2beta2::VERSION,
2052
+ transports_version_send: [:rest]
2053
+
2054
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2055
+
2056
+ options.apply_defaults timeout: @config.rpcs.buffer_task.timeout,
2057
+ metadata: call_metadata,
2058
+ retry_policy: @config.rpcs.buffer_task.retry_policy
2059
+
2060
+ options.apply_defaults timeout: @config.timeout,
2061
+ metadata: @config.metadata,
2062
+ retry_policy: @config.retry_policy
2063
+
2064
+ @cloud_tasks_stub.buffer_task request, options do |result, operation|
2065
+ yield result, operation if block_given?
2066
+ return result
2067
+ end
2068
+ rescue ::Gapic::Rest::Error => e
2069
+ raise ::Google::Cloud::Error.from_error(e)
2070
+ end
2071
+
1972
2072
  ##
1973
2073
  # Configuration class for the CloudTasks REST API.
1974
2074
  #
@@ -2042,7 +2142,9 @@ module Google
2042
2142
  class Configuration
2043
2143
  extend ::Gapic::Config
2044
2144
 
2045
- config_attr :endpoint, "cloudtasks.googleapis.com", ::String
2145
+ DEFAULT_ENDPOINT = "cloudtasks.googleapis.com"
2146
+
2147
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
2046
2148
  config_attr :credentials, nil do |value|
2047
2149
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
2048
2150
  allowed.any? { |klass| klass === value }
@@ -2055,6 +2157,13 @@ module Google
2055
2157
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2056
2158
  config_attr :quota_project, nil, ::String, nil
2057
2159
 
2160
+ # @private
2161
+ # Overrides for http bindings for the RPCs of this service
2162
+ # are only used when this service is used as mixin, and only
2163
+ # by the host service.
2164
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
2165
+ config_attr :bindings_override, {}, ::Hash, nil
2166
+
2058
2167
  # @private
2059
2168
  def initialize parent_config = nil
2060
2169
  @parent_config = parent_config unless parent_config.nil?
@@ -2192,6 +2301,11 @@ module Google
2192
2301
  # @return [::Gapic::Config::Method]
2193
2302
  #
2194
2303
  attr_reader :run_task
2304
+ ##
2305
+ # RPC-specific configuration for `buffer_task`
2306
+ # @return [::Gapic::Config::Method]
2307
+ #
2308
+ attr_reader :buffer_task
2195
2309
 
2196
2310
  # @private
2197
2311
  def initialize parent_rpcs = nil
@@ -2235,6 +2349,8 @@ module Google
2235
2349
  @cancel_lease = ::Gapic::Config::Method.new cancel_lease_config
2236
2350
  run_task_config = parent_rpcs.run_task if parent_rpcs.respond_to? :run_task
2237
2351
  @run_task = ::Gapic::Config::Method.new run_task_config
2352
+ buffer_task_config = parent_rpcs.buffer_task if parent_rpcs.respond_to? :buffer_task
2353
+ @buffer_task = ::Gapic::Config::Method.new buffer_task_config
2238
2354
 
2239
2355
  yield self if block_given?
2240
2356
  end