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