google-cloud-kms-v1 0.25.1 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +4 -4
  3. data/README.md +3 -3
  4. data/lib/google/cloud/kms/v1/autokey/client.rb +713 -0
  5. data/lib/google/cloud/kms/v1/autokey/credentials.rb +52 -0
  6. data/lib/google/cloud/kms/v1/autokey/operations.rb +809 -0
  7. data/lib/google/cloud/kms/v1/autokey/paths.rb +90 -0
  8. data/lib/google/cloud/kms/v1/autokey/rest/client.rb +675 -0
  9. data/lib/google/cloud/kms/v1/autokey/rest/operations.rb +902 -0
  10. data/lib/google/cloud/kms/v1/autokey/rest/service_stub.rb +247 -0
  11. data/lib/google/cloud/kms/v1/autokey/rest.rb +70 -0
  12. data/lib/google/cloud/kms/v1/autokey.rb +72 -0
  13. data/lib/google/cloud/kms/v1/autokey_admin/client.rb +677 -0
  14. data/lib/google/cloud/kms/v1/autokey_admin/credentials.rb +52 -0
  15. data/lib/google/cloud/kms/v1/autokey_admin/paths.rb +61 -0
  16. data/lib/google/cloud/kms/v1/autokey_admin/rest/client.rb +639 -0
  17. data/lib/google/cloud/kms/v1/autokey_admin/rest/service_stub.rb +247 -0
  18. data/lib/google/cloud/kms/v1/autokey_admin/rest.rb +59 -0
  19. data/lib/google/cloud/kms/v1/autokey_admin.rb +61 -0
  20. data/lib/google/cloud/kms/v1/autokey_admin_pb.rb +53 -0
  21. data/lib/google/cloud/kms/v1/autokey_admin_services_pb.rb +62 -0
  22. data/lib/google/cloud/kms/v1/autokey_pb.rb +53 -0
  23. data/lib/google/cloud/kms/v1/autokey_services_pb.rb +71 -0
  24. data/lib/google/cloud/kms/v1/bindings_override.rb +1 -1
  25. data/lib/google/cloud/kms/v1/ekm_service/client.rb +17 -7
  26. data/lib/google/cloud/kms/v1/ekm_service/rest/client.rb +17 -7
  27. data/lib/google/cloud/kms/v1/key_management_service/client.rb +59 -28
  28. data/lib/google/cloud/kms/v1/key_management_service/rest/client.rb +59 -28
  29. data/lib/google/cloud/kms/v1/resources_pb.rb +1 -1
  30. data/lib/google/cloud/kms/v1/rest.rb +3 -1
  31. data/lib/google/cloud/kms/v1/version.rb +1 -1
  32. data/lib/google/cloud/kms/v1.rb +4 -2
  33. data/proto_docs/google/cloud/kms/v1/autokey.rb +123 -0
  34. data/proto_docs/google/cloud/kms/v1/autokey_admin.rb +99 -0
  35. data/proto_docs/google/cloud/kms/v1/resources.rb +3 -0
  36. data/proto_docs/google/longrunning/operations.rb +164 -0
  37. data/proto_docs/google/protobuf/empty.rb +34 -0
  38. data/proto_docs/google/rpc/status.rb +48 -0
  39. metadata +27 -2
