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