google-cloud-security-private_ca-v1beta1 0.3.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 Security
24
+ module PrivateCA
25
+ module V1beta1
26
+ module CertificateAuthorityService
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 CertificateAuthorityService 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 CertificateAuthorityService 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::Security::PrivateCA::V1beta1::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::Security::PrivateCA::V1beta1::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::Security::PrivateCA::V1beta1::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::Security::PrivateCA::V1beta1::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 `"privateca.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://googleapis.dev/ruby/googleauth/latest/index.html))
416
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
417
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
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
+ config_attr :endpoint, "privateca.googleapis.com", ::String
451
+ config_attr :credentials, nil do |value|
452
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
453
+ allowed.any? { |klass| klass === value }
454
+ end
455
+ config_attr :scope, nil, ::String, ::Array, nil
456
+ config_attr :lib_name, nil, ::String, nil
457
+ config_attr :lib_version, nil, ::String, nil
458
+ config_attr :timeout, nil, ::Numeric, nil
459
+ config_attr :metadata, nil, ::Hash, nil
460
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
461
+ config_attr :quota_project, nil, ::String, nil
462
+
463
+ # @private
464
+ def initialize parent_config = nil
465
+ @parent_config = parent_config unless parent_config.nil?
466
+
467
+ yield self if block_given?
468
+ end
469
+
470
+ ##
471
+ # Configurations for individual RPCs
472
+ # @return [Rpcs]
473
+ #
474
+ def rpcs
475
+ @rpcs ||= begin
476
+ parent_rpcs = nil
477
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
478
+ Rpcs.new parent_rpcs
479
+ end
480
+ end
481
+
482
+ ##
483
+ # Configuration RPC class for the Operations API.
484
+ #
485
+ # Includes fields providing the configuration for each RPC in this service.
486
+ # Each configuration object is of type `Gapic::Config::Method` and includes
487
+ # the following configuration fields:
488
+ #
489
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
490
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
491
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
492
+ # include the following keys:
493
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
494
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
495
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
496
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
497
+ # trigger a retry.
498
+ #
499
+ class Rpcs
500
+ ##
501
+ # RPC-specific configuration for `list_operations`
502
+ # @return [::Gapic::Config::Method]
503
+ #
504
+ attr_reader :list_operations
505
+ ##
506
+ # RPC-specific configuration for `get_operation`
507
+ # @return [::Gapic::Config::Method]
508
+ #
509
+ attr_reader :get_operation
510
+ ##
511
+ # RPC-specific configuration for `delete_operation`
512
+ # @return [::Gapic::Config::Method]
513
+ #
514
+ attr_reader :delete_operation
515
+ ##
516
+ # RPC-specific configuration for `cancel_operation`
517
+ # @return [::Gapic::Config::Method]
518
+ #
519
+ attr_reader :cancel_operation
520
+
521
+ # @private
522
+ def initialize parent_rpcs = nil
523
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
524
+ @list_operations = ::Gapic::Config::Method.new list_operations_config
525
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
526
+ @get_operation = ::Gapic::Config::Method.new get_operation_config
527
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
528
+ @delete_operation = ::Gapic::Config::Method.new delete_operation_config
529
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
530
+ @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
531
+
532
+ yield self if block_given?
533
+ end
534
+ end
535
+ end
536
+ end
537
+
538
+ ##
539
+ # @private
540
+ # REST service stub for the Longrunning Operations API.
541
+ # Service stub contains baseline method implementations
542
+ # including transcoding, making the REST call, and deserialing the response.
543
+ class OperationsServiceStub
544
+ def initialize endpoint:, credentials:
545
+ # These require statements are intentionally placed here to initialize
546
+ # the REST modules only when it's required.
547
+ require "gapic/rest"
548
+
549
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials
550
+ end
551
+
552
+ ##
553
+ # Baseline implementation for the list_operations REST call
554
+ #
555
+ # @param request_pb [::Google::Longrunning::ListOperationsRequest]
556
+ # A request object representing the call parameters. Required.
557
+ # @param options [::Gapic::CallOptions]
558
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
559
+ #
560
+ # @yield [result, operation] Access the result along with the TransportOperation object
561
+ # @yieldparam result [::Google::Longrunning::ListOperationsResponse]
562
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
563
+ #
564
+ # @return [::Google::Longrunning::ListOperationsResponse]
565
+ # A result object deserialized from the server's reply
566
+ def list_operations request_pb, options = nil
567
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
568
+
569
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_list_operations_request request_pb
570
+ query_string_params = if query_string_params.any?
571
+ query_string_params.to_h { |p| p.split("=", 2) }
572
+ else
573
+ {}
574
+ end
575
+
576
+ response = @client_stub.make_http_request(
577
+ verb,
578
+ uri: uri,
579
+ body: body || "",
580
+ params: query_string_params,
581
+ options: options
582
+ )
583
+ operation = ::Gapic::Rest::TransportOperation.new response
584
+ result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
585
+
586
+ yield result, operation if block_given?
587
+ result
588
+ end
589
+
590
+ ##
591
+ # Baseline implementation for the get_operation REST call
592
+ #
593
+ # @param request_pb [::Google::Longrunning::GetOperationRequest]
594
+ # A request object representing the call parameters. Required.
595
+ # @param options [::Gapic::CallOptions]
596
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
597
+ #
598
+ # @yield [result, operation] Access the result along with the TransportOperation object
599
+ # @yieldparam result [::Google::Longrunning::Operation]
600
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
601
+ #
602
+ # @return [::Google::Longrunning::Operation]
603
+ # A result object deserialized from the server's reply
604
+ def get_operation request_pb, options = nil
605
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
606
+
607
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_get_operation_request request_pb
608
+ query_string_params = if query_string_params.any?
609
+ query_string_params.to_h { |p| p.split("=", 2) }
610
+ else
611
+ {}
612
+ end
613
+
614
+ response = @client_stub.make_http_request(
615
+ verb,
616
+ uri: uri,
617
+ body: body || "",
618
+ params: query_string_params,
619
+ options: options
620
+ )
621
+ operation = ::Gapic::Rest::TransportOperation.new response
622
+ result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
623
+
624
+ yield result, operation if block_given?
625
+ result
626
+ end
627
+
628
+ ##
629
+ # Baseline implementation for the delete_operation REST call
630
+ #
631
+ # @param request_pb [::Google::Longrunning::DeleteOperationRequest]
632
+ # A request object representing the call parameters. Required.
633
+ # @param options [::Gapic::CallOptions]
634
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
635
+ #
636
+ # @yield [result, operation] Access the result along with the TransportOperation object
637
+ # @yieldparam result [::Google::Protobuf::Empty]
638
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
639
+ #
640
+ # @return [::Google::Protobuf::Empty]
641
+ # A result object deserialized from the server's reply
642
+ def delete_operation request_pb, options = nil
643
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
644
+
645
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_delete_operation_request request_pb
646
+ query_string_params = if query_string_params.any?
647
+ query_string_params.to_h { |p| p.split("=", 2) }
648
+ else
649
+ {}
650
+ end
651
+
652
+ response = @client_stub.make_http_request(
653
+ verb,
654
+ uri: uri,
655
+ body: body || "",
656
+ params: query_string_params,
657
+ options: options
658
+ )
659
+ operation = ::Gapic::Rest::TransportOperation.new response
660
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
661
+
662
+ yield result, operation if block_given?
663
+ result
664
+ end
665
+
666
+ ##
667
+ # Baseline implementation for the cancel_operation REST call
668
+ #
669
+ # @param request_pb [::Google::Longrunning::CancelOperationRequest]
670
+ # A request object representing the call parameters. Required.
671
+ # @param options [::Gapic::CallOptions]
672
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
673
+ #
674
+ # @yield [result, operation] Access the result along with the TransportOperation object
675
+ # @yieldparam result [::Google::Protobuf::Empty]
676
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
677
+ #
678
+ # @return [::Google::Protobuf::Empty]
679
+ # A result object deserialized from the server's reply
680
+ def cancel_operation request_pb, options = nil
681
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
682
+
683
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_cancel_operation_request request_pb
684
+ query_string_params = if query_string_params.any?
685
+ query_string_params.to_h { |p| p.split("=", 2) }
686
+ else
687
+ {}
688
+ end
689
+
690
+ response = @client_stub.make_http_request(
691
+ verb,
692
+ uri: uri,
693
+ body: body || "",
694
+ params: query_string_params,
695
+ options: options
696
+ )
697
+ operation = ::Gapic::Rest::TransportOperation.new response
698
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
699
+
700
+ yield result, operation if block_given?
701
+ result
702
+ end
703
+
704
+ ##
705
+ # @private
706
+ #
707
+ # GRPC transcoding helper method for the list_operations REST call
708
+ #
709
+ # @param request_pb [::Google::Longrunning::ListOperationsRequest]
710
+ # A request object representing the call parameters. Required.
711
+ # @return [Array(String, [String, nil], Hash{String => String})]
712
+ # Uri, Body, Query string parameters
713
+ def self.transcode_list_operations_request request_pb
714
+ transcoder = Gapic::Rest::GrpcTranscoder.new
715
+ .with_bindings(
716
+ uri_method: :get,
717
+ uri_template: "/v1beta1/{name}/operations",
718
+ matches: [
719
+ ["name", %r{^projects/[^/]+/locations/[^/]+/?$}, false]
720
+ ]
721
+ )
722
+ transcoder.transcode request_pb
723
+ end
724
+
725
+ ##
726
+ # @private
727
+ #
728
+ # GRPC transcoding helper method for the get_operation REST call
729
+ #
730
+ # @param request_pb [::Google::Longrunning::GetOperationRequest]
731
+ # A request object representing the call parameters. Required.
732
+ # @return [Array(String, [String, nil], Hash{String => String})]
733
+ # Uri, Body, Query string parameters
734
+ def self.transcode_get_operation_request request_pb
735
+ transcoder = Gapic::Rest::GrpcTranscoder.new
736
+ .with_bindings(
737
+ uri_method: :get,
738
+ uri_template: "/v1beta1/{name}",
739
+ matches: [
740
+ ["name", %r{^projects/[^/]+/locations/[^/]+/operations/[^/]+/?$}, false]
741
+ ]
742
+ )
743
+ transcoder.transcode request_pb
744
+ end
745
+
746
+ ##
747
+ # @private
748
+ #
749
+ # GRPC transcoding helper method for the delete_operation REST call
750
+ #
751
+ # @param request_pb [::Google::Longrunning::DeleteOperationRequest]
752
+ # A request object representing the call parameters. Required.
753
+ # @return [Array(String, [String, nil], Hash{String => String})]
754
+ # Uri, Body, Query string parameters
755
+ def self.transcode_delete_operation_request request_pb
756
+ transcoder = Gapic::Rest::GrpcTranscoder.new
757
+ .with_bindings(
758
+ uri_method: :delete,
759
+ uri_template: "/v1beta1/{name}",
760
+ matches: [
761
+ ["name", %r{^projects/[^/]+/locations/[^/]+/operations/[^/]+/?$}, false]
762
+ ]
763
+ )
764
+ transcoder.transcode request_pb
765
+ end
766
+
767
+ ##
768
+ # @private
769
+ #
770
+ # GRPC transcoding helper method for the cancel_operation REST call
771
+ #
772
+ # @param request_pb [::Google::Longrunning::CancelOperationRequest]
773
+ # A request object representing the call parameters. Required.
774
+ # @return [Array(String, [String, nil], Hash{String => String})]
775
+ # Uri, Body, Query string parameters
776
+ def self.transcode_cancel_operation_request request_pb
777
+ transcoder = Gapic::Rest::GrpcTranscoder.new
778
+ .with_bindings(
779
+ uri_method: :post,
780
+ uri_template: "/v1beta1/{name}:cancel",
781
+ body: "*",
782
+ matches: [
783
+ ["name", %r{^projects/[^/]+/locations/[^/]+/operations/[^/]+/?$}, false]
784
+ ]
785
+ )
786
+ transcoder.transcode request_pb
787
+ end
788
+ end
789
+ end
790
+ end
791
+ end
792
+ end
793
+ end
794
+ end
795
+ end