google-cloud-shell-v1 0.1.0

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