1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.cloud.shell.v1; 18 19 import com.google.api.core.BetaApi; 20 import com.google.api.gax.core.BackgroundResource; 21 import com.google.api.gax.httpjson.longrunning.OperationsClient; 22 import com.google.api.gax.longrunning.OperationFuture; 23 import com.google.api.gax.rpc.OperationCallable; 24 import com.google.api.gax.rpc.UnaryCallable; 25 import com.google.cloud.shell.v1.stub.CloudShellServiceStub; 26 import com.google.cloud.shell.v1.stub.CloudShellServiceStubSettings; 27 import com.google.longrunning.Operation; 28 import java.io.IOException; 29 import java.util.concurrent.TimeUnit; 30 import javax.annotation.Generated; 31 32 // AUTO-GENERATED DOCUMENTATION AND CLASS. 33 /** 34 * Service Description: API for interacting with Google Cloud Shell. Each user of Cloud Shell has at 35 * least one environment, which has the ID "default". Environment consists of a Docker image 36 * defining what is installed on the environment and a home directory containing the user's data 37 * that will remain across sessions. Clients use this API to start and fetch information about their 38 * environment, which can then be used to connect to that environment via a separate SSH client. 39 * 40 * <p>This class provides the ability to make remote calls to the backing service through method 41 * calls that map to API methods. Sample code to get started: 42 * 43 * <pre>{@code 44 * // This snippet has been automatically generated and should be regarded as a code template only. 45 * // It will require modifications to work: 46 * // - It may require correct/in-range values for request initialization. 47 * // - It may require specifying regional endpoints when creating the service client as shown in 48 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 49 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 50 * EnvironmentName name = EnvironmentName.of("[USER]", "[ENVIRONMENT]"); 51 * Environment response = cloudShellServiceClient.getEnvironment(name); 52 * } 53 * }</pre> 54 * 55 * <p>Note: close() needs to be called on the CloudShellServiceClient object to clean up resources 56 * such as threads. In the example above, try-with-resources is used, which automatically calls 57 * close(). 58 * 59 * <p>The surface of this class includes several types of Java methods for each of the API's 60 * methods: 61 * 62 * <ol> 63 * <li>A "flattened" method. With this type of method, the fields of the request type have been 64 * converted into function parameters. It may be the case that not all fields are available as 65 * parameters, and not every API method will have a flattened method entry point. 66 * <li>A "request object" method. This type of method only takes one parameter, a request object, 67 * which must be constructed before the call. Not every API method will have a request object 68 * method. 69 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 70 * callable object, which can be used to initiate calls to the service. 71 * </ol> 72 * 73 * <p>See the individual methods for example code. 74 * 75 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 76 * these names, this class includes a format method for each type of name, and additionally a parse 77 * method to extract the individual identifiers contained within names that are returned. 78 * 79 * <p>This class can be customized by passing in a custom instance of CloudShellServiceSettings to 80 * create(). For example: 81 * 82 * <p>To customize credentials: 83 * 84 * <pre>{@code 85 * // This snippet has been automatically generated and should be regarded as a code template only. 86 * // It will require modifications to work: 87 * // - It may require correct/in-range values for request initialization. 88 * // - It may require specifying regional endpoints when creating the service client as shown in 89 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 90 * CloudShellServiceSettings cloudShellServiceSettings = 91 * CloudShellServiceSettings.newBuilder() 92 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 93 * .build(); 94 * CloudShellServiceClient cloudShellServiceClient = 95 * CloudShellServiceClient.create(cloudShellServiceSettings); 96 * }</pre> 97 * 98 * <p>To customize the endpoint: 99 * 100 * <pre>{@code 101 * // This snippet has been automatically generated and should be regarded as a code template only. 102 * // It will require modifications to work: 103 * // - It may require correct/in-range values for request initialization. 104 * // - It may require specifying regional endpoints when creating the service client as shown in 105 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 106 * CloudShellServiceSettings cloudShellServiceSettings = 107 * CloudShellServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); 108 * CloudShellServiceClient cloudShellServiceClient = 109 * CloudShellServiceClient.create(cloudShellServiceSettings); 110 * }</pre> 111 * 112 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 113 * the wire: 114 * 115 * <pre>{@code 116 * // This snippet has been automatically generated and should be regarded as a code template only. 117 * // It will require modifications to work: 118 * // - It may require correct/in-range values for request initialization. 119 * // - It may require specifying regional endpoints when creating the service client as shown in 120 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 121 * CloudShellServiceSettings cloudShellServiceSettings = 122 * CloudShellServiceSettings.newHttpJsonBuilder().build(); 123 * CloudShellServiceClient cloudShellServiceClient = 124 * CloudShellServiceClient.create(cloudShellServiceSettings); 125 * }</pre> 126 * 127 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 128 */ 129 @Generated("by gapic-generator-java") 130 public class CloudShellServiceClient implements BackgroundResource { 131 private final CloudShellServiceSettings settings; 132 private final CloudShellServiceStub stub; 133 private final OperationsClient httpJsonOperationsClient; 134 private final com.google.longrunning.OperationsClient operationsClient; 135 136 /** Constructs an instance of CloudShellServiceClient with default settings. */ create()137 public static final CloudShellServiceClient create() throws IOException { 138 return create(CloudShellServiceSettings.newBuilder().build()); 139 } 140 141 /** 142 * Constructs an instance of CloudShellServiceClient, using the given settings. The channels are 143 * created based on the settings passed in, or defaults for any settings that are not set. 144 */ create(CloudShellServiceSettings settings)145 public static final CloudShellServiceClient create(CloudShellServiceSettings settings) 146 throws IOException { 147 return new CloudShellServiceClient(settings); 148 } 149 150 /** 151 * Constructs an instance of CloudShellServiceClient, using the given stub for making calls. This 152 * is for advanced usage - prefer using create(CloudShellServiceSettings). 153 */ create(CloudShellServiceStub stub)154 public static final CloudShellServiceClient create(CloudShellServiceStub stub) { 155 return new CloudShellServiceClient(stub); 156 } 157 158 /** 159 * Constructs an instance of CloudShellServiceClient, using the given settings. This is protected 160 * so that it is easy to make a subclass, but otherwise, the static factory methods should be 161 * preferred. 162 */ CloudShellServiceClient(CloudShellServiceSettings settings)163 protected CloudShellServiceClient(CloudShellServiceSettings settings) throws IOException { 164 this.settings = settings; 165 this.stub = ((CloudShellServiceStubSettings) settings.getStubSettings()).createStub(); 166 this.operationsClient = 167 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 168 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 169 } 170 CloudShellServiceClient(CloudShellServiceStub stub)171 protected CloudShellServiceClient(CloudShellServiceStub stub) { 172 this.settings = null; 173 this.stub = stub; 174 this.operationsClient = 175 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 176 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 177 } 178 getSettings()179 public final CloudShellServiceSettings getSettings() { 180 return settings; 181 } 182 getStub()183 public CloudShellServiceStub getStub() { 184 return stub; 185 } 186 187 /** 188 * Returns the OperationsClient that can be used to query the status of a long-running operation 189 * returned by another API method call. 190 */ getOperationsClient()191 public final com.google.longrunning.OperationsClient getOperationsClient() { 192 return operationsClient; 193 } 194 195 /** 196 * Returns the OperationsClient that can be used to query the status of a long-running operation 197 * returned by another API method call. 198 */ 199 @BetaApi getHttpJsonOperationsClient()200 public final OperationsClient getHttpJsonOperationsClient() { 201 return httpJsonOperationsClient; 202 } 203 204 // AUTO-GENERATED DOCUMENTATION AND METHOD. 205 /** 206 * Gets an environment. Returns NOT_FOUND if the environment does not exist. 207 * 208 * <p>Sample code: 209 * 210 * <pre>{@code 211 * // This snippet has been automatically generated and should be regarded as a code template only. 212 * // It will require modifications to work: 213 * // - It may require correct/in-range values for request initialization. 214 * // - It may require specifying regional endpoints when creating the service client as shown in 215 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 216 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 217 * EnvironmentName name = EnvironmentName.of("[USER]", "[ENVIRONMENT]"); 218 * Environment response = cloudShellServiceClient.getEnvironment(name); 219 * } 220 * }</pre> 221 * 222 * @param name Required. Name of the requested resource, for example 223 * `users/me/environments/default` or 224 * `users/someone{@literal @}example.com/environments/default`. 225 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 226 */ getEnvironment(EnvironmentName name)227 public final Environment getEnvironment(EnvironmentName name) { 228 GetEnvironmentRequest request = 229 GetEnvironmentRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 230 return getEnvironment(request); 231 } 232 233 // AUTO-GENERATED DOCUMENTATION AND METHOD. 234 /** 235 * Gets an environment. Returns NOT_FOUND if the environment does not exist. 236 * 237 * <p>Sample code: 238 * 239 * <pre>{@code 240 * // This snippet has been automatically generated and should be regarded as a code template only. 241 * // It will require modifications to work: 242 * // - It may require correct/in-range values for request initialization. 243 * // - It may require specifying regional endpoints when creating the service client as shown in 244 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 245 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 246 * String name = EnvironmentName.of("[USER]", "[ENVIRONMENT]").toString(); 247 * Environment response = cloudShellServiceClient.getEnvironment(name); 248 * } 249 * }</pre> 250 * 251 * @param name Required. Name of the requested resource, for example 252 * `users/me/environments/default` or 253 * `users/someone{@literal @}example.com/environments/default`. 254 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 255 */ getEnvironment(String name)256 public final Environment getEnvironment(String name) { 257 GetEnvironmentRequest request = GetEnvironmentRequest.newBuilder().setName(name).build(); 258 return getEnvironment(request); 259 } 260 261 // AUTO-GENERATED DOCUMENTATION AND METHOD. 262 /** 263 * Gets an environment. Returns NOT_FOUND if the environment does not exist. 264 * 265 * <p>Sample code: 266 * 267 * <pre>{@code 268 * // This snippet has been automatically generated and should be regarded as a code template only. 269 * // It will require modifications to work: 270 * // - It may require correct/in-range values for request initialization. 271 * // - It may require specifying regional endpoints when creating the service client as shown in 272 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 273 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 274 * GetEnvironmentRequest request = 275 * GetEnvironmentRequest.newBuilder() 276 * .setName(EnvironmentName.of("[USER]", "[ENVIRONMENT]").toString()) 277 * .build(); 278 * Environment response = cloudShellServiceClient.getEnvironment(request); 279 * } 280 * }</pre> 281 * 282 * @param request The request object containing all of the parameters for the API call. 283 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 284 */ getEnvironment(GetEnvironmentRequest request)285 public final Environment getEnvironment(GetEnvironmentRequest request) { 286 return getEnvironmentCallable().call(request); 287 } 288 289 // AUTO-GENERATED DOCUMENTATION AND METHOD. 290 /** 291 * Gets an environment. Returns NOT_FOUND if the environment does not exist. 292 * 293 * <p>Sample code: 294 * 295 * <pre>{@code 296 * // This snippet has been automatically generated and should be regarded as a code template only. 297 * // It will require modifications to work: 298 * // - It may require correct/in-range values for request initialization. 299 * // - It may require specifying regional endpoints when creating the service client as shown in 300 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 301 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 302 * GetEnvironmentRequest request = 303 * GetEnvironmentRequest.newBuilder() 304 * .setName(EnvironmentName.of("[USER]", "[ENVIRONMENT]").toString()) 305 * .build(); 306 * ApiFuture<Environment> future = 307 * cloudShellServiceClient.getEnvironmentCallable().futureCall(request); 308 * // Do something. 309 * Environment response = future.get(); 310 * } 311 * }</pre> 312 */ getEnvironmentCallable()313 public final UnaryCallable<GetEnvironmentRequest, Environment> getEnvironmentCallable() { 314 return stub.getEnvironmentCallable(); 315 } 316 317 // AUTO-GENERATED DOCUMENTATION AND METHOD. 318 /** 319 * Starts an existing environment, allowing clients to connect to it. The returned operation will 320 * contain an instance of StartEnvironmentMetadata in its metadata field. Users can wait for the 321 * environment to start by polling this operation via GetOperation. Once the environment has 322 * finished starting and is ready to accept connections, the operation will contain a 323 * StartEnvironmentResponse in its response field. 324 * 325 * <p>Sample code: 326 * 327 * <pre>{@code 328 * // This snippet has been automatically generated and should be regarded as a code template only. 329 * // It will require modifications to work: 330 * // - It may require correct/in-range values for request initialization. 331 * // - It may require specifying regional endpoints when creating the service client as shown in 332 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 333 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 334 * StartEnvironmentRequest request = 335 * StartEnvironmentRequest.newBuilder() 336 * .setName("name3373707") 337 * .setAccessToken("accessToken-1042689291") 338 * .addAllPublicKeys(new ArrayList<String>()) 339 * .build(); 340 * StartEnvironmentResponse response = 341 * cloudShellServiceClient.startEnvironmentAsync(request).get(); 342 * } 343 * }</pre> 344 * 345 * @param request The request object containing all of the parameters for the API call. 346 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 347 */ 348 public final OperationFuture<StartEnvironmentResponse, StartEnvironmentMetadata> startEnvironmentAsync(StartEnvironmentRequest request)349 startEnvironmentAsync(StartEnvironmentRequest request) { 350 return startEnvironmentOperationCallable().futureCall(request); 351 } 352 353 // AUTO-GENERATED DOCUMENTATION AND METHOD. 354 /** 355 * Starts an existing environment, allowing clients to connect to it. The returned operation will 356 * contain an instance of StartEnvironmentMetadata in its metadata field. Users can wait for the 357 * environment to start by polling this operation via GetOperation. Once the environment has 358 * finished starting and is ready to accept connections, the operation will contain a 359 * StartEnvironmentResponse in its response field. 360 * 361 * <p>Sample code: 362 * 363 * <pre>{@code 364 * // This snippet has been automatically generated and should be regarded as a code template only. 365 * // It will require modifications to work: 366 * // - It may require correct/in-range values for request initialization. 367 * // - It may require specifying regional endpoints when creating the service client as shown in 368 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 369 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 370 * StartEnvironmentRequest request = 371 * StartEnvironmentRequest.newBuilder() 372 * .setName("name3373707") 373 * .setAccessToken("accessToken-1042689291") 374 * .addAllPublicKeys(new ArrayList<String>()) 375 * .build(); 376 * OperationFuture<StartEnvironmentResponse, StartEnvironmentMetadata> future = 377 * cloudShellServiceClient.startEnvironmentOperationCallable().futureCall(request); 378 * // Do something. 379 * StartEnvironmentResponse response = future.get(); 380 * } 381 * }</pre> 382 */ 383 public final OperationCallable< 384 StartEnvironmentRequest, StartEnvironmentResponse, StartEnvironmentMetadata> startEnvironmentOperationCallable()385 startEnvironmentOperationCallable() { 386 return stub.startEnvironmentOperationCallable(); 387 } 388 389 // AUTO-GENERATED DOCUMENTATION AND METHOD. 390 /** 391 * Starts an existing environment, allowing clients to connect to it. The returned operation will 392 * contain an instance of StartEnvironmentMetadata in its metadata field. Users can wait for the 393 * environment to start by polling this operation via GetOperation. Once the environment has 394 * finished starting and is ready to accept connections, the operation will contain a 395 * StartEnvironmentResponse in its response field. 396 * 397 * <p>Sample code: 398 * 399 * <pre>{@code 400 * // This snippet has been automatically generated and should be regarded as a code template only. 401 * // It will require modifications to work: 402 * // - It may require correct/in-range values for request initialization. 403 * // - It may require specifying regional endpoints when creating the service client as shown in 404 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 405 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 406 * StartEnvironmentRequest request = 407 * StartEnvironmentRequest.newBuilder() 408 * .setName("name3373707") 409 * .setAccessToken("accessToken-1042689291") 410 * .addAllPublicKeys(new ArrayList<String>()) 411 * .build(); 412 * ApiFuture<Operation> future = 413 * cloudShellServiceClient.startEnvironmentCallable().futureCall(request); 414 * // Do something. 415 * Operation response = future.get(); 416 * } 417 * }</pre> 418 */ startEnvironmentCallable()419 public final UnaryCallable<StartEnvironmentRequest, Operation> startEnvironmentCallable() { 420 return stub.startEnvironmentCallable(); 421 } 422 423 // AUTO-GENERATED DOCUMENTATION AND METHOD. 424 /** 425 * Sends OAuth credentials to a running environment on behalf of a user. When this completes, the 426 * environment will be authorized to run various Google Cloud command line tools without requiring 427 * the user to manually authenticate. 428 * 429 * <p>Sample code: 430 * 431 * <pre>{@code 432 * // This snippet has been automatically generated and should be regarded as a code template only. 433 * // It will require modifications to work: 434 * // - It may require correct/in-range values for request initialization. 435 * // - It may require specifying regional endpoints when creating the service client as shown in 436 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 437 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 438 * AuthorizeEnvironmentRequest request = 439 * AuthorizeEnvironmentRequest.newBuilder() 440 * .setName("name3373707") 441 * .setAccessToken("accessToken-1042689291") 442 * .setIdToken("idToken1642509726") 443 * .setExpireTime(Timestamp.newBuilder().build()) 444 * .build(); 445 * AuthorizeEnvironmentResponse response = 446 * cloudShellServiceClient.authorizeEnvironmentAsync(request).get(); 447 * } 448 * }</pre> 449 * 450 * @param request The request object containing all of the parameters for the API call. 451 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 452 */ 453 public final OperationFuture<AuthorizeEnvironmentResponse, AuthorizeEnvironmentMetadata> authorizeEnvironmentAsync(AuthorizeEnvironmentRequest request)454 authorizeEnvironmentAsync(AuthorizeEnvironmentRequest request) { 455 return authorizeEnvironmentOperationCallable().futureCall(request); 456 } 457 458 // AUTO-GENERATED DOCUMENTATION AND METHOD. 459 /** 460 * Sends OAuth credentials to a running environment on behalf of a user. When this completes, the 461 * environment will be authorized to run various Google Cloud command line tools without requiring 462 * the user to manually authenticate. 463 * 464 * <p>Sample code: 465 * 466 * <pre>{@code 467 * // This snippet has been automatically generated and should be regarded as a code template only. 468 * // It will require modifications to work: 469 * // - It may require correct/in-range values for request initialization. 470 * // - It may require specifying regional endpoints when creating the service client as shown in 471 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 472 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 473 * AuthorizeEnvironmentRequest request = 474 * AuthorizeEnvironmentRequest.newBuilder() 475 * .setName("name3373707") 476 * .setAccessToken("accessToken-1042689291") 477 * .setIdToken("idToken1642509726") 478 * .setExpireTime(Timestamp.newBuilder().build()) 479 * .build(); 480 * OperationFuture<AuthorizeEnvironmentResponse, AuthorizeEnvironmentMetadata> future = 481 * cloudShellServiceClient.authorizeEnvironmentOperationCallable().futureCall(request); 482 * // Do something. 483 * AuthorizeEnvironmentResponse response = future.get(); 484 * } 485 * }</pre> 486 */ 487 public final OperationCallable< 488 AuthorizeEnvironmentRequest, AuthorizeEnvironmentResponse, AuthorizeEnvironmentMetadata> authorizeEnvironmentOperationCallable()489 authorizeEnvironmentOperationCallable() { 490 return stub.authorizeEnvironmentOperationCallable(); 491 } 492 493 // AUTO-GENERATED DOCUMENTATION AND METHOD. 494 /** 495 * Sends OAuth credentials to a running environment on behalf of a user. When this completes, the 496 * environment will be authorized to run various Google Cloud command line tools without requiring 497 * the user to manually authenticate. 498 * 499 * <p>Sample code: 500 * 501 * <pre>{@code 502 * // This snippet has been automatically generated and should be regarded as a code template only. 503 * // It will require modifications to work: 504 * // - It may require correct/in-range values for request initialization. 505 * // - It may require specifying regional endpoints when creating the service client as shown in 506 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 507 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 508 * AuthorizeEnvironmentRequest request = 509 * AuthorizeEnvironmentRequest.newBuilder() 510 * .setName("name3373707") 511 * .setAccessToken("accessToken-1042689291") 512 * .setIdToken("idToken1642509726") 513 * .setExpireTime(Timestamp.newBuilder().build()) 514 * .build(); 515 * ApiFuture<Operation> future = 516 * cloudShellServiceClient.authorizeEnvironmentCallable().futureCall(request); 517 * // Do something. 518 * Operation response = future.get(); 519 * } 520 * }</pre> 521 */ 522 public final UnaryCallable<AuthorizeEnvironmentRequest, Operation> authorizeEnvironmentCallable()523 authorizeEnvironmentCallable() { 524 return stub.authorizeEnvironmentCallable(); 525 } 526 527 // AUTO-GENERATED DOCUMENTATION AND METHOD. 528 /** 529 * Adds a public SSH key to an environment, allowing clients with the corresponding private key to 530 * connect to that environment via SSH. If a key with the same content already exists, this will 531 * error with ALREADY_EXISTS. 532 * 533 * <p>Sample code: 534 * 535 * <pre>{@code 536 * // This snippet has been automatically generated and should be regarded as a code template only. 537 * // It will require modifications to work: 538 * // - It may require correct/in-range values for request initialization. 539 * // - It may require specifying regional endpoints when creating the service client as shown in 540 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 541 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 542 * AddPublicKeyRequest request = 543 * AddPublicKeyRequest.newBuilder() 544 * .setEnvironment("environment-85904877") 545 * .setKey("key106079") 546 * .build(); 547 * AddPublicKeyResponse response = cloudShellServiceClient.addPublicKeyAsync(request).get(); 548 * } 549 * }</pre> 550 * 551 * @param request The request object containing all of the parameters for the API call. 552 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 553 */ addPublicKeyAsync( AddPublicKeyRequest request)554 public final OperationFuture<AddPublicKeyResponse, AddPublicKeyMetadata> addPublicKeyAsync( 555 AddPublicKeyRequest request) { 556 return addPublicKeyOperationCallable().futureCall(request); 557 } 558 559 // AUTO-GENERATED DOCUMENTATION AND METHOD. 560 /** 561 * Adds a public SSH key to an environment, allowing clients with the corresponding private key to 562 * connect to that environment via SSH. If a key with the same content already exists, this will 563 * error with ALREADY_EXISTS. 564 * 565 * <p>Sample code: 566 * 567 * <pre>{@code 568 * // This snippet has been automatically generated and should be regarded as a code template only. 569 * // It will require modifications to work: 570 * // - It may require correct/in-range values for request initialization. 571 * // - It may require specifying regional endpoints when creating the service client as shown in 572 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 573 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 574 * AddPublicKeyRequest request = 575 * AddPublicKeyRequest.newBuilder() 576 * .setEnvironment("environment-85904877") 577 * .setKey("key106079") 578 * .build(); 579 * OperationFuture<AddPublicKeyResponse, AddPublicKeyMetadata> future = 580 * cloudShellServiceClient.addPublicKeyOperationCallable().futureCall(request); 581 * // Do something. 582 * AddPublicKeyResponse response = future.get(); 583 * } 584 * }</pre> 585 */ 586 public final OperationCallable<AddPublicKeyRequest, AddPublicKeyResponse, AddPublicKeyMetadata> addPublicKeyOperationCallable()587 addPublicKeyOperationCallable() { 588 return stub.addPublicKeyOperationCallable(); 589 } 590 591 // AUTO-GENERATED DOCUMENTATION AND METHOD. 592 /** 593 * Adds a public SSH key to an environment, allowing clients with the corresponding private key to 594 * connect to that environment via SSH. If a key with the same content already exists, this will 595 * error with ALREADY_EXISTS. 596 * 597 * <p>Sample code: 598 * 599 * <pre>{@code 600 * // This snippet has been automatically generated and should be regarded as a code template only. 601 * // It will require modifications to work: 602 * // - It may require correct/in-range values for request initialization. 603 * // - It may require specifying regional endpoints when creating the service client as shown in 604 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 605 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 606 * AddPublicKeyRequest request = 607 * AddPublicKeyRequest.newBuilder() 608 * .setEnvironment("environment-85904877") 609 * .setKey("key106079") 610 * .build(); 611 * ApiFuture<Operation> future = 612 * cloudShellServiceClient.addPublicKeyCallable().futureCall(request); 613 * // Do something. 614 * Operation response = future.get(); 615 * } 616 * }</pre> 617 */ addPublicKeyCallable()618 public final UnaryCallable<AddPublicKeyRequest, Operation> addPublicKeyCallable() { 619 return stub.addPublicKeyCallable(); 620 } 621 622 // AUTO-GENERATED DOCUMENTATION AND METHOD. 623 /** 624 * Removes a public SSH key from an environment. Clients will no longer be able to connect to the 625 * environment using the corresponding private key. If a key with the same content is not present, 626 * this will error with NOT_FOUND. 627 * 628 * <p>Sample code: 629 * 630 * <pre>{@code 631 * // This snippet has been automatically generated and should be regarded as a code template only. 632 * // It will require modifications to work: 633 * // - It may require correct/in-range values for request initialization. 634 * // - It may require specifying regional endpoints when creating the service client as shown in 635 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 636 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 637 * RemovePublicKeyRequest request = 638 * RemovePublicKeyRequest.newBuilder() 639 * .setEnvironment("environment-85904877") 640 * .setKey("key106079") 641 * .build(); 642 * RemovePublicKeyResponse response = 643 * cloudShellServiceClient.removePublicKeyAsync(request).get(); 644 * } 645 * }</pre> 646 * 647 * @param request The request object containing all of the parameters for the API call. 648 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 649 */ 650 public final OperationFuture<RemovePublicKeyResponse, RemovePublicKeyMetadata> removePublicKeyAsync(RemovePublicKeyRequest request)651 removePublicKeyAsync(RemovePublicKeyRequest request) { 652 return removePublicKeyOperationCallable().futureCall(request); 653 } 654 655 // AUTO-GENERATED DOCUMENTATION AND METHOD. 656 /** 657 * Removes a public SSH key from an environment. Clients will no longer be able to connect to the 658 * environment using the corresponding private key. If a key with the same content is not present, 659 * this will error with NOT_FOUND. 660 * 661 * <p>Sample code: 662 * 663 * <pre>{@code 664 * // This snippet has been automatically generated and should be regarded as a code template only. 665 * // It will require modifications to work: 666 * // - It may require correct/in-range values for request initialization. 667 * // - It may require specifying regional endpoints when creating the service client as shown in 668 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 669 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 670 * RemovePublicKeyRequest request = 671 * RemovePublicKeyRequest.newBuilder() 672 * .setEnvironment("environment-85904877") 673 * .setKey("key106079") 674 * .build(); 675 * OperationFuture<RemovePublicKeyResponse, RemovePublicKeyMetadata> future = 676 * cloudShellServiceClient.removePublicKeyOperationCallable().futureCall(request); 677 * // Do something. 678 * RemovePublicKeyResponse response = future.get(); 679 * } 680 * }</pre> 681 */ 682 public final OperationCallable< 683 RemovePublicKeyRequest, RemovePublicKeyResponse, RemovePublicKeyMetadata> removePublicKeyOperationCallable()684 removePublicKeyOperationCallable() { 685 return stub.removePublicKeyOperationCallable(); 686 } 687 688 // AUTO-GENERATED DOCUMENTATION AND METHOD. 689 /** 690 * Removes a public SSH key from an environment. Clients will no longer be able to connect to the 691 * environment using the corresponding private key. If a key with the same content is not present, 692 * this will error with NOT_FOUND. 693 * 694 * <p>Sample code: 695 * 696 * <pre>{@code 697 * // This snippet has been automatically generated and should be regarded as a code template only. 698 * // It will require modifications to work: 699 * // - It may require correct/in-range values for request initialization. 700 * // - It may require specifying regional endpoints when creating the service client as shown in 701 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 702 * try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { 703 * RemovePublicKeyRequest request = 704 * RemovePublicKeyRequest.newBuilder() 705 * .setEnvironment("environment-85904877") 706 * .setKey("key106079") 707 * .build(); 708 * ApiFuture<Operation> future = 709 * cloudShellServiceClient.removePublicKeyCallable().futureCall(request); 710 * // Do something. 711 * Operation response = future.get(); 712 * } 713 * }</pre> 714 */ removePublicKeyCallable()715 public final UnaryCallable<RemovePublicKeyRequest, Operation> removePublicKeyCallable() { 716 return stub.removePublicKeyCallable(); 717 } 718 719 @Override close()720 public final void close() { 721 stub.close(); 722 } 723 724 @Override shutdown()725 public void shutdown() { 726 stub.shutdown(); 727 } 728 729 @Override isShutdown()730 public boolean isShutdown() { 731 return stub.isShutdown(); 732 } 733 734 @Override isTerminated()735 public boolean isTerminated() { 736 return stub.isTerminated(); 737 } 738 739 @Override shutdownNow()740 public void shutdownNow() { 741 stub.shutdownNow(); 742 } 743 744 @Override awaitTermination(long duration, TimeUnit unit)745 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 746 return stub.awaitTermination(duration, unit); 747 } 748 } 749