google-cloud-os_login-v1 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,817 @@
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/v1/oslogin_pb"
21
+ require "google/cloud/os_login/v1/os_login_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module OsLogin
26
+ module V1
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::V1::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::V1::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", "V1"]
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::V1::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::V1::OsLoginService::Rest::Client.new
135
+ #
136
+ # # Create a client using a custom configuration
137
+ # client = ::Google::Cloud::OsLogin::V1::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::V1::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::V1::CreateSshPublicKeyRequest} or an equivalent Hash.
177
+ #
178
+ # @param request [::Google::Cloud::OsLogin::V1::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::V1::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::V1::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::V1::DeletePosixAccountRequest} or an equivalent Hash.
241
+ #
242
+ # @param request [::Google::Cloud::OsLogin::V1::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::V1::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::V1::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::V1::DeleteSshPublicKeyRequest} or an equivalent Hash.
305
+ #
306
+ # @param request [::Google::Cloud::OsLogin::V1::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::V1::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::V1::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::V1::GetLoginProfileRequest} or an equivalent Hash.
370
+ #
371
+ # @param request [::Google::Cloud::OsLogin::V1::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)
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
+ # @yield [result, operation] Access the result along with the TransportOperation object
389
+ # @yieldparam result [::Google::Cloud::OsLogin::V1::LoginProfile]
390
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
391
+ #
392
+ # @return [::Google::Cloud::OsLogin::V1::LoginProfile]
393
+ #
394
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
395
+ def get_login_profile request, options = nil
396
+ raise ::ArgumentError, "request must be provided" if request.nil?
397
+
398
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1::GetLoginProfileRequest
399
+
400
+ # Converts hash and nil to an options object
401
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
402
+
403
+ # Customize the options with defaults
404
+ call_metadata = @config.rpcs.get_login_profile.metadata.to_h
405
+
406
+ # Set x-goog-api-client and x-goog-user-project headers
407
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
408
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
409
+ gapic_version: ::Google::Cloud::OsLogin::V1::VERSION,
410
+ transports_version_send: [:rest]
411
+
412
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
413
+
414
+ options.apply_defaults timeout: @config.rpcs.get_login_profile.timeout,
415
+ metadata: call_metadata,
416
+ retry_policy: @config.rpcs.get_login_profile.retry_policy
417
+
418
+ options.apply_defaults timeout: @config.timeout,
419
+ metadata: @config.metadata,
420
+ retry_policy: @config.retry_policy
421
+
422
+ @os_login_service_stub.get_login_profile request, options do |result, operation|
423
+ yield result, operation if block_given?
424
+ return result
425
+ end
426
+ rescue ::Gapic::Rest::Error => e
427
+ raise ::Google::Cloud::Error.from_error(e)
428
+ end
429
+
430
+ ##
431
+ # Retrieves an SSH public key.
432
+ #
433
+ # @overload get_ssh_public_key(request, options = nil)
434
+ # Pass arguments to `get_ssh_public_key` via a request object, either of type
435
+ # {::Google::Cloud::OsLogin::V1::GetSshPublicKeyRequest} or an equivalent Hash.
436
+ #
437
+ # @param request [::Google::Cloud::OsLogin::V1::GetSshPublicKeyRequest, ::Hash]
438
+ # A request object representing the call parameters. Required. To specify no
439
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
440
+ # @param options [::Gapic::CallOptions, ::Hash]
441
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
442
+ #
443
+ # @overload get_ssh_public_key(name: nil)
444
+ # Pass arguments to `get_ssh_public_key` via keyword arguments. Note that at
445
+ # least one keyword argument is required. To specify no parameters, or to keep all
446
+ # the default parameter values, pass an empty Hash as a request object (see above).
447
+ #
448
+ # @param name [::String]
449
+ # Required. The fingerprint of the public key to retrieve. Public keys are
450
+ # identified by their SHA-256 fingerprint. The fingerprint of the public key
451
+ # is in format `users/{user}/sshPublicKeys/{fingerprint}`.
452
+ # @yield [result, operation] Access the result along with the TransportOperation object
453
+ # @yieldparam result [::Google::Cloud::OsLogin::Common::SshPublicKey]
454
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
455
+ #
456
+ # @return [::Google::Cloud::OsLogin::Common::SshPublicKey]
457
+ #
458
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
459
+ def get_ssh_public_key request, options = nil
460
+ raise ::ArgumentError, "request must be provided" if request.nil?
461
+
462
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1::GetSshPublicKeyRequest
463
+
464
+ # Converts hash and nil to an options object
465
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
466
+
467
+ # Customize the options with defaults
468
+ call_metadata = @config.rpcs.get_ssh_public_key.metadata.to_h
469
+
470
+ # Set x-goog-api-client and x-goog-user-project headers
471
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
472
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
473
+ gapic_version: ::Google::Cloud::OsLogin::V1::VERSION,
474
+ transports_version_send: [:rest]
475
+
476
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
477
+
478
+ options.apply_defaults timeout: @config.rpcs.get_ssh_public_key.timeout,
479
+ metadata: call_metadata,
480
+ retry_policy: @config.rpcs.get_ssh_public_key.retry_policy
481
+
482
+ options.apply_defaults timeout: @config.timeout,
483
+ metadata: @config.metadata,
484
+ retry_policy: @config.retry_policy
485
+
486
+ @os_login_service_stub.get_ssh_public_key request, options do |result, operation|
487
+ yield result, operation if block_given?
488
+ return result
489
+ end
490
+ rescue ::Gapic::Rest::Error => e
491
+ raise ::Google::Cloud::Error.from_error(e)
492
+ end
493
+
494
+ ##
495
+ # Adds an SSH public key and returns the profile information. Default POSIX
496
+ # account information is set when no username and UID exist as part of the
497
+ # login profile.
498
+ #
499
+ # @overload import_ssh_public_key(request, options = nil)
500
+ # Pass arguments to `import_ssh_public_key` via a request object, either of type
501
+ # {::Google::Cloud::OsLogin::V1::ImportSshPublicKeyRequest} or an equivalent Hash.
502
+ #
503
+ # @param request [::Google::Cloud::OsLogin::V1::ImportSshPublicKeyRequest, ::Hash]
504
+ # A request object representing the call parameters. Required. To specify no
505
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
506
+ # @param options [::Gapic::CallOptions, ::Hash]
507
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
508
+ #
509
+ # @overload import_ssh_public_key(parent: nil, ssh_public_key: nil, project_id: nil)
510
+ # Pass arguments to `import_ssh_public_key` via keyword arguments. Note that at
511
+ # least one keyword argument is required. To specify no parameters, or to keep all
512
+ # the default parameter values, pass an empty Hash as a request object (see above).
513
+ #
514
+ # @param parent [::String]
515
+ # Required. The unique ID for the user in format `users/{user}`.
516
+ # @param ssh_public_key [::Google::Cloud::OsLogin::Common::SshPublicKey, ::Hash]
517
+ # Optional. The SSH public key and expiration time.
518
+ # @param project_id [::String]
519
+ # The project ID of the Google Cloud Platform project.
520
+ # @yield [result, operation] Access the result along with the TransportOperation object
521
+ # @yieldparam result [::Google::Cloud::OsLogin::V1::ImportSshPublicKeyResponse]
522
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
523
+ #
524
+ # @return [::Google::Cloud::OsLogin::V1::ImportSshPublicKeyResponse]
525
+ #
526
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
527
+ def import_ssh_public_key request, options = nil
528
+ raise ::ArgumentError, "request must be provided" if request.nil?
529
+
530
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1::ImportSshPublicKeyRequest
531
+
532
+ # Converts hash and nil to an options object
533
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
534
+
535
+ # Customize the options with defaults
536
+ call_metadata = @config.rpcs.import_ssh_public_key.metadata.to_h
537
+
538
+ # Set x-goog-api-client and x-goog-user-project headers
539
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
540
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
541
+ gapic_version: ::Google::Cloud::OsLogin::V1::VERSION,
542
+ transports_version_send: [:rest]
543
+
544
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
545
+
546
+ options.apply_defaults timeout: @config.rpcs.import_ssh_public_key.timeout,
547
+ metadata: call_metadata,
548
+ retry_policy: @config.rpcs.import_ssh_public_key.retry_policy
549
+
550
+ options.apply_defaults timeout: @config.timeout,
551
+ metadata: @config.metadata,
552
+ retry_policy: @config.retry_policy
553
+
554
+ @os_login_service_stub.import_ssh_public_key request, options do |result, operation|
555
+ yield result, operation if block_given?
556
+ return result
557
+ end
558
+ rescue ::Gapic::Rest::Error => e
559
+ raise ::Google::Cloud::Error.from_error(e)
560
+ end
561
+
562
+ ##
563
+ # Updates an SSH public key and returns the profile information. This method
564
+ # supports patch semantics.
565
+ #
566
+ # @overload update_ssh_public_key(request, options = nil)
567
+ # Pass arguments to `update_ssh_public_key` via a request object, either of type
568
+ # {::Google::Cloud::OsLogin::V1::UpdateSshPublicKeyRequest} or an equivalent Hash.
569
+ #
570
+ # @param request [::Google::Cloud::OsLogin::V1::UpdateSshPublicKeyRequest, ::Hash]
571
+ # A request object representing the call parameters. Required. To specify no
572
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
573
+ # @param options [::Gapic::CallOptions, ::Hash]
574
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
575
+ #
576
+ # @overload update_ssh_public_key(name: nil, ssh_public_key: nil, update_mask: nil)
577
+ # Pass arguments to `update_ssh_public_key` via keyword arguments. Note that at
578
+ # least one keyword argument is required. To specify no parameters, or to keep all
579
+ # the default parameter values, pass an empty Hash as a request object (see above).
580
+ #
581
+ # @param name [::String]
582
+ # Required. The fingerprint of the public key to update. Public keys are
583
+ # identified by their SHA-256 fingerprint. The fingerprint of the public key
584
+ # is in format `users/{user}/sshPublicKeys/{fingerprint}`.
585
+ # @param ssh_public_key [::Google::Cloud::OsLogin::Common::SshPublicKey, ::Hash]
586
+ # Required. The SSH public key and expiration time.
587
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
588
+ # Mask to control which fields get updated. Updates all if not present.
589
+ # @yield [result, operation] Access the result along with the TransportOperation object
590
+ # @yieldparam result [::Google::Cloud::OsLogin::Common::SshPublicKey]
591
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
592
+ #
593
+ # @return [::Google::Cloud::OsLogin::Common::SshPublicKey]
594
+ #
595
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
596
+ def update_ssh_public_key request, options = nil
597
+ raise ::ArgumentError, "request must be provided" if request.nil?
598
+
599
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::OsLogin::V1::UpdateSshPublicKeyRequest
600
+
601
+ # Converts hash and nil to an options object
602
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
603
+
604
+ # Customize the options with defaults
605
+ call_metadata = @config.rpcs.update_ssh_public_key.metadata.to_h
606
+
607
+ # Set x-goog-api-client and x-goog-user-project headers
608
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
609
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
610
+ gapic_version: ::Google::Cloud::OsLogin::V1::VERSION,
611
+ transports_version_send: [:rest]
612
+
613
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
614
+
615
+ options.apply_defaults timeout: @config.rpcs.update_ssh_public_key.timeout,
616
+ metadata: call_metadata,
617
+ retry_policy: @config.rpcs.update_ssh_public_key.retry_policy
618
+
619
+ options.apply_defaults timeout: @config.timeout,
620
+ metadata: @config.metadata,
621
+ retry_policy: @config.retry_policy
622
+
623
+ @os_login_service_stub.update_ssh_public_key request, options do |result, operation|
624
+ yield result, operation if block_given?
625
+ return result
626
+ end
627
+ rescue ::Gapic::Rest::Error => e
628
+ raise ::Google::Cloud::Error.from_error(e)
629
+ end
630
+
631
+ ##
632
+ # Configuration class for the OsLoginService REST API.
633
+ #
634
+ # This class represents the configuration for OsLoginService REST,
635
+ # providing control over timeouts, retry behavior, logging, transport
636
+ # parameters, and other low-level controls. Certain parameters can also be
637
+ # applied individually to specific RPCs. See
638
+ # {::Google::Cloud::OsLogin::V1::OsLoginService::Rest::Client::Configuration::Rpcs}
639
+ # for a list of RPCs that can be configured independently.
640
+ #
641
+ # Configuration can be applied globally to all clients, or to a single client
642
+ # on construction.
643
+ #
644
+ # @example
645
+ #
646
+ # # Modify the global config, setting the timeout for
647
+ # # create_ssh_public_key to 20 seconds,
648
+ # # and all remaining timeouts to 10 seconds.
649
+ # ::Google::Cloud::OsLogin::V1::OsLoginService::Rest::Client.configure do |config|
650
+ # config.timeout = 10.0
651
+ # config.rpcs.create_ssh_public_key.timeout = 20.0
652
+ # end
653
+ #
654
+ # # Apply the above configuration only to a new client.
655
+ # client = ::Google::Cloud::OsLogin::V1::OsLoginService::Rest::Client.new do |config|
656
+ # config.timeout = 10.0
657
+ # config.rpcs.create_ssh_public_key.timeout = 20.0
658
+ # end
659
+ #
660
+ # @!attribute [rw] endpoint
661
+ # The hostname or hostname:port of the service endpoint.
662
+ # Defaults to `"oslogin.googleapis.com"`.
663
+ # @return [::String]
664
+ # @!attribute [rw] credentials
665
+ # Credentials to send with calls. You may provide any of the following types:
666
+ # * (`String`) The path to a service account key file in JSON format
667
+ # * (`Hash`) A service account key as a Hash
668
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
669
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
670
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
671
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
672
+ # * (`nil`) indicating no credentials
673
+ # @return [::Object]
674
+ # @!attribute [rw] scope
675
+ # The OAuth scopes
676
+ # @return [::Array<::String>]
677
+ # @!attribute [rw] lib_name
678
+ # The library name as recorded in instrumentation and logging
679
+ # @return [::String]
680
+ # @!attribute [rw] lib_version
681
+ # The library version as recorded in instrumentation and logging
682
+ # @return [::String]
683
+ # @!attribute [rw] timeout
684
+ # The call timeout in seconds.
685
+ # @return [::Numeric]
686
+ # @!attribute [rw] metadata
687
+ # Additional headers to be sent with the call.
688
+ # @return [::Hash{::Symbol=>::String}]
689
+ # @!attribute [rw] retry_policy
690
+ # The retry policy. The value is a hash with the following keys:
691
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
692
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
693
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
694
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
695
+ # trigger a retry.
696
+ # @return [::Hash]
697
+ # @!attribute [rw] quota_project
698
+ # A separate project against which to charge quota.
699
+ # @return [::String]
700
+ #
701
+ class Configuration
702
+ extend ::Gapic::Config
703
+
704
+ config_attr :endpoint, "oslogin.googleapis.com", ::String
705
+ config_attr :credentials, nil do |value|
706
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
707
+ allowed.any? { |klass| klass === value }
708
+ end
709
+ config_attr :scope, nil, ::String, ::Array, nil
710
+ config_attr :lib_name, nil, ::String, nil
711
+ config_attr :lib_version, nil, ::String, nil
712
+ config_attr :timeout, nil, ::Numeric, nil
713
+ config_attr :metadata, nil, ::Hash, nil
714
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
715
+ config_attr :quota_project, nil, ::String, nil
716
+
717
+ # @private
718
+ def initialize parent_config = nil
719
+ @parent_config = parent_config unless parent_config.nil?
720
+
721
+ yield self if block_given?
722
+ end
723
+
724
+ ##
725
+ # Configurations for individual RPCs
726
+ # @return [Rpcs]
727
+ #
728
+ def rpcs
729
+ @rpcs ||= begin
730
+ parent_rpcs = nil
731
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
732
+ Rpcs.new parent_rpcs
733
+ end
734
+ end
735
+
736
+ ##
737
+ # Configuration RPC class for the OsLoginService API.
738
+ #
739
+ # Includes fields providing the configuration for each RPC in this service.
740
+ # Each configuration object is of type `Gapic::Config::Method` and includes
741
+ # the following configuration fields:
742
+ #
743
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
744
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
745
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
746
+ # include the following keys:
747
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
748
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
749
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
750
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
751
+ # trigger a retry.
752
+ #
753
+ class Rpcs
754
+ ##
755
+ # RPC-specific configuration for `create_ssh_public_key`
756
+ # @return [::Gapic::Config::Method]
757
+ #
758
+ attr_reader :create_ssh_public_key
759
+ ##
760
+ # RPC-specific configuration for `delete_posix_account`
761
+ # @return [::Gapic::Config::Method]
762
+ #
763
+ attr_reader :delete_posix_account
764
+ ##
765
+ # RPC-specific configuration for `delete_ssh_public_key`
766
+ # @return [::Gapic::Config::Method]
767
+ #
768
+ attr_reader :delete_ssh_public_key
769
+ ##
770
+ # RPC-specific configuration for `get_login_profile`
771
+ # @return [::Gapic::Config::Method]
772
+ #
773
+ attr_reader :get_login_profile
774
+ ##
775
+ # RPC-specific configuration for `get_ssh_public_key`
776
+ # @return [::Gapic::Config::Method]
777
+ #
778
+ attr_reader :get_ssh_public_key
779
+ ##
780
+ # RPC-specific configuration for `import_ssh_public_key`
781
+ # @return [::Gapic::Config::Method]
782
+ #
783
+ attr_reader :import_ssh_public_key
784
+ ##
785
+ # RPC-specific configuration for `update_ssh_public_key`
786
+ # @return [::Gapic::Config::Method]
787
+ #
788
+ attr_reader :update_ssh_public_key
789
+
790
+ # @private
791
+ def initialize parent_rpcs = nil
792
+ create_ssh_public_key_config = parent_rpcs.create_ssh_public_key if parent_rpcs.respond_to? :create_ssh_public_key
793
+ @create_ssh_public_key = ::Gapic::Config::Method.new create_ssh_public_key_config
794
+ delete_posix_account_config = parent_rpcs.delete_posix_account if parent_rpcs.respond_to? :delete_posix_account
795
+ @delete_posix_account = ::Gapic::Config::Method.new delete_posix_account_config
796
+ delete_ssh_public_key_config = parent_rpcs.delete_ssh_public_key if parent_rpcs.respond_to? :delete_ssh_public_key
797
+ @delete_ssh_public_key = ::Gapic::Config::Method.new delete_ssh_public_key_config
798
+ get_login_profile_config = parent_rpcs.get_login_profile if parent_rpcs.respond_to? :get_login_profile
799
+ @get_login_profile = ::Gapic::Config::Method.new get_login_profile_config
800
+ get_ssh_public_key_config = parent_rpcs.get_ssh_public_key if parent_rpcs.respond_to? :get_ssh_public_key
801
+ @get_ssh_public_key = ::Gapic::Config::Method.new get_ssh_public_key_config
802
+ import_ssh_public_key_config = parent_rpcs.import_ssh_public_key if parent_rpcs.respond_to? :import_ssh_public_key
803
+ @import_ssh_public_key = ::Gapic::Config::Method.new import_ssh_public_key_config
804
+ update_ssh_public_key_config = parent_rpcs.update_ssh_public_key if parent_rpcs.respond_to? :update_ssh_public_key
805
+ @update_ssh_public_key = ::Gapic::Config::Method.new update_ssh_public_key_config
806
+
807
+ yield self if block_given?
808
+ end
809
+ end
810
+ end
811
+ end
812
+ end
813
+ end
814
+ end
815
+ end
816
+ end
817
+ end