google-cloud-shell-v1 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,699 @@
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/shell/v1/cloudshell_pb"
21
+ require "google/cloud/shell/v1/cloud_shell_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Shell
26
+ module V1
27
+ module CloudShellService
28
+ module Rest
29
+ ##
30
+ # REST client for the CloudShellService service.
31
+ #
32
+ # API for interacting with Google Cloud Shell. Each user of Cloud Shell has at
33
+ # least one environment, which has the ID "default". Environment consists of a
34
+ # Docker image defining what is installed on the environment and a home
35
+ # directory containing the user's data that will remain across sessions.
36
+ # Clients use this API to start and fetch information about their environment,
37
+ # which can then be used to connect to that environment via a separate SSH
38
+ # client.
39
+ #
40
+ class Client
41
+ include Paths
42
+
43
+ # @private
44
+ attr_reader :cloud_shell_service_stub
45
+
46
+ ##
47
+ # Configure the CloudShellService Client class.
48
+ #
49
+ # See {::Google::Cloud::Shell::V1::CloudShellService::Rest::Client::Configuration}
50
+ # for a description of the configuration fields.
51
+ #
52
+ # @example
53
+ #
54
+ # # Modify the configuration for all CloudShellService clients
55
+ # ::Google::Cloud::Shell::V1::CloudShellService::Rest::Client.configure do |config|
56
+ # config.timeout = 10.0
57
+ # end
58
+ #
59
+ # @yield [config] Configure the Client client.
60
+ # @yieldparam config [Client::Configuration]
61
+ #
62
+ # @return [Client::Configuration]
63
+ #
64
+ def self.configure
65
+ @configure ||= begin
66
+ namespace = ["Google", "Cloud", "Shell", "V1"]
67
+ parent_config = while namespace.any?
68
+ parent_name = namespace.join "::"
69
+ parent_const = const_get parent_name
70
+ break parent_const.configure if parent_const.respond_to? :configure
71
+ namespace.pop
72
+ end
73
+ default_config = Client::Configuration.new parent_config
74
+
75
+ default_config.rpcs.get_environment.timeout = 60.0
76
+ default_config.rpcs.get_environment.retry_policy = {
77
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 2]
78
+ }
79
+
80
+ default_config.rpcs.start_environment.timeout = 60.0
81
+
82
+ default_config.rpcs.authorize_environment.timeout = 60.0
83
+
84
+ default_config.rpcs.add_public_key.timeout = 60.0
85
+
86
+ default_config.rpcs.remove_public_key.timeout = 60.0
87
+
88
+ default_config
89
+ end
90
+ yield @configure if block_given?
91
+ @configure
92
+ end
93
+
94
+ ##
95
+ # Configure the CloudShellService Client instance.
96
+ #
97
+ # The configuration is set to the derived mode, meaning that values can be changed,
98
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
99
+ # should be made on {Client.configure}.
100
+ #
101
+ # See {::Google::Cloud::Shell::V1::CloudShellService::Rest::Client::Configuration}
102
+ # for a description of the configuration fields.
103
+ #
104
+ # @yield [config] Configure the Client client.
105
+ # @yieldparam config [Client::Configuration]
106
+ #
107
+ # @return [Client::Configuration]
108
+ #
109
+ def configure
110
+ yield @config if block_given?
111
+ @config
112
+ end
113
+
114
+ ##
115
+ # Create a new CloudShellService REST client object.
116
+ #
117
+ # @example
118
+ #
119
+ # # Create a client using the default configuration
120
+ # client = ::Google::Cloud::Shell::V1::CloudShellService::Rest::Client.new
121
+ #
122
+ # # Create a client using a custom configuration
123
+ # client = ::Google::Cloud::Shell::V1::CloudShellService::Rest::Client.new do |config|
124
+ # config.timeout = 10.0
125
+ # end
126
+ #
127
+ # @yield [config] Configure the CloudShellService client.
128
+ # @yieldparam config [Client::Configuration]
129
+ #
130
+ def initialize
131
+ # Create the configuration object
132
+ @config = Configuration.new Client.configure
133
+
134
+ # Yield the configuration if needed
135
+ yield @config if block_given?
136
+
137
+ # Create credentials
138
+ credentials = @config.credentials
139
+ # Use self-signed JWT if the endpoint is unchanged from default,
140
+ # but only if the default endpoint does not have a region prefix.
141
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
142
+ !@config.endpoint.split(".").first.include?("-")
143
+ credentials ||= Credentials.default scope: @config.scope,
144
+ enable_self_signed_jwt: enable_self_signed_jwt
145
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
146
+ credentials = Credentials.new credentials, scope: @config.scope
147
+ end
148
+
149
+ @quota_project_id = @config.quota_project
150
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
151
+
152
+ @operations_client = ::Google::Cloud::Shell::V1::CloudShellService::Rest::Operations.new do |config|
153
+ config.credentials = credentials
154
+ config.quota_project = @quota_project_id
155
+ config.endpoint = @config.endpoint
156
+ end
157
+
158
+ @cloud_shell_service_stub = ::Google::Cloud::Shell::V1::CloudShellService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
159
+ end
160
+
161
+ ##
162
+ # Get the associated client for long-running operations.
163
+ #
164
+ # @return [::Google::Cloud::Shell::V1::CloudShellService::Rest::Operations]
165
+ #
166
+ attr_reader :operations_client
167
+
168
+ # Service calls
169
+
170
+ ##
171
+ # Gets an environment. Returns NOT_FOUND if the environment does not exist.
172
+ #
173
+ # @overload get_environment(request, options = nil)
174
+ # Pass arguments to `get_environment` via a request object, either of type
175
+ # {::Google::Cloud::Shell::V1::GetEnvironmentRequest} or an equivalent Hash.
176
+ #
177
+ # @param request [::Google::Cloud::Shell::V1::GetEnvironmentRequest, ::Hash]
178
+ # A request object representing the call parameters. Required. To specify no
179
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
180
+ # @param options [::Gapic::CallOptions, ::Hash]
181
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
182
+ #
183
+ # @overload get_environment(name: nil)
184
+ # Pass arguments to `get_environment` via keyword arguments. Note that at
185
+ # least one keyword argument is required. To specify no parameters, or to keep all
186
+ # the default parameter values, pass an empty Hash as a request object (see above).
187
+ #
188
+ # @param name [::String]
189
+ # Required. Name of the requested resource, for example `users/me/environments/default`
190
+ # or `users/someone@example.com/environments/default`.
191
+ # @yield [result, operation] Access the result along with the TransportOperation object
192
+ # @yieldparam result [::Google::Cloud::Shell::V1::Environment]
193
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
194
+ #
195
+ # @return [::Google::Cloud::Shell::V1::Environment]
196
+ #
197
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
198
+ def get_environment request, options = nil
199
+ raise ::ArgumentError, "request must be provided" if request.nil?
200
+
201
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Shell::V1::GetEnvironmentRequest
202
+
203
+ # Converts hash and nil to an options object
204
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
205
+
206
+ # Customize the options with defaults
207
+ call_metadata = @config.rpcs.get_environment.metadata.to_h
208
+
209
+ # Set x-goog-api-client and x-goog-user-project headers
210
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
211
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
212
+ gapic_version: ::Google::Cloud::Shell::V1::VERSION,
213
+ transports_version_send: [:rest]
214
+
215
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
216
+
217
+ options.apply_defaults timeout: @config.rpcs.get_environment.timeout,
218
+ metadata: call_metadata,
219
+ retry_policy: @config.rpcs.get_environment.retry_policy
220
+
221
+ options.apply_defaults timeout: @config.timeout,
222
+ metadata: @config.metadata,
223
+ retry_policy: @config.retry_policy
224
+
225
+ @cloud_shell_service_stub.get_environment request, options do |result, operation|
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
+ # Starts an existing environment, allowing clients to connect to it. The
235
+ # returned operation will contain an instance of StartEnvironmentMetadata in
236
+ # its metadata field. Users can wait for the environment to start by polling
237
+ # this operation via GetOperation. Once the environment has finished starting
238
+ # and is ready to accept connections, the operation will contain a
239
+ # StartEnvironmentResponse in its response field.
240
+ #
241
+ # @overload start_environment(request, options = nil)
242
+ # Pass arguments to `start_environment` via a request object, either of type
243
+ # {::Google::Cloud::Shell::V1::StartEnvironmentRequest} or an equivalent Hash.
244
+ #
245
+ # @param request [::Google::Cloud::Shell::V1::StartEnvironmentRequest, ::Hash]
246
+ # A request object representing the call parameters. Required. To specify no
247
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
248
+ # @param options [::Gapic::CallOptions, ::Hash]
249
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
250
+ #
251
+ # @overload start_environment(name: nil, access_token: nil, public_keys: nil)
252
+ # Pass arguments to `start_environment` via keyword arguments. Note that at
253
+ # least one keyword argument is required. To specify no parameters, or to keep all
254
+ # the default parameter values, pass an empty Hash as a request object (see above).
255
+ #
256
+ # @param name [::String]
257
+ # Name of the resource that should be started, for example
258
+ # `users/me/environments/default` or
259
+ # `users/someone@example.com/environments/default`.
260
+ # @param access_token [::String]
261
+ # The initial access token passed to the environment. If this is present and
262
+ # valid, the environment will be pre-authenticated with gcloud so that the
263
+ # user can run gcloud commands in Cloud Shell without having to log in. This
264
+ # code can be updated later by calling AuthorizeEnvironment.
265
+ # @param public_keys [::Array<::String>]
266
+ # Public keys that should be added to the environment before it is started.
267
+ # @yield [result, operation] Access the result along with the TransportOperation object
268
+ # @yieldparam result [::Gapic::Operation]
269
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
270
+ #
271
+ # @return [::Gapic::Operation]
272
+ #
273
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
274
+ def start_environment request, options = nil
275
+ raise ::ArgumentError, "request must be provided" if request.nil?
276
+
277
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Shell::V1::StartEnvironmentRequest
278
+
279
+ # Converts hash and nil to an options object
280
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
281
+
282
+ # Customize the options with defaults
283
+ call_metadata = @config.rpcs.start_environment.metadata.to_h
284
+
285
+ # Set x-goog-api-client and x-goog-user-project headers
286
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
287
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
288
+ gapic_version: ::Google::Cloud::Shell::V1::VERSION,
289
+ transports_version_send: [:rest]
290
+
291
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
292
+
293
+ options.apply_defaults timeout: @config.rpcs.start_environment.timeout,
294
+ metadata: call_metadata,
295
+ retry_policy: @config.rpcs.start_environment.retry_policy
296
+
297
+ options.apply_defaults timeout: @config.timeout,
298
+ metadata: @config.metadata,
299
+ retry_policy: @config.retry_policy
300
+
301
+ @cloud_shell_service_stub.start_environment request, options do |result, operation|
302
+ result = ::Gapic::Operation.new result, @operations_client, options: options
303
+ yield result, operation if block_given?
304
+ return result
305
+ end
306
+ rescue ::Gapic::Rest::Error => e
307
+ raise ::Google::Cloud::Error.from_error(e)
308
+ end
309
+
310
+ ##
311
+ # Sends OAuth credentials to a running environment on behalf of a user. When
312
+ # this completes, the environment will be authorized to run various Google
313
+ # Cloud command line tools without requiring the user to manually
314
+ # authenticate.
315
+ #
316
+ # @overload authorize_environment(request, options = nil)
317
+ # Pass arguments to `authorize_environment` via a request object, either of type
318
+ # {::Google::Cloud::Shell::V1::AuthorizeEnvironmentRequest} or an equivalent Hash.
319
+ #
320
+ # @param request [::Google::Cloud::Shell::V1::AuthorizeEnvironmentRequest, ::Hash]
321
+ # A request object representing the call parameters. Required. To specify no
322
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
323
+ # @param options [::Gapic::CallOptions, ::Hash]
324
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
325
+ #
326
+ # @overload authorize_environment(name: nil, access_token: nil, id_token: nil, expire_time: nil)
327
+ # Pass arguments to `authorize_environment` via keyword arguments. Note that at
328
+ # least one keyword argument is required. To specify no parameters, or to keep all
329
+ # the default parameter values, pass an empty Hash as a request object (see above).
330
+ #
331
+ # @param name [::String]
332
+ # Name of the resource that should receive the credentials, for example
333
+ # `users/me/environments/default` or
334
+ # `users/someone@example.com/environments/default`.
335
+ # @param access_token [::String]
336
+ # The OAuth access token that should be sent to the environment.
337
+ # @param id_token [::String]
338
+ # The OAuth ID token that should be sent to the environment.
339
+ # @param expire_time [::Google::Protobuf::Timestamp, ::Hash]
340
+ # The time when the credentials expire. If not set, defaults to one hour from
341
+ # when the server received the request.
342
+ # @yield [result, operation] Access the result along with the TransportOperation object
343
+ # @yieldparam result [::Gapic::Operation]
344
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
345
+ #
346
+ # @return [::Gapic::Operation]
347
+ #
348
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
349
+ def authorize_environment request, options = nil
350
+ raise ::ArgumentError, "request must be provided" if request.nil?
351
+
352
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Shell::V1::AuthorizeEnvironmentRequest
353
+
354
+ # Converts hash and nil to an options object
355
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
356
+
357
+ # Customize the options with defaults
358
+ call_metadata = @config.rpcs.authorize_environment.metadata.to_h
359
+
360
+ # Set x-goog-api-client and x-goog-user-project headers
361
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
362
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
363
+ gapic_version: ::Google::Cloud::Shell::V1::VERSION,
364
+ transports_version_send: [:rest]
365
+
366
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
367
+
368
+ options.apply_defaults timeout: @config.rpcs.authorize_environment.timeout,
369
+ metadata: call_metadata,
370
+ retry_policy: @config.rpcs.authorize_environment.retry_policy
371
+
372
+ options.apply_defaults timeout: @config.timeout,
373
+ metadata: @config.metadata,
374
+ retry_policy: @config.retry_policy
375
+
376
+ @cloud_shell_service_stub.authorize_environment request, options do |result, operation|
377
+ result = ::Gapic::Operation.new result, @operations_client, options: options
378
+ yield result, operation if block_given?
379
+ return result
380
+ end
381
+ rescue ::Gapic::Rest::Error => e
382
+ raise ::Google::Cloud::Error.from_error(e)
383
+ end
384
+
385
+ ##
386
+ # Adds a public SSH key to an environment, allowing clients with the
387
+ # corresponding private key to connect to that environment via SSH. If a key
388
+ # with the same content already exists, this will error with ALREADY_EXISTS.
389
+ #
390
+ # @overload add_public_key(request, options = nil)
391
+ # Pass arguments to `add_public_key` via a request object, either of type
392
+ # {::Google::Cloud::Shell::V1::AddPublicKeyRequest} or an equivalent Hash.
393
+ #
394
+ # @param request [::Google::Cloud::Shell::V1::AddPublicKeyRequest, ::Hash]
395
+ # A request object representing the call parameters. Required. To specify no
396
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
397
+ # @param options [::Gapic::CallOptions, ::Hash]
398
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
399
+ #
400
+ # @overload add_public_key(environment: nil, key: nil)
401
+ # Pass arguments to `add_public_key` via keyword arguments. Note that at
402
+ # least one keyword argument is required. To specify no parameters, or to keep all
403
+ # the default parameter values, pass an empty Hash as a request object (see above).
404
+ #
405
+ # @param environment [::String]
406
+ # Environment this key should be added to, e.g.
407
+ # `users/me/environments/default`.
408
+ # @param key [::String]
409
+ # Key that should be added to the environment. Supported formats are
410
+ # `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256`
411
+ # (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and
412
+ # `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as
413
+ # &lt;format&gt; &lt;content&gt;, where &lt;content&gt; part is encoded with
414
+ # Base64.
415
+ # @yield [result, operation] Access the result along with the TransportOperation object
416
+ # @yieldparam result [::Gapic::Operation]
417
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
418
+ #
419
+ # @return [::Gapic::Operation]
420
+ #
421
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
422
+ def add_public_key request, options = nil
423
+ raise ::ArgumentError, "request must be provided" if request.nil?
424
+
425
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Shell::V1::AddPublicKeyRequest
426
+
427
+ # Converts hash and nil to an options object
428
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
429
+
430
+ # Customize the options with defaults
431
+ call_metadata = @config.rpcs.add_public_key.metadata.to_h
432
+
433
+ # Set x-goog-api-client and x-goog-user-project headers
434
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
435
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
436
+ gapic_version: ::Google::Cloud::Shell::V1::VERSION,
437
+ transports_version_send: [:rest]
438
+
439
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
440
+
441
+ options.apply_defaults timeout: @config.rpcs.add_public_key.timeout,
442
+ metadata: call_metadata,
443
+ retry_policy: @config.rpcs.add_public_key.retry_policy
444
+
445
+ options.apply_defaults timeout: @config.timeout,
446
+ metadata: @config.metadata,
447
+ retry_policy: @config.retry_policy
448
+
449
+ @cloud_shell_service_stub.add_public_key request, options do |result, operation|
450
+ result = ::Gapic::Operation.new result, @operations_client, options: options
451
+ yield result, operation if block_given?
452
+ return result
453
+ end
454
+ rescue ::Gapic::Rest::Error => e
455
+ raise ::Google::Cloud::Error.from_error(e)
456
+ end
457
+
458
+ ##
459
+ # Removes a public SSH key from an environment. Clients will no longer be
460
+ # able to connect to the environment using the corresponding private key.
461
+ # If a key with the same content is not present, this will error with
462
+ # NOT_FOUND.
463
+ #
464
+ # @overload remove_public_key(request, options = nil)
465
+ # Pass arguments to `remove_public_key` via a request object, either of type
466
+ # {::Google::Cloud::Shell::V1::RemovePublicKeyRequest} or an equivalent Hash.
467
+ #
468
+ # @param request [::Google::Cloud::Shell::V1::RemovePublicKeyRequest, ::Hash]
469
+ # A request object representing the call parameters. Required. To specify no
470
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
471
+ # @param options [::Gapic::CallOptions, ::Hash]
472
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
473
+ #
474
+ # @overload remove_public_key(environment: nil, key: nil)
475
+ # Pass arguments to `remove_public_key` via keyword arguments. Note that at
476
+ # least one keyword argument is required. To specify no parameters, or to keep all
477
+ # the default parameter values, pass an empty Hash as a request object (see above).
478
+ #
479
+ # @param environment [::String]
480
+ # Environment this key should be removed from, e.g.
481
+ # `users/me/environments/default`.
482
+ # @param key [::String]
483
+ # Key that should be removed from the environment.
484
+ # @yield [result, operation] Access the result along with the TransportOperation object
485
+ # @yieldparam result [::Gapic::Operation]
486
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
487
+ #
488
+ # @return [::Gapic::Operation]
489
+ #
490
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
491
+ def remove_public_key request, options = nil
492
+ raise ::ArgumentError, "request must be provided" if request.nil?
493
+
494
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Shell::V1::RemovePublicKeyRequest
495
+
496
+ # Converts hash and nil to an options object
497
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
498
+
499
+ # Customize the options with defaults
500
+ call_metadata = @config.rpcs.remove_public_key.metadata.to_h
501
+
502
+ # Set x-goog-api-client and x-goog-user-project headers
503
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
504
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
505
+ gapic_version: ::Google::Cloud::Shell::V1::VERSION,
506
+ transports_version_send: [:rest]
507
+
508
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
509
+
510
+ options.apply_defaults timeout: @config.rpcs.remove_public_key.timeout,
511
+ metadata: call_metadata,
512
+ retry_policy: @config.rpcs.remove_public_key.retry_policy
513
+
514
+ options.apply_defaults timeout: @config.timeout,
515
+ metadata: @config.metadata,
516
+ retry_policy: @config.retry_policy
517
+
518
+ @cloud_shell_service_stub.remove_public_key request, options do |result, operation|
519
+ result = ::Gapic::Operation.new result, @operations_client, options: options
520
+ yield result, operation if block_given?
521
+ return result
522
+ end
523
+ rescue ::Gapic::Rest::Error => e
524
+ raise ::Google::Cloud::Error.from_error(e)
525
+ end
526
+
527
+ ##
528
+ # Configuration class for the CloudShellService REST API.
529
+ #
530
+ # This class represents the configuration for CloudShellService REST,
531
+ # providing control over timeouts, retry behavior, logging, transport
532
+ # parameters, and other low-level controls. Certain parameters can also be
533
+ # applied individually to specific RPCs. See
534
+ # {::Google::Cloud::Shell::V1::CloudShellService::Rest::Client::Configuration::Rpcs}
535
+ # for a list of RPCs that can be configured independently.
536
+ #
537
+ # Configuration can be applied globally to all clients, or to a single client
538
+ # on construction.
539
+ #
540
+ # @example
541
+ #
542
+ # # Modify the global config, setting the timeout for
543
+ # # get_environment to 20 seconds,
544
+ # # and all remaining timeouts to 10 seconds.
545
+ # ::Google::Cloud::Shell::V1::CloudShellService::Rest::Client.configure do |config|
546
+ # config.timeout = 10.0
547
+ # config.rpcs.get_environment.timeout = 20.0
548
+ # end
549
+ #
550
+ # # Apply the above configuration only to a new client.
551
+ # client = ::Google::Cloud::Shell::V1::CloudShellService::Rest::Client.new do |config|
552
+ # config.timeout = 10.0
553
+ # config.rpcs.get_environment.timeout = 20.0
554
+ # end
555
+ #
556
+ # @!attribute [rw] endpoint
557
+ # The hostname or hostname:port of the service endpoint.
558
+ # Defaults to `"cloudshell.googleapis.com"`.
559
+ # @return [::String]
560
+ # @!attribute [rw] credentials
561
+ # Credentials to send with calls. You may provide any of the following types:
562
+ # * (`String`) The path to a service account key file in JSON format
563
+ # * (`Hash`) A service account key as a Hash
564
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
565
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
566
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
567
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
568
+ # * (`nil`) indicating no credentials
569
+ # @return [::Object]
570
+ # @!attribute [rw] scope
571
+ # The OAuth scopes
572
+ # @return [::Array<::String>]
573
+ # @!attribute [rw] lib_name
574
+ # The library name as recorded in instrumentation and logging
575
+ # @return [::String]
576
+ # @!attribute [rw] lib_version
577
+ # The library version as recorded in instrumentation and logging
578
+ # @return [::String]
579
+ # @!attribute [rw] timeout
580
+ # The call timeout in seconds.
581
+ # @return [::Numeric]
582
+ # @!attribute [rw] metadata
583
+ # Additional headers to be sent with the call.
584
+ # @return [::Hash{::Symbol=>::String}]
585
+ # @!attribute [rw] retry_policy
586
+ # The retry policy. The value is a hash with the following keys:
587
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
588
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
589
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
590
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
591
+ # trigger a retry.
592
+ # @return [::Hash]
593
+ # @!attribute [rw] quota_project
594
+ # A separate project against which to charge quota.
595
+ # @return [::String]
596
+ #
597
+ class Configuration
598
+ extend ::Gapic::Config
599
+
600
+ config_attr :endpoint, "cloudshell.googleapis.com", ::String
601
+ config_attr :credentials, nil do |value|
602
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
603
+ allowed.any? { |klass| klass === value }
604
+ end
605
+ config_attr :scope, nil, ::String, ::Array, nil
606
+ config_attr :lib_name, nil, ::String, nil
607
+ config_attr :lib_version, nil, ::String, nil
608
+ config_attr :timeout, nil, ::Numeric, nil
609
+ config_attr :metadata, nil, ::Hash, nil
610
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
611
+ config_attr :quota_project, nil, ::String, nil
612
+
613
+ # @private
614
+ def initialize parent_config = nil
615
+ @parent_config = parent_config unless parent_config.nil?
616
+
617
+ yield self if block_given?
618
+ end
619
+
620
+ ##
621
+ # Configurations for individual RPCs
622
+ # @return [Rpcs]
623
+ #
624
+ def rpcs
625
+ @rpcs ||= begin
626
+ parent_rpcs = nil
627
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
628
+ Rpcs.new parent_rpcs
629
+ end
630
+ end
631
+
632
+ ##
633
+ # Configuration RPC class for the CloudShellService API.
634
+ #
635
+ # Includes fields providing the configuration for each RPC in this service.
636
+ # Each configuration object is of type `Gapic::Config::Method` and includes
637
+ # the following configuration fields:
638
+ #
639
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
640
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
641
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
642
+ # include the following keys:
643
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
644
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
645
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
646
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
647
+ # trigger a retry.
648
+ #
649
+ class Rpcs
650
+ ##
651
+ # RPC-specific configuration for `get_environment`
652
+ # @return [::Gapic::Config::Method]
653
+ #
654
+ attr_reader :get_environment
655
+ ##
656
+ # RPC-specific configuration for `start_environment`
657
+ # @return [::Gapic::Config::Method]
658
+ #
659
+ attr_reader :start_environment
660
+ ##
661
+ # RPC-specific configuration for `authorize_environment`
662
+ # @return [::Gapic::Config::Method]
663
+ #
664
+ attr_reader :authorize_environment
665
+ ##
666
+ # RPC-specific configuration for `add_public_key`
667
+ # @return [::Gapic::Config::Method]
668
+ #
669
+ attr_reader :add_public_key
670
+ ##
671
+ # RPC-specific configuration for `remove_public_key`
672
+ # @return [::Gapic::Config::Method]
673
+ #
674
+ attr_reader :remove_public_key
675
+
676
+ # @private
677
+ def initialize parent_rpcs = nil
678
+ get_environment_config = parent_rpcs.get_environment if parent_rpcs.respond_to? :get_environment
679
+ @get_environment = ::Gapic::Config::Method.new get_environment_config
680
+ start_environment_config = parent_rpcs.start_environment if parent_rpcs.respond_to? :start_environment
681
+ @start_environment = ::Gapic::Config::Method.new start_environment_config
682
+ authorize_environment_config = parent_rpcs.authorize_environment if parent_rpcs.respond_to? :authorize_environment
683
+ @authorize_environment = ::Gapic::Config::Method.new authorize_environment_config
684
+ add_public_key_config = parent_rpcs.add_public_key if parent_rpcs.respond_to? :add_public_key
685
+ @add_public_key = ::Gapic::Config::Method.new add_public_key_config
686
+ remove_public_key_config = parent_rpcs.remove_public_key if parent_rpcs.respond_to? :remove_public_key
687
+ @remove_public_key = ::Gapic::Config::Method.new remove_public_key_config
688
+
689
+ yield self if block_given?
690
+ end
691
+ end
692
+ end
693
+ end
694
+ end
695
+ end
696
+ end
697
+ end
698
+ end
699
+ end