@@ -0,0 +1,675 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 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 "google/cloud/errors"
20
+ require "google/cloud/kms/v1/autokey_pb"
21
+ require "google/cloud/kms/v1/autokey/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+ require "google/iam/v1/rest"
24
+
25
+ module Google
26
+ module Cloud
27
+ module Kms
28
+ module V1
29
+ module Autokey
30
+ module Rest
31
+ ##
32
+ # REST client for the Autokey service.
33
+ #
34
+ # Provides interfaces for using Cloud KMS Autokey to provision new
35
+ # {::Google::Cloud::Kms::V1::CryptoKey CryptoKeys}, ready for Customer Managed
36
+ # Encryption Key (CMEK) use, on-demand. To support certain client tooling, this
37
+ # feature is modeled around a {::Google::Cloud::Kms::V1::KeyHandle KeyHandle}
38
+ # resource: creating a {::Google::Cloud::Kms::V1::KeyHandle KeyHandle} in a resource
39
+ # project and given location triggers Cloud KMS Autokey to provision a
40
+ # {::Google::Cloud::Kms::V1::CryptoKey CryptoKey} in the configured key project and
41
+ # the same location.
42
+ #
43
+ # Prior to use in a given resource project,
44
+ # {::Google::Cloud::Kms::V1::AutokeyAdmin::Rest::Client#update_autokey_config UpdateAutokeyConfig}
45
+ # should have been called on an ancestor folder, setting the key project where
46
+ # Cloud KMS Autokey should create new
47
+ # {::Google::Cloud::Kms::V1::CryptoKey CryptoKeys}. See documentation for additional
48
+ # prerequisites. To check what key project, if any, is currently configured on
49
+ # a resource project's ancestor folder, see
50
+ # {::Google::Cloud::Kms::V1::AutokeyAdmin::Rest::Client#show_effective_autokey_config ShowEffectiveAutokeyConfig}.
51
+ #
52
+ class Client
53
+ # @private
54
+ API_VERSION = ""
55
+
56
+ # @private
57
+ DEFAULT_ENDPOINT_TEMPLATE = "cloudkms.$UNIVERSE_DOMAIN$"
58
+
59
+ include Paths
60
+
61
+ # @private
62
+ attr_reader :autokey_stub
63
+
64
+ ##
65
+ # Configure the Autokey Client class.
66
+ #
67
+ # See {::Google::Cloud::Kms::V1::Autokey::Rest::Client::Configuration}
68
+ # for a description of the configuration fields.
69
+ #
70
+ # @example
71
+ #
72
+ # # Modify the configuration for all Autokey clients
73
+ # ::Google::Cloud::Kms::V1::Autokey::Rest::Client.configure do |config|
74
+ # config.timeout = 10.0
75
+ # end
76
+ #
77
+ # @yield [config] Configure the Client client.
78
+ # @yieldparam config [Client::Configuration]
79
+ #
80
+ # @return [Client::Configuration]
81
+ #
82
+ def self.configure
83
+ @configure ||= begin
84
+ namespace = ["Google", "Cloud", "Kms", "V1"]
85
+ parent_config = while namespace.any?
86
+ parent_name = namespace.join "::"
87
+ parent_const = const_get parent_name
88
+ break parent_const.configure if parent_const.respond_to? :configure
89
+ namespace.pop
90
+ end
91
+ default_config = Client::Configuration.new parent_config
92
+
93
+ default_config.rpcs.create_key_handle.timeout = 60.0
94
+
95
+ default_config.rpcs.get_key_handle.timeout = 60.0
96
+ default_config.rpcs.get_key_handle.retry_policy = {
97
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
98
+ }
99
+
100
+ default_config.rpcs.list_key_handles.timeout = 60.0
101
+ default_config.rpcs.list_key_handles.retry_policy = {
102
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
103
+ }
104
+
105
+ default_config
106
+ end
107
+ yield @configure if block_given?
108
+ @configure
109
+ end
110
+
111
+ ##
112
+ # Configure the Autokey Client instance.
113
+ #
114
+ # The configuration is set to the derived mode, meaning that values can be changed,
115
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
116
+ # should be made on {Client.configure}.
117
+ #
118
+ # See {::Google::Cloud::Kms::V1::Autokey::Rest::Client::Configuration}
119
+ # for a description of the configuration fields.
120
+ #
121
+ # @yield [config] Configure the Client client.
122
+ # @yieldparam config [Client::Configuration]
123
+ #
124
+ # @return [Client::Configuration]
125
+ #
126
+ def configure
127
+ yield @config if block_given?
128
+ @config
129
+ end
130
+
131
+ ##
132
+ # The effective universe domain
133
+ #
134
+ # @return [String]
135
+ #
136
+ def universe_domain
137
+ @autokey_stub.universe_domain
138
+ end
139
+
140
+ ##
141
+ # Create a new Autokey REST client object.
142
+ #
143
+ # @example
144
+ #
145
+ # # Create a client using the default configuration
146
+ # client = ::Google::Cloud::Kms::V1::Autokey::Rest::Client.new
147
+ #
148
+ # # Create a client using a custom configuration
149
+ # client = ::Google::Cloud::Kms::V1::Autokey::Rest::Client.new do |config|
150
+ # config.timeout = 10.0
151
+ # end
152
+ #
153
+ # @yield [config] Configure the Autokey client.
154
+ # @yieldparam config [Client::Configuration]
155
+ #
156
+ def initialize
157
+ # Create the configuration object
158
+ @config = Configuration.new Client.configure
159
+
160
+ # Yield the configuration if needed
161
+ yield @config if block_given?
162
+
163
+ # Create credentials
164
+ credentials = @config.credentials
165
+ # Use self-signed JWT if the endpoint is unchanged from default,
166
+ # but only if the default endpoint does not have a region prefix.
167
+ enable_self_signed_jwt = @config.endpoint.nil? ||
168
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
169
+ !@config.endpoint.split(".").first.include?("-"))
170
+ credentials ||= Credentials.default scope: @config.scope,
171
+ enable_self_signed_jwt: enable_self_signed_jwt
172
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
173
+ credentials = Credentials.new credentials, scope: @config.scope
174
+ end
175
+
176
+ @quota_project_id = @config.quota_project
177
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
178
+
179
+ @operations_client = ::Google::Cloud::Kms::V1::Autokey::Rest::Operations.new do |config|
180
+ config.credentials = credentials
181
+ config.quota_project = @quota_project_id
182
+ config.endpoint = @config.endpoint
183
+ config.universe_domain = @config.universe_domain
184
+ end
185
+
186
+ @autokey_stub = ::Google::Cloud::Kms::V1::Autokey::Rest::ServiceStub.new(
187
+ endpoint: @config.endpoint,
188
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
189
+ universe_domain: @config.universe_domain,
190
+ credentials: credentials
191
+ )
192
+
193
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
194
+ config.credentials = credentials
195
+ config.quota_project = @quota_project_id
196
+ config.endpoint = @autokey_stub.endpoint
197
+ config.universe_domain = @autokey_stub.universe_domain
198
+ config.bindings_override = @config.bindings_override
199
+ end
200
+
201
+ @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
202
+ config.credentials = credentials
203
+ config.quota_project = @quota_project_id
204
+ config.endpoint = @autokey_stub.endpoint
205
+ config.universe_domain = @autokey_stub.universe_domain
206
+ config.bindings_override = @config.bindings_override
207
+ end
208
+ end
209
+
210
+ ##
211
+ # Get the associated client for long-running operations.
212
+ #
213
+ # @return [::Google::Cloud::Kms::V1::Autokey::Rest::Operations]
214
+ #
215
+ attr_reader :operations_client
216
+
217
+ ##
218
+ # Get the associated client for mix-in of the Locations.
219
+ #
220
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
221
+ #
222
+ attr_reader :location_client
223
+
224
+ ##
225
+ # Get the associated client for mix-in of the IAMPolicy.
226
+ #
227
+ # @return [Google::Iam::V1::IAMPolicy::Rest::Client]
228
+ #
229
+ attr_reader :iam_policy_client
230
+
231
+ # Service calls
232
+
233
+ ##
234
+ # Creates a new {::Google::Cloud::Kms::V1::KeyHandle KeyHandle}, triggering the
235
+ # provisioning of a new {::Google::Cloud::Kms::V1::CryptoKey CryptoKey} for CMEK
236
+ # use with the given resource type in the configured key project and the same
237
+ # location. [GetOperation][Operations.GetOperation] should be used to resolve
238
+ # the resulting long-running operation and get the resulting
239
+ # {::Google::Cloud::Kms::V1::KeyHandle KeyHandle} and
240
+ # {::Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
241
+ #
242
+ # @overload create_key_handle(request, options = nil)
243
+ # Pass arguments to `create_key_handle` via a request object, either of type
244
+ # {::Google::Cloud::Kms::V1::CreateKeyHandleRequest} or an equivalent Hash.
245
+ #
246
+ # @param request [::Google::Cloud::Kms::V1::CreateKeyHandleRequest, ::Hash]
247
+ # A request object representing the call parameters. Required. To specify no
248
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
249
+ # @param options [::Gapic::CallOptions, ::Hash]
250
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
251
+ #
252
+ # @overload create_key_handle(parent: nil, key_handle_id: nil, key_handle: nil)
253
+ # Pass arguments to `create_key_handle` via keyword arguments. Note that at
254
+ # least one keyword argument is required. To specify no parameters, or to keep all
255
+ # the default parameter values, pass an empty Hash as a request object (see above).
256
+ #
257
+ # @param parent [::String]
258
+ # Required. Name of the resource project and location to create the
259
+ # {::Google::Cloud::Kms::V1::KeyHandle KeyHandle} in, e.g.
260
+ # `projects/{PROJECT_ID}/locations/{LOCATION}`.
261
+ # @param key_handle_id [::String]
262
+ # Optional. Id of the {::Google::Cloud::Kms::V1::KeyHandle KeyHandle}. Must be
263
+ # unique to the resource project and location. If not provided by the caller,
264
+ # a new UUID is used.
265
+ # @param key_handle [::Google::Cloud::Kms::V1::KeyHandle, ::Hash]
266
+ # Required. {::Google::Cloud::Kms::V1::KeyHandle KeyHandle} to create.
267
+ # @yield [result, operation] Access the result along with the TransportOperation object
268
+ # @yieldparam result [::Gapic::Operation]
269
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
270
+ #
271
+ # @return [::Gapic::Operation]
272
+ #
273
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
274
+ #
275
+ # @example Basic example
276
+ # require "google/cloud/kms/v1"
277
+ #
278
+ # # Create a client object. The client can be reused for multiple calls.
279
+ # client = Google::Cloud::Kms::V1::Autokey::Rest::Client.new
280
+ #
281
+ # # Create a request. To set request fields, pass in keyword arguments.
282
+ # request = Google::Cloud::Kms::V1::CreateKeyHandleRequest.new
283
+ #
284
+ # # Call the create_key_handle method.
285
+ # result = client.create_key_handle request
286
+ #
287
+ # # The returned object is of type Gapic::Operation. You can use it to
288
+ # # check the status of an operation, cancel it, or wait for results.
289
+ # # Here is how to wait for a response.
290
+ # result.wait_until_done! timeout: 60
291
+ # if result.response?
292
+ # p result.response
293
+ # else
294
+ # puts "No response received."
295
+ # end
296
+ #
297
+ def create_key_handle request, options = nil
298
+ raise ::ArgumentError, "request must be provided" if request.nil?
299
+
300
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::CreateKeyHandleRequest
301
+
302
+ # Converts hash and nil to an options object
303
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
304
+
305
+ # Customize the options with defaults
306
+ call_metadata = @config.rpcs.create_key_handle.metadata.to_h
307
+
308
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
309
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
310
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
311
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION,
312
+ transports_version_send: [:rest]
313
+
314
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
315
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
316
+
317
+ options.apply_defaults timeout: @config.rpcs.create_key_handle.timeout,
318
+ metadata: call_metadata,
319
+ retry_policy: @config.rpcs.create_key_handle.retry_policy
320
+
321
+ options.apply_defaults timeout: @config.timeout,
322
+ metadata: @config.metadata,
323
+ retry_policy: @config.retry_policy
324
+
325
+ @autokey_stub.create_key_handle request, options do |result, operation|
326
+ result = ::Gapic::Operation.new result, @operations_client, options: options
327
+ yield result, operation if block_given?
328
+ return result
329
+ end
330
+ rescue ::Gapic::Rest::Error => e
331
+ raise ::Google::Cloud::Error.from_error(e)
332
+ end
333
+
334
+ ##
335
+ # Returns the {::Google::Cloud::Kms::V1::KeyHandle KeyHandle}.
336
+ #
337
+ # @overload get_key_handle(request, options = nil)
338
+ # Pass arguments to `get_key_handle` via a request object, either of type
339
+ # {::Google::Cloud::Kms::V1::GetKeyHandleRequest} or an equivalent Hash.
340
+ #
341
+ # @param request [::Google::Cloud::Kms::V1::GetKeyHandleRequest, ::Hash]
342
+ # A request object representing the call parameters. Required. To specify no
343
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
344
+ # @param options [::Gapic::CallOptions, ::Hash]
345
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
346
+ #
347
+ # @overload get_key_handle(name: nil)
348
+ # Pass arguments to `get_key_handle` via keyword arguments. Note that at
349
+ # least one keyword argument is required. To specify no parameters, or to keep all
350
+ # the default parameter values, pass an empty Hash as a request object (see above).
351
+ #
352
+ # @param name [::String]
353
+ # Required. Name of the {::Google::Cloud::Kms::V1::KeyHandle KeyHandle} resource,
354
+ # e.g.
355
+ # `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_ID}`.
356
+ # @yield [result, operation] Access the result along with the TransportOperation object
357
+ # @yieldparam result [::Google::Cloud::Kms::V1::KeyHandle]
358
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
359
+ #
360
+ # @return [::Google::Cloud::Kms::V1::KeyHandle]
361
+ #
362
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
363
+ #
364
+ # @example Basic example
365
+ # require "google/cloud/kms/v1"
366
+ #
367
+ # # Create a client object. The client can be reused for multiple calls.
368
+ # client = Google::Cloud::Kms::V1::Autokey::Rest::Client.new
369
+ #
370
+ # # Create a request. To set request fields, pass in keyword arguments.
371
+ # request = Google::Cloud::Kms::V1::GetKeyHandleRequest.new
372
+ #
373
+ # # Call the get_key_handle method.
374
+ # result = client.get_key_handle request
375
+ #
376
+ # # The returned object is of type Google::Cloud::Kms::V1::KeyHandle.
377
+ # p result
378
+ #
379
+ def get_key_handle request, options = nil
380
+ raise ::ArgumentError, "request must be provided" if request.nil?
381
+
382
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::GetKeyHandleRequest
383
+
384
+ # Converts hash and nil to an options object
385
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
386
+
387
+ # Customize the options with defaults
388
+ call_metadata = @config.rpcs.get_key_handle.metadata.to_h
389
+
390
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
391
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
392
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
393
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION,
394
+ transports_version_send: [:rest]
395
+
396
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
397
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
398
+
399
+ options.apply_defaults timeout: @config.rpcs.get_key_handle.timeout,
400
+ metadata: call_metadata,
401
+ retry_policy: @config.rpcs.get_key_handle.retry_policy
402
+
403
+ options.apply_defaults timeout: @config.timeout,
404
+ metadata: @config.metadata,
405
+ retry_policy: @config.retry_policy
406
+
407
+ @autokey_stub.get_key_handle request, options do |result, operation|
408
+ yield result, operation if block_given?
409
+ return result
410
+ end
411
+ rescue ::Gapic::Rest::Error => e
412
+ raise ::Google::Cloud::Error.from_error(e)
413
+ end
414
+
415
+ ##
416
+ # Lists {::Google::Cloud::Kms::V1::KeyHandle KeyHandles}.
417
+ #
418
+ # @overload list_key_handles(request, options = nil)
419
+ # Pass arguments to `list_key_handles` via a request object, either of type
420
+ # {::Google::Cloud::Kms::V1::ListKeyHandlesRequest} or an equivalent Hash.
421
+ #
422
+ # @param request [::Google::Cloud::Kms::V1::ListKeyHandlesRequest, ::Hash]
423
+ # A request object representing the call parameters. Required. To specify no
424
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
425
+ # @param options [::Gapic::CallOptions, ::Hash]
426
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
427
+ #
428
+ # @overload list_key_handles(parent: nil, filter: nil)
429
+ # Pass arguments to `list_key_handles` via keyword arguments. Note that at
430
+ # least one keyword argument is required. To specify no parameters, or to keep all
431
+ # the default parameter values, pass an empty Hash as a request object (see above).
432
+ #
433
+ # @param parent [::String]
434
+ # Required. Name of the resource project and location from which to list
435
+ # {::Google::Cloud::Kms::V1::KeyHandle KeyHandles}, e.g.
436
+ # `projects/{PROJECT_ID}/locations/{LOCATION}`.
437
+ # @param filter [::String]
438
+ # Optional. Filter to apply when listing
439
+ # {::Google::Cloud::Kms::V1::KeyHandle KeyHandles}, e.g.
440
+ # `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`.
441
+ # @yield [result, operation] Access the result along with the TransportOperation object
442
+ # @yieldparam result [::Google::Cloud::Kms::V1::ListKeyHandlesResponse]
443
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
444
+ #
445
+ # @return [::Google::Cloud::Kms::V1::ListKeyHandlesResponse]
446
+ #
447
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
448
+ #
449
+ # @example Basic example
450
+ # require "google/cloud/kms/v1"
451
+ #
452
+ # # Create a client object. The client can be reused for multiple calls.
453
+ # client = Google::Cloud::Kms::V1::Autokey::Rest::Client.new
454
+ #
455
+ # # Create a request. To set request fields, pass in keyword arguments.
456
+ # request = Google::Cloud::Kms::V1::ListKeyHandlesRequest.new
457
+ #
458
+ # # Call the list_key_handles method.
459
+ # result = client.list_key_handles request
460
+ #
461
+ # # The returned object is of type Google::Cloud::Kms::V1::ListKeyHandlesResponse.
462
+ # p result
463
+ #
464
+ def list_key_handles request, options = nil
465
+ raise ::ArgumentError, "request must be provided" if request.nil?
466
+
467
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::ListKeyHandlesRequest
468
+
469
+ # Converts hash and nil to an options object
470
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
471
+
472
+ # Customize the options with defaults
473
+ call_metadata = @config.rpcs.list_key_handles.metadata.to_h
474
+
475
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
476
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
477
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
478
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION,
479
+ transports_version_send: [:rest]
480
+
481
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
482
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
483
+
484
+ options.apply_defaults timeout: @config.rpcs.list_key_handles.timeout,
485
+ metadata: call_metadata,
486
+ retry_policy: @config.rpcs.list_key_handles.retry_policy
487
+
488
+ options.apply_defaults timeout: @config.timeout,
489
+ metadata: @config.metadata,
490
+ retry_policy: @config.retry_policy
491
+
492
+ @autokey_stub.list_key_handles request, options do |result, operation|
493
+ yield result, operation if block_given?
494
+ return result
495
+ end
496
+ rescue ::Gapic::Rest::Error => e
497
+ raise ::Google::Cloud::Error.from_error(e)
498
+ end
499
+
500
+ ##
501
+ # Configuration class for the Autokey REST API.
502
+ #
503
+ # This class represents the configuration for Autokey REST,
504
+ # providing control over timeouts, retry behavior, logging, transport
505
+ # parameters, and other low-level controls. Certain parameters can also be
506
+ # applied individually to specific RPCs. See
507
+ # {::Google::Cloud::Kms::V1::Autokey::Rest::Client::Configuration::Rpcs}
508
+ # for a list of RPCs that can be configured independently.
509
+ #
510
+ # Configuration can be applied globally to all clients, or to a single client
511
+ # on construction.
512
+ #
513
+ # @example
514
+ #
515
+ # # Modify the global config, setting the timeout for
516
+ # # create_key_handle to 20 seconds,
517
+ # # and all remaining timeouts to 10 seconds.
518
+ # ::Google::Cloud::Kms::V1::Autokey::Rest::Client.configure do |config|
519
+ # config.timeout = 10.0
520
+ # config.rpcs.create_key_handle.timeout = 20.0
521
+ # end
522
+ #
523
+ # # Apply the above configuration only to a new client.
524
+ # client = ::Google::Cloud::Kms::V1::Autokey::Rest::Client.new do |config|
525
+ # config.timeout = 10.0
526
+ # config.rpcs.create_key_handle.timeout = 20.0
527
+ # end
528
+ #
529
+ # @!attribute [rw] endpoint
530
+ # A custom service endpoint, as a hostname or hostname:port. The default is
531
+ # nil, indicating to use the default endpoint in the current universe domain.
532
+ # @return [::String,nil]
533
+ # @!attribute [rw] credentials
534
+ # Credentials to send with calls. You may provide any of the following types:
535
+ # * (`String`) The path to a service account key file in JSON format
536
+ # * (`Hash`) A service account key as a Hash
537
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
538
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
539
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
540
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
541
+ # * (`nil`) indicating no credentials
542
+ # @return [::Object]
543
+ # @!attribute [rw] scope
544
+ # The OAuth scopes
545
+ # @return [::Array<::String>]
546
+ # @!attribute [rw] lib_name
547
+ # The library name as recorded in instrumentation and logging
548
+ # @return [::String]
549
+ # @!attribute [rw] lib_version
550
+ # The library version as recorded in instrumentation and logging
551
+ # @return [::String]
552
+ # @!attribute [rw] timeout
553
+ # The call timeout in seconds.
554
+ # @return [::Numeric]
555
+ # @!attribute [rw] metadata
556
+ # Additional headers to be sent with the call.
557
+ # @return [::Hash{::Symbol=>::String}]
558
+ # @!attribute [rw] retry_policy
559
+ # The retry policy. The value is a hash with the following keys:
560
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
561
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
562
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
563
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
564
+ # trigger a retry.
565
+ # @return [::Hash]
566
+ # @!attribute [rw] quota_project
567
+ # A separate project against which to charge quota.
568
+ # @return [::String]
569
+ # @!attribute [rw] universe_domain
570
+ # The universe domain within which to make requests. This determines the
571
+ # default endpoint URL. The default value of nil uses the environment
572
+ # universe (usually the default "googleapis.com" universe).
573
+ # @return [::String,nil]
574
+ #
575
+ class Configuration
576
+ extend ::Gapic::Config
577
+
578
+ # @private
579
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
580
+ DEFAULT_ENDPOINT = "cloudkms.googleapis.com"
581
+
582
+ config_attr :endpoint, nil, ::String, nil
583
+ config_attr :credentials, nil do |value|
584
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
585
+ allowed.any? { |klass| klass === value }
586
+ end
587
+ config_attr :scope, nil, ::String, ::Array, nil
588
+ config_attr :lib_name, nil, ::String, nil
589
+ config_attr :lib_version, nil, ::String, nil
590
+ config_attr :timeout, nil, ::Numeric, nil
591
+ config_attr :metadata, nil, ::Hash, nil
592
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
593
+ config_attr :quota_project, nil, ::String, nil
594
+ config_attr :universe_domain, nil, ::String, nil
595
+
596
+ # @private
597
+ # Overrides for http bindings for the RPCs of this service
598
+ # are only used when this service is used as mixin, and only
599
+ # by the host service.
600
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
601
+ config_attr :bindings_override, {}, ::Hash, nil
602
+
603
+ # @private
604
+ def initialize parent_config = nil
605
+ @parent_config = parent_config unless parent_config.nil?
606
+
607
+ yield self if block_given?
608
+ end
609
+
610
+ ##
611
+ # Configurations for individual RPCs
612
+ # @return [Rpcs]
613
+ #
614
+ def rpcs
615
+ @rpcs ||= begin
616
+ parent_rpcs = nil
617
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
618
+ Rpcs.new parent_rpcs
619
+ end
620
+ end
621
+
622
+ ##
623
+ # Configuration RPC class for the Autokey API.
624
+ #
625
+ # Includes fields providing the configuration for each RPC in this service.
626
+ # Each configuration object is of type `Gapic::Config::Method` and includes
627
+ # the following configuration fields:
628
+ #
629
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
630
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
631
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
632
+ # include the following keys:
633
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
634
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
635
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
636
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
637
+ # trigger a retry.
638
+ #
639
+ class Rpcs
640
+ ##
641
+ # RPC-specific configuration for `create_key_handle`
642
+ # @return [::Gapic::Config::Method]
643
+ #
644
+ attr_reader :create_key_handle
645
+ ##
646
+ # RPC-specific configuration for `get_key_handle`
647
+ # @return [::Gapic::Config::Method]
648
+ #
649
+ attr_reader :get_key_handle
650
+ ##
651
+ # RPC-specific configuration for `list_key_handles`
652
+ # @return [::Gapic::Config::Method]
653
+ #
654
+ attr_reader :list_key_handles
655
+
656
+ # @private
657
+ def initialize parent_rpcs = nil
658
+ create_key_handle_config = parent_rpcs.create_key_handle if parent_rpcs.respond_to? :create_key_handle
659
+ @create_key_handle = ::Gapic::Config::Method.new create_key_handle_config
660
+ get_key_handle_config = parent_rpcs.get_key_handle if parent_rpcs.respond_to? :get_key_handle
661
+ @get_key_handle = ::Gapic::Config::Method.new get_key_handle_config
662
+ list_key_handles_config = parent_rpcs.list_key_handles if parent_rpcs.respond_to? :list_key_handles
663
+ @list_key_handles = ::Gapic::Config::Method.new list_key_handles_config
664
+
665
+ yield self if block_given?
666
+ end
667
+ end
668
+ end
669
+ end
670
+ end
671
+ end
672
+ end
673
+ end
674
+ end
675
+ end