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