google-analytics-data-v1beta 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,779 @@
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/operation"
20
+ require "google/longrunning/operations_pb"
21
+
22
+ module Google
23
+ module Analytics
24
+ module Data
25
+ module V1beta
26
+ module AnalyticsData
27
+ # Service that implements Longrunning Operations API.
28
+ class Operations
29
+ # @private
30
+ attr_reader :operations_stub
31
+
32
+ ##
33
+ # Configuration for the AnalyticsData Operations API.
34
+ #
35
+ # @yield [config] Configure the Operations client.
36
+ # @yieldparam config [Operations::Configuration]
37
+ #
38
+ # @return [Operations::Configuration]
39
+ #
40
+ def self.configure
41
+ @configure ||= Operations::Configuration.new
42
+ yield @configure if block_given?
43
+ @configure
44
+ end
45
+
46
+ ##
47
+ # Configure the AnalyticsData Operations instance.
48
+ #
49
+ # The configuration is set to the derived mode, meaning that values can be changed,
50
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
51
+ # should be made on {Operations.configure}.
52
+ #
53
+ # @yield [config] Configure the Operations client.
54
+ # @yieldparam config [Operations::Configuration]
55
+ #
56
+ # @return [Operations::Configuration]
57
+ #
58
+ def configure
59
+ yield @config if block_given?
60
+ @config
61
+ end
62
+
63
+ ##
64
+ # Create a new Operations client object.
65
+ #
66
+ # @yield [config] Configure the Client client.
67
+ # @yieldparam config [Operations::Configuration]
68
+ #
69
+ def initialize
70
+ # These require statements are intentionally placed here to initialize
71
+ # the gRPC module only when it's required.
72
+ # See https://github.com/googleapis/toolkit/issues/446
73
+ require "gapic/grpc"
74
+ require "google/longrunning/operations_services_pb"
75
+
76
+ # Create the configuration object
77
+ @config = Configuration.new Operations.configure
78
+
79
+ # Yield the configuration if needed
80
+ yield @config if block_given?
81
+
82
+ # Create credentials
83
+ credentials = @config.credentials
84
+ credentials ||= Credentials.default scope: @config.scope
85
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
86
+ credentials = Credentials.new credentials, scope: @config.scope
87
+ end
88
+ @quota_project_id = @config.quota_project
89
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
90
+
91
+ @operations_stub = ::Gapic::ServiceStub.new(
92
+ ::Google::Longrunning::Operations::Stub,
93
+ credentials: credentials,
94
+ endpoint: @config.endpoint,
95
+ channel_args: @config.channel_args,
96
+ interceptors: @config.interceptors,
97
+ channel_pool_config: @config.channel_pool
98
+ )
99
+
100
+ # Used by an LRO wrapper for some methods of this service
101
+ @operations_client = self
102
+ end
103
+
104
+ # Service calls
105
+
106
+ ##
107
+ # Lists operations that match the specified filter in the request. If the
108
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
109
+ #
110
+ # NOTE: the `name` binding allows API services to override the binding
111
+ # to use different resource name schemes, such as `users/*/operations`. To
112
+ # override the binding, API services can add a binding such as
113
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
114
+ # For backwards compatibility, the default name includes the operations
115
+ # collection id, however overriding users must ensure the name binding
116
+ # is the parent resource, without the operations collection id.
117
+ #
118
+ # @overload list_operations(request, options = nil)
119
+ # Pass arguments to `list_operations` via a request object, either of type
120
+ # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
121
+ #
122
+ # @param request [::Google::Longrunning::ListOperationsRequest, ::Hash]
123
+ # A request object representing the call parameters. Required. To specify no
124
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
125
+ # @param options [::Gapic::CallOptions, ::Hash]
126
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
127
+ #
128
+ # @overload list_operations(name: nil, filter: nil, page_size: nil, page_token: nil)
129
+ # Pass arguments to `list_operations` via keyword arguments. Note that at
130
+ # least one keyword argument is required. To specify no parameters, or to keep all
131
+ # the default parameter values, pass an empty Hash as a request object (see above).
132
+ #
133
+ # @param name [::String]
134
+ # The name of the operation's parent resource.
135
+ # @param filter [::String]
136
+ # The standard list filter.
137
+ # @param page_size [::Integer]
138
+ # The standard list page size.
139
+ # @param page_token [::String]
140
+ # The standard list page token.
141
+ #
142
+ # @yield [response, operation] Access the result along with the RPC operation
143
+ # @yieldparam response [::Gapic::PagedEnumerable<::Gapic::Operation>]
144
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
145
+ #
146
+ # @return [::Gapic::PagedEnumerable<::Gapic::Operation>]
147
+ #
148
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
149
+ #
150
+ # @example Basic example
151
+ # require "google/longrunning"
152
+ #
153
+ # # Create a client object. The client can be reused for multiple calls.
154
+ # client = Google::Longrunning::Operations::Client.new
155
+ #
156
+ # # Create a request. To set request fields, pass in keyword arguments.
157
+ # request = Google::Longrunning::ListOperationsRequest.new
158
+ #
159
+ # # Call the list_operations method.
160
+ # result = client.list_operations request
161
+ #
162
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
163
+ # # over elements, and API calls will be issued to fetch pages as needed.
164
+ # result.each do |item|
165
+ # # Each element is of type ::Google::Longrunning::Operation.
166
+ # p item
167
+ # end
168
+ #
169
+ def list_operations request, options = nil
170
+ raise ::ArgumentError, "request must be provided" if request.nil?
171
+
172
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::ListOperationsRequest
173
+
174
+ # Converts hash and nil to an options object
175
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
176
+
177
+ # Customize the options with defaults
178
+ metadata = @config.rpcs.list_operations.metadata.to_h
179
+
180
+ # Set x-goog-api-client and x-goog-user-project headers
181
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
182
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
183
+ gapic_version: ::Google::Analytics::Data::V1beta::VERSION
184
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
185
+
186
+ header_params = {}
187
+ if request.name
188
+ header_params["name"] = request.name
189
+ end
190
+
191
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
192
+ metadata[:"x-goog-request-params"] ||= request_params_header
193
+
194
+ options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
195
+ metadata: metadata,
196
+ retry_policy: @config.rpcs.list_operations.retry_policy
197
+
198
+ options.apply_defaults timeout: @config.timeout,
199
+ metadata: @config.metadata,
200
+ retry_policy: @config.retry_policy
201
+
202
+ @operations_stub.call_rpc :list_operations, request, options: options do |response, operation|
203
+ wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
204
+ response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
205
+ yield response, operation if block_given?
206
+ return response
207
+ end
208
+ rescue ::GRPC::BadStatus => e
209
+ raise ::Google::Cloud::Error.from_error(e)
210
+ end
211
+
212
+ ##
213
+ # Gets the latest state of a long-running operation. Clients can use this
214
+ # method to poll the operation result at intervals as recommended by the API
215
+ # service.
216
+ #
217
+ # @overload get_operation(request, options = nil)
218
+ # Pass arguments to `get_operation` via a request object, either of type
219
+ # {::Google::Longrunning::GetOperationRequest} or an equivalent Hash.
220
+ #
221
+ # @param request [::Google::Longrunning::GetOperationRequest, ::Hash]
222
+ # A request object representing the call parameters. Required. To specify no
223
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
224
+ # @param options [::Gapic::CallOptions, ::Hash]
225
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
226
+ #
227
+ # @overload get_operation(name: nil)
228
+ # Pass arguments to `get_operation` via keyword arguments. Note that at
229
+ # least one keyword argument is required. To specify no parameters, or to keep all
230
+ # the default parameter values, pass an empty Hash as a request object (see above).
231
+ #
232
+ # @param name [::String]
233
+ # The name of the operation resource.
234
+ #
235
+ # @yield [response, operation] Access the result along with the RPC operation
236
+ # @yieldparam response [::Gapic::Operation]
237
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
238
+ #
239
+ # @return [::Gapic::Operation]
240
+ #
241
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
242
+ #
243
+ # @example Basic example
244
+ # require "google/longrunning"
245
+ #
246
+ # # Create a client object. The client can be reused for multiple calls.
247
+ # client = Google::Longrunning::Operations::Client.new
248
+ #
249
+ # # Create a request. To set request fields, pass in keyword arguments.
250
+ # request = Google::Longrunning::GetOperationRequest.new
251
+ #
252
+ # # Call the get_operation method.
253
+ # result = client.get_operation request
254
+ #
255
+ # # The returned object is of type Gapic::Operation. You can use it to
256
+ # # check the status of an operation, cancel it, or wait for results.
257
+ # # Here is how to wait for a response.
258
+ # result.wait_until_done! timeout: 60
259
+ # if result.response?
260
+ # p result.response
261
+ # else
262
+ # puts "No response received."
263
+ # end
264
+ #
265
+ def get_operation request, options = nil
266
+ raise ::ArgumentError, "request must be provided" if request.nil?
267
+
268
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::GetOperationRequest
269
+
270
+ # Converts hash and nil to an options object
271
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
272
+
273
+ # Customize the options with defaults
274
+ metadata = @config.rpcs.get_operation.metadata.to_h
275
+
276
+ # Set x-goog-api-client and x-goog-user-project headers
277
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
278
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
279
+ gapic_version: ::Google::Analytics::Data::V1beta::VERSION
280
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
281
+
282
+ header_params = {}
283
+ if request.name
284
+ header_params["name"] = request.name
285
+ end
286
+
287
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
288
+ metadata[:"x-goog-request-params"] ||= request_params_header
289
+
290
+ options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
291
+ metadata: metadata,
292
+ retry_policy: @config.rpcs.get_operation.retry_policy
293
+
294
+ options.apply_defaults timeout: @config.timeout,
295
+ metadata: @config.metadata,
296
+ retry_policy: @config.retry_policy
297
+
298
+ @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
299
+ response = ::Gapic::Operation.new response, @operations_client, options: options
300
+ yield response, operation if block_given?
301
+ return response
302
+ end
303
+ rescue ::GRPC::BadStatus => e
304
+ raise ::Google::Cloud::Error.from_error(e)
305
+ end
306
+
307
+ ##
308
+ # Deletes a long-running operation. This method indicates that the client is
309
+ # no longer interested in the operation result. It does not cancel the
310
+ # operation. If the server doesn't support this method, it returns
311
+ # `google.rpc.Code.UNIMPLEMENTED`.
312
+ #
313
+ # @overload delete_operation(request, options = nil)
314
+ # Pass arguments to `delete_operation` via a request object, either of type
315
+ # {::Google::Longrunning::DeleteOperationRequest} or an equivalent Hash.
316
+ #
317
+ # @param request [::Google::Longrunning::DeleteOperationRequest, ::Hash]
318
+ # A request object representing the call parameters. Required. To specify no
319
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
320
+ # @param options [::Gapic::CallOptions, ::Hash]
321
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
322
+ #
323
+ # @overload delete_operation(name: nil)
324
+ # Pass arguments to `delete_operation` via keyword arguments. Note that at
325
+ # least one keyword argument is required. To specify no parameters, or to keep all
326
+ # the default parameter values, pass an empty Hash as a request object (see above).
327
+ #
328
+ # @param name [::String]
329
+ # The name of the operation resource to be deleted.
330
+ #
331
+ # @yield [response, operation] Access the result along with the RPC operation
332
+ # @yieldparam response [::Google::Protobuf::Empty]
333
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
334
+ #
335
+ # @return [::Google::Protobuf::Empty]
336
+ #
337
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
338
+ #
339
+ # @example Basic example
340
+ # require "google/longrunning"
341
+ #
342
+ # # Create a client object. The client can be reused for multiple calls.
343
+ # client = Google::Longrunning::Operations::Client.new
344
+ #
345
+ # # Create a request. To set request fields, pass in keyword arguments.
346
+ # request = Google::Longrunning::DeleteOperationRequest.new
347
+ #
348
+ # # Call the delete_operation method.
349
+ # result = client.delete_operation request
350
+ #
351
+ # # The returned object is of type Google::Protobuf::Empty.
352
+ # p result
353
+ #
354
+ def delete_operation request, options = nil
355
+ raise ::ArgumentError, "request must be provided" if request.nil?
356
+
357
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::DeleteOperationRequest
358
+
359
+ # Converts hash and nil to an options object
360
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
361
+
362
+ # Customize the options with defaults
363
+ metadata = @config.rpcs.delete_operation.metadata.to_h
364
+
365
+ # Set x-goog-api-client and x-goog-user-project headers
366
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
367
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
368
+ gapic_version: ::Google::Analytics::Data::V1beta::VERSION
369
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
370
+
371
+ header_params = {}
372
+ if request.name
373
+ header_params["name"] = request.name
374
+ end
375
+
376
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
377
+ metadata[:"x-goog-request-params"] ||= request_params_header
378
+
379
+ options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
380
+ metadata: metadata,
381
+ retry_policy: @config.rpcs.delete_operation.retry_policy
382
+
383
+ options.apply_defaults timeout: @config.timeout,
384
+ metadata: @config.metadata,
385
+ retry_policy: @config.retry_policy
386
+
387
+ @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
388
+ yield response, operation if block_given?
389
+ return response
390
+ end
391
+ rescue ::GRPC::BadStatus => e
392
+ raise ::Google::Cloud::Error.from_error(e)
393
+ end
394
+
395
+ ##
396
+ # Starts asynchronous cancellation on a long-running operation. The server
397
+ # makes a best effort to cancel the operation, but success is not
398
+ # guaranteed. If the server doesn't support this method, it returns
399
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
400
+ # Operations.GetOperation or
401
+ # other methods to check whether the cancellation succeeded or whether the
402
+ # operation completed despite cancellation. On successful cancellation,
403
+ # the operation is not deleted; instead, it becomes an operation with
404
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
405
+ # corresponding to `Code.CANCELLED`.
406
+ #
407
+ # @overload cancel_operation(request, options = nil)
408
+ # Pass arguments to `cancel_operation` via a request object, either of type
409
+ # {::Google::Longrunning::CancelOperationRequest} or an equivalent Hash.
410
+ #
411
+ # @param request [::Google::Longrunning::CancelOperationRequest, ::Hash]
412
+ # A request object representing the call parameters. Required. To specify no
413
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
414
+ # @param options [::Gapic::CallOptions, ::Hash]
415
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
416
+ #
417
+ # @overload cancel_operation(name: nil)
418
+ # Pass arguments to `cancel_operation` via keyword arguments. Note that at
419
+ # least one keyword argument is required. To specify no parameters, or to keep all
420
+ # the default parameter values, pass an empty Hash as a request object (see above).
421
+ #
422
+ # @param name [::String]
423
+ # The name of the operation resource to be cancelled.
424
+ #
425
+ # @yield [response, operation] Access the result along with the RPC operation
426
+ # @yieldparam response [::Google::Protobuf::Empty]
427
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
428
+ #
429
+ # @return [::Google::Protobuf::Empty]
430
+ #
431
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
432
+ #
433
+ # @example Basic example
434
+ # require "google/longrunning"
435
+ #
436
+ # # Create a client object. The client can be reused for multiple calls.
437
+ # client = Google::Longrunning::Operations::Client.new
438
+ #
439
+ # # Create a request. To set request fields, pass in keyword arguments.
440
+ # request = Google::Longrunning::CancelOperationRequest.new
441
+ #
442
+ # # Call the cancel_operation method.
443
+ # result = client.cancel_operation request
444
+ #
445
+ # # The returned object is of type Google::Protobuf::Empty.
446
+ # p result
447
+ #
448
+ def cancel_operation request, options = nil
449
+ raise ::ArgumentError, "request must be provided" if request.nil?
450
+
451
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::CancelOperationRequest
452
+
453
+ # Converts hash and nil to an options object
454
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
455
+
456
+ # Customize the options with defaults
457
+ metadata = @config.rpcs.cancel_operation.metadata.to_h
458
+
459
+ # Set x-goog-api-client and x-goog-user-project headers
460
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
461
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
462
+ gapic_version: ::Google::Analytics::Data::V1beta::VERSION
463
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
464
+
465
+ header_params = {}
466
+ if request.name
467
+ header_params["name"] = request.name
468
+ end
469
+
470
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
471
+ metadata[:"x-goog-request-params"] ||= request_params_header
472
+
473
+ options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
474
+ metadata: metadata,
475
+ retry_policy: @config.rpcs.cancel_operation.retry_policy
476
+
477
+ options.apply_defaults timeout: @config.timeout,
478
+ metadata: @config.metadata,
479
+ retry_policy: @config.retry_policy
480
+
481
+ @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
482
+ yield response, operation if block_given?
483
+ return response
484
+ end
485
+ rescue ::GRPC::BadStatus => e
486
+ raise ::Google::Cloud::Error.from_error(e)
487
+ end
488
+
489
+ ##
490
+ # Waits until the specified long-running operation is done or reaches at most
491
+ # a specified timeout, returning the latest state. If the operation is
492
+ # already done, the latest state is immediately returned. If the timeout
493
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
494
+ # timeout is used. If the server does not support this method, it returns
495
+ # `google.rpc.Code.UNIMPLEMENTED`.
496
+ # Note that this method is on a best-effort basis. It may return the latest
497
+ # state before the specified timeout (including immediately), meaning even an
498
+ # immediate response is no guarantee that the operation is done.
499
+ #
500
+ # @overload wait_operation(request, options = nil)
501
+ # Pass arguments to `wait_operation` via a request object, either of type
502
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
503
+ #
504
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
505
+ # A request object representing the call parameters. Required. To specify no
506
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
507
+ # @param options [::Gapic::CallOptions, ::Hash]
508
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
509
+ #
510
+ # @overload wait_operation(name: nil, timeout: nil)
511
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
512
+ # least one keyword argument is required. To specify no parameters, or to keep all
513
+ # the default parameter values, pass an empty Hash as a request object (see above).
514
+ #
515
+ # @param name [::String]
516
+ # The name of the operation resource to wait on.
517
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
518
+ # The maximum duration to wait before timing out. If left blank, the wait
519
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
520
+ # If RPC context deadline is also specified, the shorter one will be used.
521
+ #
522
+ # @yield [response, operation] Access the result along with the RPC operation
523
+ # @yieldparam response [::Gapic::Operation]
524
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
525
+ #
526
+ # @return [::Gapic::Operation]
527
+ #
528
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
529
+ #
530
+ # @example Basic example
531
+ # require "google/longrunning"
532
+ #
533
+ # # Create a client object. The client can be reused for multiple calls.
534
+ # client = Google::Longrunning::Operations::Client.new
535
+ #
536
+ # # Create a request. To set request fields, pass in keyword arguments.
537
+ # request = Google::Longrunning::WaitOperationRequest.new
538
+ #
539
+ # # Call the wait_operation method.
540
+ # result = client.wait_operation request
541
+ #
542
+ # # The returned object is of type Gapic::Operation. You can use it to
543
+ # # check the status of an operation, cancel it, or wait for results.
544
+ # # Here is how to wait for a response.
545
+ # result.wait_until_done! timeout: 60
546
+ # if result.response?
547
+ # p result.response
548
+ # else
549
+ # puts "No response received."
550
+ # end
551
+ #
552
+ def wait_operation request, options = nil
553
+ raise ::ArgumentError, "request must be provided" if request.nil?
554
+
555
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
556
+
557
+ # Converts hash and nil to an options object
558
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
559
+
560
+ # Customize the options with defaults
561
+ metadata = @config.rpcs.wait_operation.metadata.to_h
562
+
563
+ # Set x-goog-api-client and x-goog-user-project headers
564
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
565
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
566
+ gapic_version: ::Google::Analytics::Data::V1beta::VERSION
567
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
568
+
569
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
570
+ metadata: metadata,
571
+ retry_policy: @config.rpcs.wait_operation.retry_policy
572
+
573
+ options.apply_defaults timeout: @config.timeout,
574
+ metadata: @config.metadata,
575
+ retry_policy: @config.retry_policy
576
+
577
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
578
+ response = ::Gapic::Operation.new response, @operations_client, options: options
579
+ yield response, operation if block_given?
580
+ return response
581
+ end
582
+ rescue ::GRPC::BadStatus => e
583
+ raise ::Google::Cloud::Error.from_error(e)
584
+ end
585
+
586
+ ##
587
+ # Configuration class for the Operations API.
588
+ #
589
+ # This class represents the configuration for Operations,
590
+ # providing control over timeouts, retry behavior, logging, transport
591
+ # parameters, and other low-level controls. Certain parameters can also be
592
+ # applied individually to specific RPCs. See
593
+ # {::Google::Longrunning::Operations::Client::Configuration::Rpcs}
594
+ # for a list of RPCs that can be configured independently.
595
+ #
596
+ # Configuration can be applied globally to all clients, or to a single client
597
+ # on construction.
598
+ #
599
+ # @example
600
+ #
601
+ # # Modify the global config, setting the timeout for
602
+ # # list_operations to 20 seconds,
603
+ # # and all remaining timeouts to 10 seconds.
604
+ # ::Google::Longrunning::Operations::Client.configure do |config|
605
+ # config.timeout = 10.0
606
+ # config.rpcs.list_operations.timeout = 20.0
607
+ # end
608
+ #
609
+ # # Apply the above configuration only to a new client.
610
+ # client = ::Google::Longrunning::Operations::Client.new do |config|
611
+ # config.timeout = 10.0
612
+ # config.rpcs.list_operations.timeout = 20.0
613
+ # end
614
+ #
615
+ # @!attribute [rw] endpoint
616
+ # The hostname or hostname:port of the service endpoint.
617
+ # Defaults to `"analyticsdata.googleapis.com"`.
618
+ # @return [::String]
619
+ # @!attribute [rw] credentials
620
+ # Credentials to send with calls. You may provide any of the following types:
621
+ # * (`String`) The path to a service account key file in JSON format
622
+ # * (`Hash`) A service account key as a Hash
623
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
624
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
625
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
626
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
627
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
628
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
629
+ # * (`nil`) indicating no credentials
630
+ # @return [::Object]
631
+ # @!attribute [rw] scope
632
+ # The OAuth scopes
633
+ # @return [::Array<::String>]
634
+ # @!attribute [rw] lib_name
635
+ # The library name as recorded in instrumentation and logging
636
+ # @return [::String]
637
+ # @!attribute [rw] lib_version
638
+ # The library version as recorded in instrumentation and logging
639
+ # @return [::String]
640
+ # @!attribute [rw] channel_args
641
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
642
+ # `GRPC::Core::Channel` object is provided as the credential.
643
+ # @return [::Hash]
644
+ # @!attribute [rw] interceptors
645
+ # An array of interceptors that are run before calls are executed.
646
+ # @return [::Array<::GRPC::ClientInterceptor>]
647
+ # @!attribute [rw] timeout
648
+ # The call timeout in seconds.
649
+ # @return [::Numeric]
650
+ # @!attribute [rw] metadata
651
+ # Additional gRPC headers to be sent with the call.
652
+ # @return [::Hash{::Symbol=>::String}]
653
+ # @!attribute [rw] retry_policy
654
+ # The retry policy. The value is a hash with the following keys:
655
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
656
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
657
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
658
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
659
+ # trigger a retry.
660
+ # @return [::Hash]
661
+ # @!attribute [rw] quota_project
662
+ # A separate project against which to charge quota.
663
+ # @return [::String]
664
+ #
665
+ class Configuration
666
+ extend ::Gapic::Config
667
+
668
+ DEFAULT_ENDPOINT = "analyticsdata.googleapis.com"
669
+
670
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
671
+ config_attr :credentials, nil do |value|
672
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
673
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
674
+ allowed.any? { |klass| klass === value }
675
+ end
676
+ config_attr :scope, nil, ::String, ::Array, nil
677
+ config_attr :lib_name, nil, ::String, nil
678
+ config_attr :lib_version, nil, ::String, nil
679
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
680
+ config_attr :interceptors, nil, ::Array, nil
681
+ config_attr :timeout, nil, ::Numeric, nil
682
+ config_attr :metadata, nil, ::Hash, nil
683
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
684
+ config_attr :quota_project, nil, ::String, nil
685
+
686
+ # @private
687
+ def initialize parent_config = nil
688
+ @parent_config = parent_config unless parent_config.nil?
689
+
690
+ yield self if block_given?
691
+ end
692
+
693
+ ##
694
+ # Configurations for individual RPCs
695
+ # @return [Rpcs]
696
+ #
697
+ def rpcs
698
+ @rpcs ||= begin
699
+ parent_rpcs = nil
700
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
701
+ Rpcs.new parent_rpcs
702
+ end
703
+ end
704
+
705
+ ##
706
+ # Configuration for the channel pool
707
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
708
+ #
709
+ def channel_pool
710
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
711
+ end
712
+
713
+ ##
714
+ # Configuration RPC class for the Operations API.
715
+ #
716
+ # Includes fields providing the configuration for each RPC in this service.
717
+ # Each configuration object is of type `Gapic::Config::Method` and includes
718
+ # the following configuration fields:
719
+ #
720
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
721
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
722
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
723
+ # include the following keys:
724
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
725
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
726
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
727
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
728
+ # trigger a retry.
729
+ #
730
+ class Rpcs
731
+ ##
732
+ # RPC-specific configuration for `list_operations`
733
+ # @return [::Gapic::Config::Method]
734
+ #
735
+ attr_reader :list_operations
736
+ ##
737
+ # RPC-specific configuration for `get_operation`
738
+ # @return [::Gapic::Config::Method]
739
+ #
740
+ attr_reader :get_operation
741
+ ##
742
+ # RPC-specific configuration for `delete_operation`
743
+ # @return [::Gapic::Config::Method]
744
+ #
745
+ attr_reader :delete_operation
746
+ ##
747
+ # RPC-specific configuration for `cancel_operation`
748
+ # @return [::Gapic::Config::Method]
749
+ #
750
+ attr_reader :cancel_operation
751
+ ##
752
+ # RPC-specific configuration for `wait_operation`
753
+ # @return [::Gapic::Config::Method]
754
+ #
755
+ attr_reader :wait_operation
756
+
757
+ # @private
758
+ def initialize parent_rpcs = nil
759
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
760
+ @list_operations = ::Gapic::Config::Method.new list_operations_config
761
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
762
+ @get_operation = ::Gapic::Config::Method.new get_operation_config
763
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
764
+ @delete_operation = ::Gapic::Config::Method.new delete_operation_config
765
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
766
+ @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
767
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
768
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
769
+
770
+ yield self if block_given?
771
+ end
772
+ end
773
+ end
774
+ end
775
+ end
776
+ end
777
+ end
778
+ end
779
+ end