google-cloud-api_keys-v2 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,912 @@
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 "google/cloud/errors"
20
+ require "google/api/apikeys/v2/apikeys_pb"
21
+ require "google/cloud/api_keys/v2/api_keys/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module ApiKeys
26
+ module V2
27
+ module ApiKeys
28
+ module Rest
29
+ ##
30
+ # REST client for the ApiKeys service.
31
+ #
32
+ # Manages the API keys associated with projects.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :api_keys_stub
39
+
40
+ ##
41
+ # Configure the ApiKeys Client class.
42
+ #
43
+ # See {::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # @example
47
+ #
48
+ # # Modify the configuration for all ApiKeys clients
49
+ # ::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
52
+ #
53
+ # @yield [config] Configure the Client client.
54
+ # @yieldparam config [Client::Configuration]
55
+ #
56
+ # @return [Client::Configuration]
57
+ #
58
+ def self.configure
59
+ @configure ||= begin
60
+ namespace = ["Google", "Cloud", "ApiKeys", "V2"]
61
+ parent_config = while namespace.any?
62
+ parent_name = namespace.join "::"
63
+ parent_const = const_get parent_name
64
+ break parent_const.configure if parent_const.respond_to? :configure
65
+ namespace.pop
66
+ end
67
+ default_config = Client::Configuration.new parent_config
68
+
69
+ default_config.timeout = 10.0
70
+
71
+ default_config
72
+ end
73
+ yield @configure if block_given?
74
+ @configure
75
+ end
76
+
77
+ ##
78
+ # Configure the ApiKeys Client instance.
79
+ #
80
+ # The configuration is set to the derived mode, meaning that values can be changed,
81
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
82
+ # should be made on {Client.configure}.
83
+ #
84
+ # See {::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Client::Configuration}
85
+ # for a description of the configuration fields.
86
+ #
87
+ # @yield [config] Configure the Client client.
88
+ # @yieldparam config [Client::Configuration]
89
+ #
90
+ # @return [Client::Configuration]
91
+ #
92
+ def configure
93
+ yield @config if block_given?
94
+ @config
95
+ end
96
+
97
+ ##
98
+ # Create a new ApiKeys REST client object.
99
+ #
100
+ # @example
101
+ #
102
+ # # Create a client using the default configuration
103
+ # client = ::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Client.new
104
+ #
105
+ # # Create a client using a custom configuration
106
+ # client = ::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Client.new do |config|
107
+ # config.timeout = 10.0
108
+ # end
109
+ #
110
+ # @yield [config] Configure the ApiKeys client.
111
+ # @yieldparam config [Client::Configuration]
112
+ #
113
+ def initialize
114
+ # Create the configuration object
115
+ @config = Configuration.new Client.configure
116
+
117
+ # Yield the configuration if needed
118
+ yield @config if block_given?
119
+
120
+ # Create credentials
121
+ credentials = @config.credentials
122
+ # Use self-signed JWT if the endpoint is unchanged from default,
123
+ # but only if the default endpoint does not have a region prefix.
124
+ enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
125
+ !@config.endpoint.split(".").first.include?("-")
126
+ credentials ||= Credentials.default scope: @config.scope,
127
+ enable_self_signed_jwt: enable_self_signed_jwt
128
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
129
+ credentials = Credentials.new credentials, scope: @config.scope
130
+ end
131
+
132
+ @quota_project_id = @config.quota_project
133
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
134
+
135
+ @operations_client = ::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Operations.new do |config|
136
+ config.credentials = credentials
137
+ config.quota_project = @quota_project_id
138
+ config.endpoint = @config.endpoint
139
+ end
140
+
141
+ @api_keys_stub = ::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
142
+ end
143
+
144
+ ##
145
+ # Get the associated client for long-running operations.
146
+ #
147
+ # @return [::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Operations]
148
+ #
149
+ attr_reader :operations_client
150
+
151
+ # Service calls
152
+
153
+ ##
154
+ # Creates a new API key.
155
+ #
156
+ # NOTE: Key is a global resource; hence the only supported value for
157
+ # location is `global`.
158
+ #
159
+ # @overload create_key(request, options = nil)
160
+ # Pass arguments to `create_key` via a request object, either of type
161
+ # {::Google::Cloud::ApiKeys::V2::CreateKeyRequest} or an equivalent Hash.
162
+ #
163
+ # @param request [::Google::Cloud::ApiKeys::V2::CreateKeyRequest, ::Hash]
164
+ # A request object representing the call parameters. Required. To specify no
165
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
166
+ # @param options [::Gapic::CallOptions, ::Hash]
167
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
168
+ #
169
+ # @overload create_key(parent: nil, key: nil, key_id: nil)
170
+ # Pass arguments to `create_key` via keyword arguments. Note that at
171
+ # least one keyword argument is required. To specify no parameters, or to keep all
172
+ # the default parameter values, pass an empty Hash as a request object (see above).
173
+ #
174
+ # @param parent [::String]
175
+ # Required. The project in which the API key is created.
176
+ # @param key [::Google::Cloud::ApiKeys::V2::Key, ::Hash]
177
+ # Required. The API key fields to set at creation time.
178
+ # You can configure only the `display_name`, `restrictions`, and
179
+ # `annotations` fields.
180
+ # @param key_id [::String]
181
+ # User specified key id (optional). If specified, it will become the final
182
+ # component of the key resource name.
183
+ #
184
+ # The id must be unique within the project, must conform with RFC-1034,
185
+ # is restricted to lower-cased letters, and has a maximum length of 63
186
+ # characters. In another word, the id must match the regular
187
+ # expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
188
+ #
189
+ # The id must NOT be a UUID-like string.
190
+ # @yield [result, operation] Access the result along with the TransportOperation object
191
+ # @yieldparam result [::Gapic::Operation]
192
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
193
+ #
194
+ # @return [::Gapic::Operation]
195
+ #
196
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
197
+ def create_key request, options = nil
198
+ raise ::ArgumentError, "request must be provided" if request.nil?
199
+
200
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::CreateKeyRequest
201
+
202
+ # Converts hash and nil to an options object
203
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
204
+
205
+ # Customize the options with defaults
206
+ call_metadata = @config.rpcs.create_key.metadata.to_h
207
+
208
+ # Set x-goog-api-client and x-goog-user-project headers
209
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
210
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
211
+ gapic_version: ::Google::Cloud::ApiKeys::V2::VERSION,
212
+ transports_version_send: [:rest]
213
+
214
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
215
+
216
+ options.apply_defaults timeout: @config.rpcs.create_key.timeout,
217
+ metadata: call_metadata,
218
+ retry_policy: @config.rpcs.create_key.retry_policy
219
+
220
+ options.apply_defaults timeout: @config.timeout,
221
+ metadata: @config.metadata,
222
+ retry_policy: @config.retry_policy
223
+
224
+ @api_keys_stub.create_key request, options do |result, operation|
225
+ result = ::Gapic::Operation.new result, @operations_client, options: options
226
+ yield result, operation if block_given?
227
+ return result
228
+ end
229
+ rescue ::Gapic::Rest::Error => e
230
+ raise ::Google::Cloud::Error.from_error(e)
231
+ end
232
+
233
+ ##
234
+ # Lists the API keys owned by a project. The key string of the API key
235
+ # isn't included in the response.
236
+ #
237
+ # NOTE: Key is a global resource; hence the only supported value for
238
+ # location is `global`.
239
+ #
240
+ # @overload list_keys(request, options = nil)
241
+ # Pass arguments to `list_keys` via a request object, either of type
242
+ # {::Google::Cloud::ApiKeys::V2::ListKeysRequest} or an equivalent Hash.
243
+ #
244
+ # @param request [::Google::Cloud::ApiKeys::V2::ListKeysRequest, ::Hash]
245
+ # A request object representing the call parameters. Required. To specify no
246
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
247
+ # @param options [::Gapic::CallOptions, ::Hash]
248
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
249
+ #
250
+ # @overload list_keys(parent: nil, page_size: nil, page_token: nil, show_deleted: nil)
251
+ # Pass arguments to `list_keys` via keyword arguments. Note that at
252
+ # least one keyword argument is required. To specify no parameters, or to keep all
253
+ # the default parameter values, pass an empty Hash as a request object (see above).
254
+ #
255
+ # @param parent [::String]
256
+ # Required. Lists all API keys associated with this project.
257
+ # @param page_size [::Integer]
258
+ # Optional. Specifies the maximum number of results to be returned at a time.
259
+ # @param page_token [::String]
260
+ # Optional. Requests a specific page of results.
261
+ # @param show_deleted [::Boolean]
262
+ # Optional. Indicate that keys deleted in the past 30 days should also be
263
+ # returned.
264
+ # @yield [result, operation] Access the result along with the TransportOperation object
265
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>]
266
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
267
+ #
268
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>]
269
+ #
270
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
271
+ def list_keys request, options = nil
272
+ raise ::ArgumentError, "request must be provided" if request.nil?
273
+
274
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::ListKeysRequest
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.list_keys.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::ApiKeys::V2::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.list_keys.timeout,
291
+ metadata: call_metadata,
292
+ retry_policy: @config.rpcs.list_keys.retry_policy
293
+
294
+ options.apply_defaults timeout: @config.timeout,
295
+ metadata: @config.metadata,
296
+ retry_policy: @config.retry_policy
297
+
298
+ @api_keys_stub.list_keys request, options do |result, operation|
299
+ result = ::Gapic::Rest::PagedEnumerable.new @api_keys_stub, :list_keys, "keys", request, result, options
300
+ yield result, operation if block_given?
301
+ return result
302
+ end
303
+ rescue ::Gapic::Rest::Error => e
304
+ raise ::Google::Cloud::Error.from_error(e)
305
+ end
306
+
307
+ ##
308
+ # Gets the metadata for an API key. The key string of the API key
309
+ # isn't included in the response.
310
+ #
311
+ # NOTE: Key is a global resource; hence the only supported value for
312
+ # location is `global`.
313
+ #
314
+ # @overload get_key(request, options = nil)
315
+ # Pass arguments to `get_key` via a request object, either of type
316
+ # {::Google::Cloud::ApiKeys::V2::GetKeyRequest} or an equivalent Hash.
317
+ #
318
+ # @param request [::Google::Cloud::ApiKeys::V2::GetKeyRequest, ::Hash]
319
+ # A request object representing the call parameters. Required. To specify no
320
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
321
+ # @param options [::Gapic::CallOptions, ::Hash]
322
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
323
+ #
324
+ # @overload get_key(name: nil)
325
+ # Pass arguments to `get_key` via keyword arguments. Note that at
326
+ # least one keyword argument is required. To specify no parameters, or to keep all
327
+ # the default parameter values, pass an empty Hash as a request object (see above).
328
+ #
329
+ # @param name [::String]
330
+ # Required. The resource name of the API key to get.
331
+ # @yield [result, operation] Access the result along with the TransportOperation object
332
+ # @yieldparam result [::Google::Cloud::ApiKeys::V2::Key]
333
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
334
+ #
335
+ # @return [::Google::Cloud::ApiKeys::V2::Key]
336
+ #
337
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
338
+ def get_key request, options = nil
339
+ raise ::ArgumentError, "request must be provided" if request.nil?
340
+
341
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::GetKeyRequest
342
+
343
+ # Converts hash and nil to an options object
344
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
345
+
346
+ # Customize the options with defaults
347
+ call_metadata = @config.rpcs.get_key.metadata.to_h
348
+
349
+ # Set x-goog-api-client and x-goog-user-project headers
350
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
351
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
352
+ gapic_version: ::Google::Cloud::ApiKeys::V2::VERSION,
353
+ transports_version_send: [:rest]
354
+
355
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
356
+
357
+ options.apply_defaults timeout: @config.rpcs.get_key.timeout,
358
+ metadata: call_metadata,
359
+ retry_policy: @config.rpcs.get_key.retry_policy
360
+
361
+ options.apply_defaults timeout: @config.timeout,
362
+ metadata: @config.metadata,
363
+ retry_policy: @config.retry_policy
364
+
365
+ @api_keys_stub.get_key request, options do |result, operation|
366
+ yield result, operation if block_given?
367
+ return result
368
+ end
369
+ rescue ::Gapic::Rest::Error => e
370
+ raise ::Google::Cloud::Error.from_error(e)
371
+ end
372
+
373
+ ##
374
+ # Get the key string for an API key.
375
+ #
376
+ # NOTE: Key is a global resource; hence the only supported value for
377
+ # location is `global`.
378
+ #
379
+ # @overload get_key_string(request, options = nil)
380
+ # Pass arguments to `get_key_string` via a request object, either of type
381
+ # {::Google::Cloud::ApiKeys::V2::GetKeyStringRequest} or an equivalent Hash.
382
+ #
383
+ # @param request [::Google::Cloud::ApiKeys::V2::GetKeyStringRequest, ::Hash]
384
+ # A request object representing the call parameters. Required. To specify no
385
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
386
+ # @param options [::Gapic::CallOptions, ::Hash]
387
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
388
+ #
389
+ # @overload get_key_string(name: nil)
390
+ # Pass arguments to `get_key_string` via keyword arguments. Note that at
391
+ # least one keyword argument is required. To specify no parameters, or to keep all
392
+ # the default parameter values, pass an empty Hash as a request object (see above).
393
+ #
394
+ # @param name [::String]
395
+ # Required. The resource name of the API key to be retrieved.
396
+ # @yield [result, operation] Access the result along with the TransportOperation object
397
+ # @yieldparam result [::Google::Cloud::ApiKeys::V2::GetKeyStringResponse]
398
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
399
+ #
400
+ # @return [::Google::Cloud::ApiKeys::V2::GetKeyStringResponse]
401
+ #
402
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
403
+ def get_key_string request, options = nil
404
+ raise ::ArgumentError, "request must be provided" if request.nil?
405
+
406
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::GetKeyStringRequest
407
+
408
+ # Converts hash and nil to an options object
409
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
410
+
411
+ # Customize the options with defaults
412
+ call_metadata = @config.rpcs.get_key_string.metadata.to_h
413
+
414
+ # Set x-goog-api-client and x-goog-user-project headers
415
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
416
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
417
+ gapic_version: ::Google::Cloud::ApiKeys::V2::VERSION,
418
+ transports_version_send: [:rest]
419
+
420
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
421
+
422
+ options.apply_defaults timeout: @config.rpcs.get_key_string.timeout,
423
+ metadata: call_metadata,
424
+ retry_policy: @config.rpcs.get_key_string.retry_policy
425
+
426
+ options.apply_defaults timeout: @config.timeout,
427
+ metadata: @config.metadata,
428
+ retry_policy: @config.retry_policy
429
+
430
+ @api_keys_stub.get_key_string request, options do |result, operation|
431
+ yield result, operation if block_given?
432
+ return result
433
+ end
434
+ rescue ::Gapic::Rest::Error => e
435
+ raise ::Google::Cloud::Error.from_error(e)
436
+ end
437
+
438
+ ##
439
+ # Patches the modifiable fields of an API key.
440
+ # The key string of the API key isn't included in the response.
441
+ #
442
+ # NOTE: Key is a global resource; hence the only supported value for
443
+ # location is `global`.
444
+ #
445
+ # @overload update_key(request, options = nil)
446
+ # Pass arguments to `update_key` via a request object, either of type
447
+ # {::Google::Cloud::ApiKeys::V2::UpdateKeyRequest} or an equivalent Hash.
448
+ #
449
+ # @param request [::Google::Cloud::ApiKeys::V2::UpdateKeyRequest, ::Hash]
450
+ # A request object representing the call parameters. Required. To specify no
451
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
452
+ # @param options [::Gapic::CallOptions, ::Hash]
453
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
454
+ #
455
+ # @overload update_key(key: nil, update_mask: nil)
456
+ # Pass arguments to `update_key` via keyword arguments. Note that at
457
+ # least one keyword argument is required. To specify no parameters, or to keep all
458
+ # the default parameter values, pass an empty Hash as a request object (see above).
459
+ #
460
+ # @param key [::Google::Cloud::ApiKeys::V2::Key, ::Hash]
461
+ # Required. Set the `name` field to the resource name of the API key to be
462
+ # updated. You can update only the `display_name`, `restrictions`, and
463
+ # `annotations` fields.
464
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
465
+ # The field mask specifies which fields to be updated as part of this
466
+ # request. All other fields are ignored.
467
+ # Mutable fields are: `display_name`, `restrictions`, and `annotations`.
468
+ # If an update mask is not provided, the service treats it as an implied mask
469
+ # equivalent to all allowed fields that are set on the wire. If the field
470
+ # mask has a special value "*", the service treats it equivalent to replace
471
+ # all allowed mutable fields.
472
+ # @yield [result, operation] Access the result along with the TransportOperation object
473
+ # @yieldparam result [::Gapic::Operation]
474
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
475
+ #
476
+ # @return [::Gapic::Operation]
477
+ #
478
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
479
+ def update_key request, options = nil
480
+ raise ::ArgumentError, "request must be provided" if request.nil?
481
+
482
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::UpdateKeyRequest
483
+
484
+ # Converts hash and nil to an options object
485
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
486
+
487
+ # Customize the options with defaults
488
+ call_metadata = @config.rpcs.update_key.metadata.to_h
489
+
490
+ # Set x-goog-api-client and x-goog-user-project headers
491
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
492
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
493
+ gapic_version: ::Google::Cloud::ApiKeys::V2::VERSION,
494
+ transports_version_send: [:rest]
495
+
496
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
497
+
498
+ options.apply_defaults timeout: @config.rpcs.update_key.timeout,
499
+ metadata: call_metadata,
500
+ retry_policy: @config.rpcs.update_key.retry_policy
501
+
502
+ options.apply_defaults timeout: @config.timeout,
503
+ metadata: @config.metadata,
504
+ retry_policy: @config.retry_policy
505
+
506
+ @api_keys_stub.update_key request, options do |result, operation|
507
+ result = ::Gapic::Operation.new result, @operations_client, options: options
508
+ yield result, operation if block_given?
509
+ return result
510
+ end
511
+ rescue ::Gapic::Rest::Error => e
512
+ raise ::Google::Cloud::Error.from_error(e)
513
+ end
514
+
515
+ ##
516
+ # Deletes an API key. Deleted key can be retrieved within 30 days of
517
+ # deletion. Afterward, key will be purged from the project.
518
+ #
519
+ # NOTE: Key is a global resource; hence the only supported value for
520
+ # location is `global`.
521
+ #
522
+ # @overload delete_key(request, options = nil)
523
+ # Pass arguments to `delete_key` via a request object, either of type
524
+ # {::Google::Cloud::ApiKeys::V2::DeleteKeyRequest} or an equivalent Hash.
525
+ #
526
+ # @param request [::Google::Cloud::ApiKeys::V2::DeleteKeyRequest, ::Hash]
527
+ # A request object representing the call parameters. Required. To specify no
528
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
529
+ # @param options [::Gapic::CallOptions, ::Hash]
530
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
531
+ #
532
+ # @overload delete_key(name: nil, etag: nil)
533
+ # Pass arguments to `delete_key` via keyword arguments. Note that at
534
+ # least one keyword argument is required. To specify no parameters, or to keep all
535
+ # the default parameter values, pass an empty Hash as a request object (see above).
536
+ #
537
+ # @param name [::String]
538
+ # Required. The resource name of the API key to be deleted.
539
+ # @param etag [::String]
540
+ # Optional. The etag known to the client for the expected state of the key.
541
+ # This is to be used for optimistic concurrency.
542
+ # @yield [result, operation] Access the result along with the TransportOperation object
543
+ # @yieldparam result [::Gapic::Operation]
544
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
545
+ #
546
+ # @return [::Gapic::Operation]
547
+ #
548
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
549
+ def delete_key request, options = nil
550
+ raise ::ArgumentError, "request must be provided" if request.nil?
551
+
552
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::DeleteKeyRequest
553
+
554
+ # Converts hash and nil to an options object
555
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
556
+
557
+ # Customize the options with defaults
558
+ call_metadata = @config.rpcs.delete_key.metadata.to_h
559
+
560
+ # Set x-goog-api-client and x-goog-user-project headers
561
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
562
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
563
+ gapic_version: ::Google::Cloud::ApiKeys::V2::VERSION,
564
+ transports_version_send: [:rest]
565
+
566
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
567
+
568
+ options.apply_defaults timeout: @config.rpcs.delete_key.timeout,
569
+ metadata: call_metadata,
570
+ retry_policy: @config.rpcs.delete_key.retry_policy
571
+
572
+ options.apply_defaults timeout: @config.timeout,
573
+ metadata: @config.metadata,
574
+ retry_policy: @config.retry_policy
575
+
576
+ @api_keys_stub.delete_key request, options do |result, operation|
577
+ result = ::Gapic::Operation.new result, @operations_client, options: options
578
+ yield result, operation if block_given?
579
+ return result
580
+ end
581
+ rescue ::Gapic::Rest::Error => e
582
+ raise ::Google::Cloud::Error.from_error(e)
583
+ end
584
+
585
+ ##
586
+ # Undeletes an API key which was deleted within 30 days.
587
+ #
588
+ # NOTE: Key is a global resource; hence the only supported value for
589
+ # location is `global`.
590
+ #
591
+ # @overload undelete_key(request, options = nil)
592
+ # Pass arguments to `undelete_key` via a request object, either of type
593
+ # {::Google::Cloud::ApiKeys::V2::UndeleteKeyRequest} or an equivalent Hash.
594
+ #
595
+ # @param request [::Google::Cloud::ApiKeys::V2::UndeleteKeyRequest, ::Hash]
596
+ # A request object representing the call parameters. Required. To specify no
597
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
598
+ # @param options [::Gapic::CallOptions, ::Hash]
599
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
600
+ #
601
+ # @overload undelete_key(name: nil)
602
+ # Pass arguments to `undelete_key` via keyword arguments. Note that at
603
+ # least one keyword argument is required. To specify no parameters, or to keep all
604
+ # the default parameter values, pass an empty Hash as a request object (see above).
605
+ #
606
+ # @param name [::String]
607
+ # Required. The resource name of the API key to be undeleted.
608
+ # @yield [result, operation] Access the result along with the TransportOperation object
609
+ # @yieldparam result [::Gapic::Operation]
610
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
611
+ #
612
+ # @return [::Gapic::Operation]
613
+ #
614
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
615
+ def undelete_key request, options = nil
616
+ raise ::ArgumentError, "request must be provided" if request.nil?
617
+
618
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::UndeleteKeyRequest
619
+
620
+ # Converts hash and nil to an options object
621
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
622
+
623
+ # Customize the options with defaults
624
+ call_metadata = @config.rpcs.undelete_key.metadata.to_h
625
+
626
+ # Set x-goog-api-client and x-goog-user-project headers
627
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
628
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
629
+ gapic_version: ::Google::Cloud::ApiKeys::V2::VERSION,
630
+ transports_version_send: [:rest]
631
+
632
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
633
+
634
+ options.apply_defaults timeout: @config.rpcs.undelete_key.timeout,
635
+ metadata: call_metadata,
636
+ retry_policy: @config.rpcs.undelete_key.retry_policy
637
+
638
+ options.apply_defaults timeout: @config.timeout,
639
+ metadata: @config.metadata,
640
+ retry_policy: @config.retry_policy
641
+
642
+ @api_keys_stub.undelete_key request, options do |result, operation|
643
+ result = ::Gapic::Operation.new result, @operations_client, options: options
644
+ yield result, operation if block_given?
645
+ return result
646
+ end
647
+ rescue ::Gapic::Rest::Error => e
648
+ raise ::Google::Cloud::Error.from_error(e)
649
+ end
650
+
651
+ ##
652
+ # Find the parent project and resource name of the API
653
+ # key that matches the key string in the request. If the API key has been
654
+ # purged, resource name will not be set.
655
+ # The service account must have the `apikeys.keys.lookup` permission
656
+ # on the parent project.
657
+ #
658
+ # @overload lookup_key(request, options = nil)
659
+ # Pass arguments to `lookup_key` via a request object, either of type
660
+ # {::Google::Cloud::ApiKeys::V2::LookupKeyRequest} or an equivalent Hash.
661
+ #
662
+ # @param request [::Google::Cloud::ApiKeys::V2::LookupKeyRequest, ::Hash]
663
+ # A request object representing the call parameters. Required. To specify no
664
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
665
+ # @param options [::Gapic::CallOptions, ::Hash]
666
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
667
+ #
668
+ # @overload lookup_key(key_string: nil)
669
+ # Pass arguments to `lookup_key` via keyword arguments. Note that at
670
+ # least one keyword argument is required. To specify no parameters, or to keep all
671
+ # the default parameter values, pass an empty Hash as a request object (see above).
672
+ #
673
+ # @param key_string [::String]
674
+ # Required. Finds the project that owns the key string value.
675
+ # @yield [result, operation] Access the result along with the TransportOperation object
676
+ # @yieldparam result [::Google::Cloud::ApiKeys::V2::LookupKeyResponse]
677
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
678
+ #
679
+ # @return [::Google::Cloud::ApiKeys::V2::LookupKeyResponse]
680
+ #
681
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
682
+ def lookup_key request, options = nil
683
+ raise ::ArgumentError, "request must be provided" if request.nil?
684
+
685
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::LookupKeyRequest
686
+
687
+ # Converts hash and nil to an options object
688
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
689
+
690
+ # Customize the options with defaults
691
+ call_metadata = @config.rpcs.lookup_key.metadata.to_h
692
+
693
+ # Set x-goog-api-client and x-goog-user-project headers
694
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
695
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
696
+ gapic_version: ::Google::Cloud::ApiKeys::V2::VERSION,
697
+ transports_version_send: [:rest]
698
+
699
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
700
+
701
+ options.apply_defaults timeout: @config.rpcs.lookup_key.timeout,
702
+ metadata: call_metadata,
703
+ retry_policy: @config.rpcs.lookup_key.retry_policy
704
+
705
+ options.apply_defaults timeout: @config.timeout,
706
+ metadata: @config.metadata,
707
+ retry_policy: @config.retry_policy
708
+
709
+ @api_keys_stub.lookup_key request, options do |result, operation|
710
+ yield result, operation if block_given?
711
+ return result
712
+ end
713
+ rescue ::Gapic::Rest::Error => e
714
+ raise ::Google::Cloud::Error.from_error(e)
715
+ end
716
+
717
+ ##
718
+ # Configuration class for the ApiKeys REST API.
719
+ #
720
+ # This class represents the configuration for ApiKeys REST,
721
+ # providing control over timeouts, retry behavior, logging, transport
722
+ # parameters, and other low-level controls. Certain parameters can also be
723
+ # applied individually to specific RPCs. See
724
+ # {::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Client::Configuration::Rpcs}
725
+ # for a list of RPCs that can be configured independently.
726
+ #
727
+ # Configuration can be applied globally to all clients, or to a single client
728
+ # on construction.
729
+ #
730
+ # @example
731
+ #
732
+ # # Modify the global config, setting the timeout for
733
+ # # create_key to 20 seconds,
734
+ # # and all remaining timeouts to 10 seconds.
735
+ # ::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Client.configure do |config|
736
+ # config.timeout = 10.0
737
+ # config.rpcs.create_key.timeout = 20.0
738
+ # end
739
+ #
740
+ # # Apply the above configuration only to a new client.
741
+ # client = ::Google::Cloud::ApiKeys::V2::ApiKeys::Rest::Client.new do |config|
742
+ # config.timeout = 10.0
743
+ # config.rpcs.create_key.timeout = 20.0
744
+ # end
745
+ #
746
+ # @!attribute [rw] endpoint
747
+ # The hostname or hostname:port of the service endpoint.
748
+ # Defaults to `"apikeys.googleapis.com"`.
749
+ # @return [::String]
750
+ # @!attribute [rw] credentials
751
+ # Credentials to send with calls. You may provide any of the following types:
752
+ # * (`String`) The path to a service account key file in JSON format
753
+ # * (`Hash`) A service account key as a Hash
754
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
755
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
756
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
757
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
758
+ # * (`nil`) indicating no credentials
759
+ # @return [::Object]
760
+ # @!attribute [rw] scope
761
+ # The OAuth scopes
762
+ # @return [::Array<::String>]
763
+ # @!attribute [rw] lib_name
764
+ # The library name as recorded in instrumentation and logging
765
+ # @return [::String]
766
+ # @!attribute [rw] lib_version
767
+ # The library version as recorded in instrumentation and logging
768
+ # @return [::String]
769
+ # @!attribute [rw] timeout
770
+ # The call timeout in seconds.
771
+ # @return [::Numeric]
772
+ # @!attribute [rw] metadata
773
+ # Additional headers to be sent with the call.
774
+ # @return [::Hash{::Symbol=>::String}]
775
+ # @!attribute [rw] retry_policy
776
+ # The retry policy. The value is a hash with the following keys:
777
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
778
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
779
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
780
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
781
+ # trigger a retry.
782
+ # @return [::Hash]
783
+ # @!attribute [rw] quota_project
784
+ # A separate project against which to charge quota.
785
+ # @return [::String]
786
+ #
787
+ class Configuration
788
+ extend ::Gapic::Config
789
+
790
+ DEFAULT_ENDPOINT = "apikeys.googleapis.com"
791
+
792
+ config_attr :endpoint, DEFAULT_ENDPOINT, ::String
793
+ config_attr :credentials, nil do |value|
794
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
795
+ allowed.any? { |klass| klass === value }
796
+ end
797
+ config_attr :scope, nil, ::String, ::Array, nil
798
+ config_attr :lib_name, nil, ::String, nil
799
+ config_attr :lib_version, nil, ::String, nil
800
+ config_attr :timeout, nil, ::Numeric, nil
801
+ config_attr :metadata, nil, ::Hash, nil
802
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
803
+ config_attr :quota_project, nil, ::String, nil
804
+
805
+ # @private
806
+ def initialize parent_config = nil
807
+ @parent_config = parent_config unless parent_config.nil?
808
+
809
+ yield self if block_given?
810
+ end
811
+
812
+ ##
813
+ # Configurations for individual RPCs
814
+ # @return [Rpcs]
815
+ #
816
+ def rpcs
817
+ @rpcs ||= begin
818
+ parent_rpcs = nil
819
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
820
+ Rpcs.new parent_rpcs
821
+ end
822
+ end
823
+
824
+ ##
825
+ # Configuration RPC class for the ApiKeys API.
826
+ #
827
+ # Includes fields providing the configuration for each RPC in this service.
828
+ # Each configuration object is of type `Gapic::Config::Method` and includes
829
+ # the following configuration fields:
830
+ #
831
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
832
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
833
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
834
+ # include the following keys:
835
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
836
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
837
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
838
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
839
+ # trigger a retry.
840
+ #
841
+ class Rpcs
842
+ ##
843
+ # RPC-specific configuration for `create_key`
844
+ # @return [::Gapic::Config::Method]
845
+ #
846
+ attr_reader :create_key
847
+ ##
848
+ # RPC-specific configuration for `list_keys`
849
+ # @return [::Gapic::Config::Method]
850
+ #
851
+ attr_reader :list_keys
852
+ ##
853
+ # RPC-specific configuration for `get_key`
854
+ # @return [::Gapic::Config::Method]
855
+ #
856
+ attr_reader :get_key
857
+ ##
858
+ # RPC-specific configuration for `get_key_string`
859
+ # @return [::Gapic::Config::Method]
860
+ #
861
+ attr_reader :get_key_string
862
+ ##
863
+ # RPC-specific configuration for `update_key`
864
+ # @return [::Gapic::Config::Method]
865
+ #
866
+ attr_reader :update_key
867
+ ##
868
+ # RPC-specific configuration for `delete_key`
869
+ # @return [::Gapic::Config::Method]
870
+ #
871
+ attr_reader :delete_key
872
+ ##
873
+ # RPC-specific configuration for `undelete_key`
874
+ # @return [::Gapic::Config::Method]
875
+ #
876
+ attr_reader :undelete_key
877
+ ##
878
+ # RPC-specific configuration for `lookup_key`
879
+ # @return [::Gapic::Config::Method]
880
+ #
881
+ attr_reader :lookup_key
882
+
883
+ # @private
884
+ def initialize parent_rpcs = nil
885
+ create_key_config = parent_rpcs.create_key if parent_rpcs.respond_to? :create_key
886
+ @create_key = ::Gapic::Config::Method.new create_key_config
887
+ list_keys_config = parent_rpcs.list_keys if parent_rpcs.respond_to? :list_keys
888
+ @list_keys = ::Gapic::Config::Method.new list_keys_config
889
+ get_key_config = parent_rpcs.get_key if parent_rpcs.respond_to? :get_key
890
+ @get_key = ::Gapic::Config::Method.new get_key_config
891
+ get_key_string_config = parent_rpcs.get_key_string if parent_rpcs.respond_to? :get_key_string
892
+ @get_key_string = ::Gapic::Config::Method.new get_key_string_config
893
+ update_key_config = parent_rpcs.update_key if parent_rpcs.respond_to? :update_key
894
+ @update_key = ::Gapic::Config::Method.new update_key_config
895
+ delete_key_config = parent_rpcs.delete_key if parent_rpcs.respond_to? :delete_key
896
+ @delete_key = ::Gapic::Config::Method.new delete_key_config
897
+ undelete_key_config = parent_rpcs.undelete_key if parent_rpcs.respond_to? :undelete_key
898
+ @undelete_key = ::Gapic::Config::Method.new undelete_key_config
899
+ lookup_key_config = parent_rpcs.lookup_key if parent_rpcs.respond_to? :lookup_key
900
+ @lookup_key = ::Gapic::Config::Method.new lookup_key_config
901
+
902
+ yield self if block_given?
903
+ end
904
+ end
905
+ end
906
+ end
907
+ end
908
+ end
909
+ end
910
+ end
911
+ end
912
+ end