google-cloud-datastore-admin-v1 0.7.1 → 0.9.0

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