google-cloud-os_login-v1beta 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,821 @@
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/cloud/oslogin/v1beta/oslogin_pb"
21
+ require "google/cloud/os_login/v1beta/os_login_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module OsLogin
26
+ module V1beta
27
+ module OsLoginService
28
+ module Rest
29
+ ##
30
+ # REST client for the OsLoginService service.
31
+ #
32
+ # Cloud OS Login API
33
+ #
34
+ # The Cloud OS Login API allows you to manage users and their associated SSH
35
+ # public keys for logging into virtual machines on Google Cloud Platform.
36
+ #
37
+ class Client
38
+ include Paths
39
+
40
+ # @private
41
+ attr_reader :os_login_service_stub
42
+
43
+ ##
44
+ # Configure the OsLoginService Client class.
45
+ #
46
+ # See {::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::Client::Configuration}
47
+ # for a description of the configuration fields.
48
+ #
49
+ # @example
50
+ #
51
+ # # Modify the configuration for all OsLoginService clients
52
+ # ::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::Client.configure do |config|
53
+ # config.timeout = 10.0
54
+ # end
55
+ #
56
+ # @yield [config] Configure the Client client.
57
+ # @yieldparam config [Client::Configuration]
58
+ #
59
+ # @return [Client::Configuration]
60
+ #
61
+ def self.configure
62
+ @configure ||= begin
63
+ namespace = ["Google", "Cloud", "OsLogin", "V1beta"]
64
+ parent_config = while namespace.any?
65
+ parent_name = namespace.join "::"
66
+ parent_const = const_get parent_name
67
+ break parent_const.configure if parent_const.respond_to? :configure
68
+ namespace.pop
69
+ end
70
+ default_config = Client::Configuration.new parent_config
71
+
72
+ default_config.rpcs.delete_posix_account.timeout = 10.0
73
+ default_config.rpcs.delete_posix_account.retry_policy = {
74
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
75
+ }
76
+
77
+ default_config.rpcs.delete_ssh_public_key.timeout = 10.0
78
+ default_config.rpcs.delete_ssh_public_key.retry_policy = {
79
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
80
+ }
81
+
82
+ default_config.rpcs.get_login_profile.timeout = 10.0
83
+ default_config.rpcs.get_login_profile.retry_policy = {
84
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
85
+ }
86
+
87
+ default_config.rpcs.get_ssh_public_key.timeout = 10.0
88
+ default_config.rpcs.get_ssh_public_key.retry_policy = {
89
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
90
+ }
91
+
92
+ default_config.rpcs.import_ssh_public_key.timeout = 10.0
93
+ default_config.rpcs.import_ssh_public_key.retry_policy = {
94
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
95
+ }
96
+
97
+ default_config.rpcs.update_ssh_public_key.timeout = 10.0
98
+ default_config.rpcs.update_ssh_public_key.retry_policy = {
99
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
100
+ }
101
+
102
+ default_config
103
+ end
104
+ yield @configure if block_given?
105
+ @configure
106
+ end
107
+
108
+ ##
109
+ # Configure the OsLoginService Client instance.
110
+ #
111
+ # The configuration is set to the derived mode, meaning that values can be changed,
112
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
113
+ # should be made on {Client.configure}.
114
+ #
115
+ # See {::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::Client::Configuration}
116
+ # for a description of the configuration fields.
117
+ #
118
+ # @yield [config] Configure the Client client.
119
+ # @yieldparam config [Client::Configuration]
120
+ #
121
+ # @return [Client::Configuration]
122
+ #
123
+ def configure
124
+ yield @config if block_given?
125
+ @config
126
+ end
127
+
128
+ ##
129
+ # Create a new OsLoginService REST client object.
130
+ #
131
+ # @example
132
+ #
133
+ # # Create a client using the default configuration
134
+ # client = ::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::Client.new
135
+ #
136
+ # # Create a client using a custom configuration
137
+ # client = ::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::Client.new do |config|
138
+ # config.timeout = 10.0
139
+ # end
140
+ #
141
+ # @yield [config] Configure the OsLoginService client.
142
+ # @yieldparam config [Client::Configuration]
143
+ #
144
+ def initialize
145
+ # Create the configuration object
146
+ @config = Configuration.new Client.configure
147
+
148
+ # Yield the configuration if needed
149
+ yield @config if block_given?
150
+
151
+ # Create credentials
152
+ credentials = @config.credentials
153
+ # Use self-signed JWT if the endpoint is unchanged from default,
154
+ # but only if the default endpoint does not have a region prefix.
155
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
156
+ !@config.endpoint.split(".").first.include?("-")
157
+ credentials ||= Credentials.default scope: @config.scope,
158
+ enable_self_signed_jwt: enable_self_signed_jwt
159
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
160
+ credentials = Credentials.new credentials, scope: @config.scope
161
+ end
162
+
163
+ @quota_project_id = @config.quota_project
164
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
165
+
166
+ @os_login_service_stub = ::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
167
+ end
168
+
169
+ # Service calls
170
+
171
+ ##
172
+ # Create an SSH public key
173
+ #
174
+ # @overload create_ssh_public_key(request, options = nil)
175
+ # Pass arguments to `create_ssh_public_key` via a request object, either of type
176
+ # {::Google::Cloud::OsLogin::V1beta::CreateSshPublicKeyRequest} or an equivalent Hash.
177
+ #
178
+ # @param request [::Google::Cloud::OsLogin::V1beta::CreateSshPublicKeyRequest, ::Hash]
179
+ # A request object representing the call parameters. Required. To specify no
180
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
181
+ # @param options [::Gapic::CallOptions, ::Hash]
182
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
183
+ #
184
+ # @overload create_ssh_public_key(parent: nil, ssh_public_key: nil)
185
+ # Pass arguments to `create_ssh_public_key` via keyword arguments. Note that at
186
+ # least one keyword argument is required. To specify no parameters, or to keep all
187
+ # the default parameter values, pass an empty Hash as a request object (see above).
188
+ #
189
+ # @param parent [::String]
190
+ # Required. The unique ID for the user in format `users/{user}`.
191
+ # @param ssh_public_key [::Google::Cloud::OsLogin::Common::SshPublicKey, ::Hash]
192
+ # Required. The SSH public key and expiration time.
193
+ # @yield [result, operation] Access the result along with the TransportOperation object
194
+ # @yieldparam result [::Google::Cloud::OsLogin::Common::SshPublicKey]
195
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
196
+ #
197
+ # @return [::Google::Cloud::OsLogin::Common::SshPublicKey]
198
+ #
199
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
200
+ def create_ssh_public_key request, options = nil
201
+ raise ::ArgumentError, "request must be provided" if request.nil?
202
+
203
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1beta::CreateSshPublicKeyRequest
204
+
205
+ # Converts hash and nil to an options object
206
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
207
+
208
+ # Customize the options with defaults
209
+ call_metadata = @config.rpcs.create_ssh_public_key.metadata.to_h
210
+
211
+ # Set x-goog-api-client and x-goog-user-project headers
212
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
213
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
214
+ gapic_version: ::Google::Cloud::OsLogin::V1beta::VERSION,
215
+ transports_version_send: [:rest]
216
+
217
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
218
+
219
+ options.apply_defaults timeout: @config.rpcs.create_ssh_public_key.timeout,
220
+ metadata: call_metadata,
221
+ retry_policy: @config.rpcs.create_ssh_public_key.retry_policy
222
+
223
+ options.apply_defaults timeout: @config.timeout,
224
+ metadata: @config.metadata,
225
+ retry_policy: @config.retry_policy
226
+
227
+ @os_login_service_stub.create_ssh_public_key request, options do |result, operation|
228
+ yield result, operation if block_given?
229
+ return result
230
+ end
231
+ rescue ::Gapic::Rest::Error => e
232
+ raise ::Google::Cloud::Error.from_error(e)
233
+ end
234
+
235
+ ##
236
+ # Deletes a POSIX account.
237
+ #
238
+ # @overload delete_posix_account(request, options = nil)
239
+ # Pass arguments to `delete_posix_account` via a request object, either of type
240
+ # {::Google::Cloud::OsLogin::V1beta::DeletePosixAccountRequest} or an equivalent Hash.
241
+ #
242
+ # @param request [::Google::Cloud::OsLogin::V1beta::DeletePosixAccountRequest, ::Hash]
243
+ # A request object representing the call parameters. Required. To specify no
244
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
245
+ # @param options [::Gapic::CallOptions, ::Hash]
246
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
247
+ #
248
+ # @overload delete_posix_account(name: nil)
249
+ # Pass arguments to `delete_posix_account` via keyword arguments. Note that at
250
+ # least one keyword argument is required. To specify no parameters, or to keep all
251
+ # the default parameter values, pass an empty Hash as a request object (see above).
252
+ #
253
+ # @param name [::String]
254
+ # Required. A reference to the POSIX account to update. POSIX accounts are
255
+ # identified by the project ID they are associated with. A reference to the
256
+ # POSIX account is in format `users/{user}/projects/{project}`.
257
+ # @yield [result, operation] Access the result along with the TransportOperation object
258
+ # @yieldparam result [::Google::Protobuf::Empty]
259
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
260
+ #
261
+ # @return [::Google::Protobuf::Empty]
262
+ #
263
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
264
+ def delete_posix_account request, options = nil
265
+ raise ::ArgumentError, "request must be provided" if request.nil?
266
+
267
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1beta::DeletePosixAccountRequest
268
+
269
+ # Converts hash and nil to an options object
270
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
271
+
272
+ # Customize the options with defaults
273
+ call_metadata = @config.rpcs.delete_posix_account.metadata.to_h
274
+
275
+ # Set x-goog-api-client and x-goog-user-project headers
276
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
277
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
278
+ gapic_version: ::Google::Cloud::OsLogin::V1beta::VERSION,
279
+ transports_version_send: [:rest]
280
+
281
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
282
+
283
+ options.apply_defaults timeout: @config.rpcs.delete_posix_account.timeout,
284
+ metadata: call_metadata,
285
+ retry_policy: @config.rpcs.delete_posix_account.retry_policy
286
+
287
+ options.apply_defaults timeout: @config.timeout,
288
+ metadata: @config.metadata,
289
+ retry_policy: @config.retry_policy
290
+
291
+ @os_login_service_stub.delete_posix_account request, options do |result, operation|
292
+ yield result, operation if block_given?
293
+ return result
294
+ end
295
+ rescue ::Gapic::Rest::Error => e
296
+ raise ::Google::Cloud::Error.from_error(e)
297
+ end
298
+
299
+ ##
300
+ # Deletes an SSH public key.
301
+ #
302
+ # @overload delete_ssh_public_key(request, options = nil)
303
+ # Pass arguments to `delete_ssh_public_key` via a request object, either of type
304
+ # {::Google::Cloud::OsLogin::V1beta::DeleteSshPublicKeyRequest} or an equivalent Hash.
305
+ #
306
+ # @param request [::Google::Cloud::OsLogin::V1beta::DeleteSshPublicKeyRequest, ::Hash]
307
+ # A request object representing the call parameters. Required. To specify no
308
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
309
+ # @param options [::Gapic::CallOptions, ::Hash]
310
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
311
+ #
312
+ # @overload delete_ssh_public_key(name: nil)
313
+ # Pass arguments to `delete_ssh_public_key` via keyword arguments. Note that at
314
+ # least one keyword argument is required. To specify no parameters, or to keep all
315
+ # the default parameter values, pass an empty Hash as a request object (see above).
316
+ #
317
+ # @param name [::String]
318
+ # Required. The fingerprint of the public key to update. Public keys are
319
+ # identified by their SHA-256 fingerprint. The fingerprint of the public key
320
+ # is in format `users/{user}/sshPublicKeys/{fingerprint}`.
321
+ # @yield [result, operation] Access the result along with the TransportOperation object
322
+ # @yieldparam result [::Google::Protobuf::Empty]
323
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
324
+ #
325
+ # @return [::Google::Protobuf::Empty]
326
+ #
327
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
328
+ def delete_ssh_public_key request, options = nil
329
+ raise ::ArgumentError, "request must be provided" if request.nil?
330
+
331
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1beta::DeleteSshPublicKeyRequest
332
+
333
+ # Converts hash and nil to an options object
334
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
335
+
336
+ # Customize the options with defaults
337
+ call_metadata = @config.rpcs.delete_ssh_public_key.metadata.to_h
338
+
339
+ # Set x-goog-api-client and x-goog-user-project headers
340
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
341
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
342
+ gapic_version: ::Google::Cloud::OsLogin::V1beta::VERSION,
343
+ transports_version_send: [:rest]
344
+
345
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
346
+
347
+ options.apply_defaults timeout: @config.rpcs.delete_ssh_public_key.timeout,
348
+ metadata: call_metadata,
349
+ retry_policy: @config.rpcs.delete_ssh_public_key.retry_policy
350
+
351
+ options.apply_defaults timeout: @config.timeout,
352
+ metadata: @config.metadata,
353
+ retry_policy: @config.retry_policy
354
+
355
+ @os_login_service_stub.delete_ssh_public_key request, options do |result, operation|
356
+ yield result, operation if block_given?
357
+ return result
358
+ end
359
+ rescue ::Gapic::Rest::Error => e
360
+ raise ::Google::Cloud::Error.from_error(e)
361
+ end
362
+
363
+ ##
364
+ # Retrieves the profile information used for logging in to a virtual machine
365
+ # on Google Compute Engine.
366
+ #
367
+ # @overload get_login_profile(request, options = nil)
368
+ # Pass arguments to `get_login_profile` via a request object, either of type
369
+ # {::Google::Cloud::OsLogin::V1beta::GetLoginProfileRequest} or an equivalent Hash.
370
+ #
371
+ # @param request [::Google::Cloud::OsLogin::V1beta::GetLoginProfileRequest, ::Hash]
372
+ # A request object representing the call parameters. Required. To specify no
373
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
374
+ # @param options [::Gapic::CallOptions, ::Hash]
375
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
376
+ #
377
+ # @overload get_login_profile(name: nil, project_id: nil, system_id: nil, view: nil)
378
+ # Pass arguments to `get_login_profile` via keyword arguments. Note that at
379
+ # least one keyword argument is required. To specify no parameters, or to keep all
380
+ # the default parameter values, pass an empty Hash as a request object (see above).
381
+ #
382
+ # @param name [::String]
383
+ # Required. The unique ID for the user in format `users/{user}`.
384
+ # @param project_id [::String]
385
+ # The project ID of the Google Cloud Platform project.
386
+ # @param system_id [::String]
387
+ # A system ID for filtering the results of the request.
388
+ # @param view [::Google::Cloud::OsLogin::V1beta::LoginProfileView]
389
+ # The view configures whether to retrieve security keys information.
390
+ # @yield [result, operation] Access the result along with the TransportOperation object
391
+ # @yieldparam result [::Google::Cloud::OsLogin::V1beta::LoginProfile]
392
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
393
+ #
394
+ # @return [::Google::Cloud::OsLogin::V1beta::LoginProfile]
395
+ #
396
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
397
+ def get_login_profile request, options = nil
398
+ raise ::ArgumentError, "request must be provided" if request.nil?
399
+
400
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1beta::GetLoginProfileRequest
401
+
402
+ # Converts hash and nil to an options object
403
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
404
+
405
+ # Customize the options with defaults
406
+ call_metadata = @config.rpcs.get_login_profile.metadata.to_h
407
+
408
+ # Set x-goog-api-client and x-goog-user-project headers
409
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
410
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
411
+ gapic_version: ::Google::Cloud::OsLogin::V1beta::VERSION,
412
+ transports_version_send: [:rest]
413
+
414
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
415
+
416
+ options.apply_defaults timeout: @config.rpcs.get_login_profile.timeout,
417
+ metadata: call_metadata,
418
+ retry_policy: @config.rpcs.get_login_profile.retry_policy
419
+
420
+ options.apply_defaults timeout: @config.timeout,
421
+ metadata: @config.metadata,
422
+ retry_policy: @config.retry_policy
423
+
424
+ @os_login_service_stub.get_login_profile request, options do |result, operation|
425
+ yield result, operation if block_given?
426
+ return result
427
+ end
428
+ rescue ::Gapic::Rest::Error => e
429
+ raise ::Google::Cloud::Error.from_error(e)
430
+ end
431
+
432
+ ##
433
+ # Retrieves an SSH public key.
434
+ #
435
+ # @overload get_ssh_public_key(request, options = nil)
436
+ # Pass arguments to `get_ssh_public_key` via a request object, either of type
437
+ # {::Google::Cloud::OsLogin::V1beta::GetSshPublicKeyRequest} or an equivalent Hash.
438
+ #
439
+ # @param request [::Google::Cloud::OsLogin::V1beta::GetSshPublicKeyRequest, ::Hash]
440
+ # A request object representing the call parameters. Required. To specify no
441
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
442
+ # @param options [::Gapic::CallOptions, ::Hash]
443
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
444
+ #
445
+ # @overload get_ssh_public_key(name: nil)
446
+ # Pass arguments to `get_ssh_public_key` via keyword arguments. Note that at
447
+ # least one keyword argument is required. To specify no parameters, or to keep all
448
+ # the default parameter values, pass an empty Hash as a request object (see above).
449
+ #
450
+ # @param name [::String]
451
+ # Required. The fingerprint of the public key to retrieve. Public keys are
452
+ # identified by their SHA-256 fingerprint. The fingerprint of the public key
453
+ # is in format `users/{user}/sshPublicKeys/{fingerprint}`.
454
+ # @yield [result, operation] Access the result along with the TransportOperation object
455
+ # @yieldparam result [::Google::Cloud::OsLogin::Common::SshPublicKey]
456
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
457
+ #
458
+ # @return [::Google::Cloud::OsLogin::Common::SshPublicKey]
459
+ #
460
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
461
+ def get_ssh_public_key request, options = nil
462
+ raise ::ArgumentError, "request must be provided" if request.nil?
463
+
464
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1beta::GetSshPublicKeyRequest
465
+
466
+ # Converts hash and nil to an options object
467
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
468
+
469
+ # Customize the options with defaults
470
+ call_metadata = @config.rpcs.get_ssh_public_key.metadata.to_h
471
+
472
+ # Set x-goog-api-client and x-goog-user-project headers
473
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
474
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
475
+ gapic_version: ::Google::Cloud::OsLogin::V1beta::VERSION,
476
+ transports_version_send: [:rest]
477
+
478
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
479
+
480
+ options.apply_defaults timeout: @config.rpcs.get_ssh_public_key.timeout,
481
+ metadata: call_metadata,
482
+ retry_policy: @config.rpcs.get_ssh_public_key.retry_policy
483
+
484
+ options.apply_defaults timeout: @config.timeout,
485
+ metadata: @config.metadata,
486
+ retry_policy: @config.retry_policy
487
+
488
+ @os_login_service_stub.get_ssh_public_key request, options do |result, operation|
489
+ yield result, operation if block_given?
490
+ return result
491
+ end
492
+ rescue ::Gapic::Rest::Error => e
493
+ raise ::Google::Cloud::Error.from_error(e)
494
+ end
495
+
496
+ ##
497
+ # Adds an SSH public key and returns the profile information. Default POSIX
498
+ # account information is set when no username and UID exist as part of the
499
+ # login profile.
500
+ #
501
+ # @overload import_ssh_public_key(request, options = nil)
502
+ # Pass arguments to `import_ssh_public_key` via a request object, either of type
503
+ # {::Google::Cloud::OsLogin::V1beta::ImportSshPublicKeyRequest} or an equivalent Hash.
504
+ #
505
+ # @param request [::Google::Cloud::OsLogin::V1beta::ImportSshPublicKeyRequest, ::Hash]
506
+ # A request object representing the call parameters. Required. To specify no
507
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
508
+ # @param options [::Gapic::CallOptions, ::Hash]
509
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
510
+ #
511
+ # @overload import_ssh_public_key(parent: nil, ssh_public_key: nil, project_id: nil, view: nil)
512
+ # Pass arguments to `import_ssh_public_key` via keyword arguments. Note that at
513
+ # least one keyword argument is required. To specify no parameters, or to keep all
514
+ # the default parameter values, pass an empty Hash as a request object (see above).
515
+ #
516
+ # @param parent [::String]
517
+ # The unique ID for the user in format `users/{user}`.
518
+ # @param ssh_public_key [::Google::Cloud::OsLogin::Common::SshPublicKey, ::Hash]
519
+ # Required. The SSH public key and expiration time.
520
+ # @param project_id [::String]
521
+ # The project ID of the Google Cloud Platform project.
522
+ # @param view [::Google::Cloud::OsLogin::V1beta::LoginProfileView]
523
+ # The view configures whether to retrieve security keys information.
524
+ # @yield [result, operation] Access the result along with the TransportOperation object
525
+ # @yieldparam result [::Google::Cloud::OsLogin::V1beta::ImportSshPublicKeyResponse]
526
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
527
+ #
528
+ # @return [::Google::Cloud::OsLogin::V1beta::ImportSshPublicKeyResponse]
529
+ #
530
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
531
+ def import_ssh_public_key request, options = nil
532
+ raise ::ArgumentError, "request must be provided" if request.nil?
533
+
534
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1beta::ImportSshPublicKeyRequest
535
+
536
+ # Converts hash and nil to an options object
537
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
538
+
539
+ # Customize the options with defaults
540
+ call_metadata = @config.rpcs.import_ssh_public_key.metadata.to_h
541
+
542
+ # Set x-goog-api-client and x-goog-user-project headers
543
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
544
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
545
+ gapic_version: ::Google::Cloud::OsLogin::V1beta::VERSION,
546
+ transports_version_send: [:rest]
547
+
548
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
549
+
550
+ options.apply_defaults timeout: @config.rpcs.import_ssh_public_key.timeout,
551
+ metadata: call_metadata,
552
+ retry_policy: @config.rpcs.import_ssh_public_key.retry_policy
553
+
554
+ options.apply_defaults timeout: @config.timeout,
555
+ metadata: @config.metadata,
556
+ retry_policy: @config.retry_policy
557
+
558
+ @os_login_service_stub.import_ssh_public_key request, options do |result, operation|
559
+ yield result, operation if block_given?
560
+ return result
561
+ end
562
+ rescue ::Gapic::Rest::Error => e
563
+ raise ::Google::Cloud::Error.from_error(e)
564
+ end
565
+
566
+ ##
567
+ # Updates an SSH public key and returns the profile information. This method
568
+ # supports patch semantics.
569
+ #
570
+ # @overload update_ssh_public_key(request, options = nil)
571
+ # Pass arguments to `update_ssh_public_key` via a request object, either of type
572
+ # {::Google::Cloud::OsLogin::V1beta::UpdateSshPublicKeyRequest} or an equivalent Hash.
573
+ #
574
+ # @param request [::Google::Cloud::OsLogin::V1beta::UpdateSshPublicKeyRequest, ::Hash]
575
+ # A request object representing the call parameters. Required. To specify no
576
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
577
+ # @param options [::Gapic::CallOptions, ::Hash]
578
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
579
+ #
580
+ # @overload update_ssh_public_key(name: nil, ssh_public_key: nil, update_mask: nil)
581
+ # Pass arguments to `update_ssh_public_key` via keyword arguments. Note that at
582
+ # least one keyword argument is required. To specify no parameters, or to keep all
583
+ # the default parameter values, pass an empty Hash as a request object (see above).
584
+ #
585
+ # @param name [::String]
586
+ # Required. The fingerprint of the public key to update. Public keys are
587
+ # identified by their SHA-256 fingerprint. The fingerprint of the public key
588
+ # is in format `users/{user}/sshPublicKeys/{fingerprint}`.
589
+ # @param ssh_public_key [::Google::Cloud::OsLogin::Common::SshPublicKey, ::Hash]
590
+ # Required. The SSH public key and expiration time.
591
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
592
+ # Mask to control which fields get updated. Updates all if not present.
593
+ # @yield [result, operation] Access the result along with the TransportOperation object
594
+ # @yieldparam result [::Google::Cloud::OsLogin::Common::SshPublicKey]
595
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
596
+ #
597
+ # @return [::Google::Cloud::OsLogin::Common::SshPublicKey]
598
+ #
599
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
600
+ def update_ssh_public_key request, options = nil
601
+ raise ::ArgumentError, "request must be provided" if request.nil?
602
+
603
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1beta::UpdateSshPublicKeyRequest
604
+
605
+ # Converts hash and nil to an options object
606
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
607
+
608
+ # Customize the options with defaults
609
+ call_metadata = @config.rpcs.update_ssh_public_key.metadata.to_h
610
+
611
+ # Set x-goog-api-client and x-goog-user-project headers
612
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
613
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
614
+ gapic_version: ::Google::Cloud::OsLogin::V1beta::VERSION,
615
+ transports_version_send: [:rest]
616
+
617
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
618
+
619
+ options.apply_defaults timeout: @config.rpcs.update_ssh_public_key.timeout,
620
+ metadata: call_metadata,
621
+ retry_policy: @config.rpcs.update_ssh_public_key.retry_policy
622
+
623
+ options.apply_defaults timeout: @config.timeout,
624
+ metadata: @config.metadata,
625
+ retry_policy: @config.retry_policy
626
+
627
+ @os_login_service_stub.update_ssh_public_key request, options do |result, operation|
628
+ yield result, operation if block_given?
629
+ return result
630
+ end
631
+ rescue ::Gapic::Rest::Error => e
632
+ raise ::Google::Cloud::Error.from_error(e)
633
+ end
634
+
635
+ ##
636
+ # Configuration class for the OsLoginService REST API.
637
+ #
638
+ # This class represents the configuration for OsLoginService REST,
639
+ # providing control over timeouts, retry behavior, logging, transport
640
+ # parameters, and other low-level controls. Certain parameters can also be
641
+ # applied individually to specific RPCs. See
642
+ # {::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::Client::Configuration::Rpcs}
643
+ # for a list of RPCs that can be configured independently.
644
+ #
645
+ # Configuration can be applied globally to all clients, or to a single client
646
+ # on construction.
647
+ #
648
+ # @example
649
+ #
650
+ # # Modify the global config, setting the timeout for
651
+ # # create_ssh_public_key to 20 seconds,
652
+ # # and all remaining timeouts to 10 seconds.
653
+ # ::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::Client.configure do |config|
654
+ # config.timeout = 10.0
655
+ # config.rpcs.create_ssh_public_key.timeout = 20.0
656
+ # end
657
+ #
658
+ # # Apply the above configuration only to a new client.
659
+ # client = ::Google::Cloud::OsLogin::V1beta::OsLoginService::Rest::Client.new do |config|
660
+ # config.timeout = 10.0
661
+ # config.rpcs.create_ssh_public_key.timeout = 20.0
662
+ # end
663
+ #
664
+ # @!attribute [rw] endpoint
665
+ # The hostname or hostname:port of the service endpoint.
666
+ # Defaults to `"oslogin.googleapis.com"`.
667
+ # @return [::String]
668
+ # @!attribute [rw] credentials
669
+ # Credentials to send with calls. You may provide any of the following types:
670
+ # * (`String`) The path to a service account key file in JSON format
671
+ # * (`Hash`) A service account key as a Hash
672
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
673
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
674
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
675
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
676
+ # * (`nil`) indicating no credentials
677
+ # @return [::Object]
678
+ # @!attribute [rw] scope
679
+ # The OAuth scopes
680
+ # @return [::Array<::String>]
681
+ # @!attribute [rw] lib_name
682
+ # The library name as recorded in instrumentation and logging
683
+ # @return [::String]
684
+ # @!attribute [rw] lib_version
685
+ # The library version as recorded in instrumentation and logging
686
+ # @return [::String]
687
+ # @!attribute [rw] timeout
688
+ # The call timeout in seconds.
689
+ # @return [::Numeric]
690
+ # @!attribute [rw] metadata
691
+ # Additional headers to be sent with the call.
692
+ # @return [::Hash{::Symbol=>::String}]
693
+ # @!attribute [rw] retry_policy
694
+ # The retry policy. The value is a hash with the following keys:
695
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
696
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
697
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
698
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
699
+ # trigger a retry.
700
+ # @return [::Hash]
701
+ # @!attribute [rw] quota_project
702
+ # A separate project against which to charge quota.
703
+ # @return [::String]
704
+ #
705
+ class Configuration
706
+ extend ::Gapic::Config
707
+
708
+ config_attr :endpoint, "oslogin.googleapis.com", ::String
709
+ config_attr :credentials, nil do |value|
710
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
711
+ allowed.any? { |klass| klass === value }
712
+ end
713
+ config_attr :scope, nil, ::String, ::Array, nil
714
+ config_attr :lib_name, nil, ::String, nil
715
+ config_attr :lib_version, nil, ::String, nil
716
+ config_attr :timeout, nil, ::Numeric, nil
717
+ config_attr :metadata, nil, ::Hash, nil
718
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
719
+ config_attr :quota_project, nil, ::String, nil
720
+
721
+ # @private
722
+ def initialize parent_config = nil
723
+ @parent_config = parent_config unless parent_config.nil?
724
+
725
+ yield self if block_given?
726
+ end
727
+
728
+ ##
729
+ # Configurations for individual RPCs
730
+ # @return [Rpcs]
731
+ #
732
+ def rpcs
733
+ @rpcs ||= begin
734
+ parent_rpcs = nil
735
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
736
+ Rpcs.new parent_rpcs
737
+ end
738
+ end
739
+
740
+ ##
741
+ # Configuration RPC class for the OsLoginService API.
742
+ #
743
+ # Includes fields providing the configuration for each RPC in this service.
744
+ # Each configuration object is of type `Gapic::Config::Method` and includes
745
+ # the following configuration fields:
746
+ #
747
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
748
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
749
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
750
+ # include the following keys:
751
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
752
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
753
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
754
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
755
+ # trigger a retry.
756
+ #
757
+ class Rpcs
758
+ ##
759
+ # RPC-specific configuration for `create_ssh_public_key`
760
+ # @return [::Gapic::Config::Method]
761
+ #
762
+ attr_reader :create_ssh_public_key
763
+ ##
764
+ # RPC-specific configuration for `delete_posix_account`
765
+ # @return [::Gapic::Config::Method]
766
+ #
767
+ attr_reader :delete_posix_account
768
+ ##
769
+ # RPC-specific configuration for `delete_ssh_public_key`
770
+ # @return [::Gapic::Config::Method]
771
+ #
772
+ attr_reader :delete_ssh_public_key
773
+ ##
774
+ # RPC-specific configuration for `get_login_profile`
775
+ # @return [::Gapic::Config::Method]
776
+ #
777
+ attr_reader :get_login_profile
778
+ ##
779
+ # RPC-specific configuration for `get_ssh_public_key`
780
+ # @return [::Gapic::Config::Method]
781
+ #
782
+ attr_reader :get_ssh_public_key
783
+ ##
784
+ # RPC-specific configuration for `import_ssh_public_key`
785
+ # @return [::Gapic::Config::Method]
786
+ #
787
+ attr_reader :import_ssh_public_key
788
+ ##
789
+ # RPC-specific configuration for `update_ssh_public_key`
790
+ # @return [::Gapic::Config::Method]
791
+ #
792
+ attr_reader :update_ssh_public_key
793
+
794
+ # @private
795
+ def initialize parent_rpcs = nil
796
+ create_ssh_public_key_config = parent_rpcs.create_ssh_public_key if parent_rpcs.respond_to? :create_ssh_public_key
797
+ @create_ssh_public_key = ::Gapic::Config::Method.new create_ssh_public_key_config
798
+ delete_posix_account_config = parent_rpcs.delete_posix_account if parent_rpcs.respond_to? :delete_posix_account
799
+ @delete_posix_account = ::Gapic::Config::Method.new delete_posix_account_config
800
+ delete_ssh_public_key_config = parent_rpcs.delete_ssh_public_key if parent_rpcs.respond_to? :delete_ssh_public_key
801
+ @delete_ssh_public_key = ::Gapic::Config::Method.new delete_ssh_public_key_config
802
+ get_login_profile_config = parent_rpcs.get_login_profile if parent_rpcs.respond_to? :get_login_profile
803
+ @get_login_profile = ::Gapic::Config::Method.new get_login_profile_config
804
+ get_ssh_public_key_config = parent_rpcs.get_ssh_public_key if parent_rpcs.respond_to? :get_ssh_public_key
805
+ @get_ssh_public_key = ::Gapic::Config::Method.new get_ssh_public_key_config
806
+ import_ssh_public_key_config = parent_rpcs.import_ssh_public_key if parent_rpcs.respond_to? :import_ssh_public_key
807
+ @import_ssh_public_key = ::Gapic::Config::Method.new import_ssh_public_key_config
808
+ update_ssh_public_key_config = parent_rpcs.update_ssh_public_key if parent_rpcs.respond_to? :update_ssh_public_key
809
+ @update_ssh_public_key = ::Gapic::Config::Method.new update_ssh_public_key_config
810
+
811
+ yield self if block_given?
812
+ end
813
+ end
814
+ end
815
+ end
816
+ end
817
+ end
818
+ end
819
+ end
820
+ end
821
+ end