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.appengine.v1; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.core.BetaApi; 22 import com.google.api.gax.core.BackgroundResource; 23 import com.google.api.gax.httpjson.longrunning.OperationsClient; 24 import com.google.api.gax.longrunning.OperationFuture; 25 import com.google.api.gax.paging.AbstractFixedSizeCollection; 26 import com.google.api.gax.paging.AbstractPage; 27 import com.google.api.gax.paging.AbstractPagedListResponse; 28 import com.google.api.gax.rpc.OperationCallable; 29 import com.google.api.gax.rpc.PageContext; 30 import com.google.api.gax.rpc.UnaryCallable; 31 import com.google.appengine.v1.stub.VersionsStub; 32 import com.google.appengine.v1.stub.VersionsStubSettings; 33 import com.google.common.util.concurrent.MoreExecutors; 34 import com.google.longrunning.Operation; 35 import com.google.protobuf.Empty; 36 import java.io.IOException; 37 import java.util.List; 38 import java.util.concurrent.TimeUnit; 39 import javax.annotation.Generated; 40 41 // AUTO-GENERATED DOCUMENTATION AND CLASS. 42 /** 43 * Service Description: Manages versions of a service. 44 * 45 * <p>This class provides the ability to make remote calls to the backing service through method 46 * calls that map to API methods. Sample code to get started: 47 * 48 * <pre>{@code 49 * // This snippet has been automatically generated and should be regarded as a code template only. 50 * // It will require modifications to work: 51 * // - It may require correct/in-range values for request initialization. 52 * // - It may require specifying regional endpoints when creating the service client as shown in 53 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 54 * try (VersionsClient versionsClient = VersionsClient.create()) { 55 * GetVersionRequest request = 56 * GetVersionRequest.newBuilder() 57 * .setName("name3373707") 58 * .setView(VersionView.forNumber(0)) 59 * .build(); 60 * Version response = versionsClient.getVersion(request); 61 * } 62 * }</pre> 63 * 64 * <p>Note: close() needs to be called on the VersionsClient object to clean up resources such as 65 * threads. In the example above, try-with-resources is used, which automatically calls close(). 66 * 67 * <p>The surface of this class includes several types of Java methods for each of the API's 68 * methods: 69 * 70 * <ol> 71 * <li>A "flattened" method. With this type of method, the fields of the request type have been 72 * converted into function parameters. It may be the case that not all fields are available as 73 * parameters, and not every API method will have a flattened method entry point. 74 * <li>A "request object" method. This type of method only takes one parameter, a request object, 75 * which must be constructed before the call. Not every API method will have a request object 76 * method. 77 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 78 * callable object, which can be used to initiate calls to the service. 79 * </ol> 80 * 81 * <p>See the individual methods for example code. 82 * 83 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 84 * these names, this class includes a format method for each type of name, and additionally a parse 85 * method to extract the individual identifiers contained within names that are returned. 86 * 87 * <p>This class can be customized by passing in a custom instance of VersionsSettings to create(). 88 * For example: 89 * 90 * <p>To customize credentials: 91 * 92 * <pre>{@code 93 * // This snippet has been automatically generated and should be regarded as a code template only. 94 * // It will require modifications to work: 95 * // - It may require correct/in-range values for request initialization. 96 * // - It may require specifying regional endpoints when creating the service client as shown in 97 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 98 * VersionsSettings versionsSettings = 99 * VersionsSettings.newBuilder() 100 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 101 * .build(); 102 * VersionsClient versionsClient = VersionsClient.create(versionsSettings); 103 * }</pre> 104 * 105 * <p>To customize the endpoint: 106 * 107 * <pre>{@code 108 * // This snippet has been automatically generated and should be regarded as a code template only. 109 * // It will require modifications to work: 110 * // - It may require correct/in-range values for request initialization. 111 * // - It may require specifying regional endpoints when creating the service client as shown in 112 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 113 * VersionsSettings versionsSettings = 114 * VersionsSettings.newBuilder().setEndpoint(myEndpoint).build(); 115 * VersionsClient versionsClient = VersionsClient.create(versionsSettings); 116 * }</pre> 117 * 118 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 119 * the wire: 120 * 121 * <pre>{@code 122 * // This snippet has been automatically generated and should be regarded as a code template only. 123 * // It will require modifications to work: 124 * // - It may require correct/in-range values for request initialization. 125 * // - It may require specifying regional endpoints when creating the service client as shown in 126 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 127 * VersionsSettings versionsSettings = VersionsSettings.newHttpJsonBuilder().build(); 128 * VersionsClient versionsClient = VersionsClient.create(versionsSettings); 129 * }</pre> 130 * 131 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 132 */ 133 @Generated("by gapic-generator-java") 134 public class VersionsClient implements BackgroundResource { 135 private final VersionsSettings settings; 136 private final VersionsStub stub; 137 private final OperationsClient httpJsonOperationsClient; 138 private final com.google.longrunning.OperationsClient operationsClient; 139 140 /** Constructs an instance of VersionsClient with default settings. */ create()141 public static final VersionsClient create() throws IOException { 142 return create(VersionsSettings.newBuilder().build()); 143 } 144 145 /** 146 * Constructs an instance of VersionsClient, using the given settings. The channels are created 147 * based on the settings passed in, or defaults for any settings that are not set. 148 */ create(VersionsSettings settings)149 public static final VersionsClient create(VersionsSettings settings) throws IOException { 150 return new VersionsClient(settings); 151 } 152 153 /** 154 * Constructs an instance of VersionsClient, using the given stub for making calls. This is for 155 * advanced usage - prefer using create(VersionsSettings). 156 */ create(VersionsStub stub)157 public static final VersionsClient create(VersionsStub stub) { 158 return new VersionsClient(stub); 159 } 160 161 /** 162 * Constructs an instance of VersionsClient, using the given settings. This is protected so that 163 * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. 164 */ VersionsClient(VersionsSettings settings)165 protected VersionsClient(VersionsSettings settings) throws IOException { 166 this.settings = settings; 167 this.stub = ((VersionsStubSettings) settings.getStubSettings()).createStub(); 168 this.operationsClient = 169 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 170 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 171 } 172 VersionsClient(VersionsStub stub)173 protected VersionsClient(VersionsStub stub) { 174 this.settings = null; 175 this.stub = stub; 176 this.operationsClient = 177 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 178 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 179 } 180 getSettings()181 public final VersionsSettings getSettings() { 182 return settings; 183 } 184 getStub()185 public VersionsStub getStub() { 186 return stub; 187 } 188 189 /** 190 * Returns the OperationsClient that can be used to query the status of a long-running operation 191 * returned by another API method call. 192 */ getOperationsClient()193 public final com.google.longrunning.OperationsClient getOperationsClient() { 194 return operationsClient; 195 } 196 197 /** 198 * Returns the OperationsClient that can be used to query the status of a long-running operation 199 * returned by another API method call. 200 */ 201 @BetaApi getHttpJsonOperationsClient()202 public final OperationsClient getHttpJsonOperationsClient() { 203 return httpJsonOperationsClient; 204 } 205 206 // AUTO-GENERATED DOCUMENTATION AND METHOD. 207 /** 208 * Lists the versions of a service. 209 * 210 * <p>Sample code: 211 * 212 * <pre>{@code 213 * // This snippet has been automatically generated and should be regarded as a code template only. 214 * // It will require modifications to work: 215 * // - It may require correct/in-range values for request initialization. 216 * // - It may require specifying regional endpoints when creating the service client as shown in 217 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 218 * try (VersionsClient versionsClient = VersionsClient.create()) { 219 * ListVersionsRequest request = 220 * ListVersionsRequest.newBuilder() 221 * .setParent("parent-995424086") 222 * .setView(VersionView.forNumber(0)) 223 * .setPageSize(883849137) 224 * .setPageToken("pageToken873572522") 225 * .build(); 226 * for (Version element : versionsClient.listVersions(request).iterateAll()) { 227 * // doThingsWith(element); 228 * } 229 * } 230 * }</pre> 231 * 232 * @param request The request object containing all of the parameters for the API call. 233 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 234 */ listVersions(ListVersionsRequest request)235 public final ListVersionsPagedResponse listVersions(ListVersionsRequest request) { 236 return listVersionsPagedCallable().call(request); 237 } 238 239 // AUTO-GENERATED DOCUMENTATION AND METHOD. 240 /** 241 * Lists the versions of a service. 242 * 243 * <p>Sample code: 244 * 245 * <pre>{@code 246 * // This snippet has been automatically generated and should be regarded as a code template only. 247 * // It will require modifications to work: 248 * // - It may require correct/in-range values for request initialization. 249 * // - It may require specifying regional endpoints when creating the service client as shown in 250 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 251 * try (VersionsClient versionsClient = VersionsClient.create()) { 252 * ListVersionsRequest request = 253 * ListVersionsRequest.newBuilder() 254 * .setParent("parent-995424086") 255 * .setView(VersionView.forNumber(0)) 256 * .setPageSize(883849137) 257 * .setPageToken("pageToken873572522") 258 * .build(); 259 * ApiFuture<Version> future = versionsClient.listVersionsPagedCallable().futureCall(request); 260 * // Do something. 261 * for (Version element : future.get().iterateAll()) { 262 * // doThingsWith(element); 263 * } 264 * } 265 * }</pre> 266 */ 267 public final UnaryCallable<ListVersionsRequest, ListVersionsPagedResponse> listVersionsPagedCallable()268 listVersionsPagedCallable() { 269 return stub.listVersionsPagedCallable(); 270 } 271 272 // AUTO-GENERATED DOCUMENTATION AND METHOD. 273 /** 274 * Lists the versions of a service. 275 * 276 * <p>Sample code: 277 * 278 * <pre>{@code 279 * // This snippet has been automatically generated and should be regarded as a code template only. 280 * // It will require modifications to work: 281 * // - It may require correct/in-range values for request initialization. 282 * // - It may require specifying regional endpoints when creating the service client as shown in 283 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 284 * try (VersionsClient versionsClient = VersionsClient.create()) { 285 * ListVersionsRequest request = 286 * ListVersionsRequest.newBuilder() 287 * .setParent("parent-995424086") 288 * .setView(VersionView.forNumber(0)) 289 * .setPageSize(883849137) 290 * .setPageToken("pageToken873572522") 291 * .build(); 292 * while (true) { 293 * ListVersionsResponse response = versionsClient.listVersionsCallable().call(request); 294 * for (Version element : response.getVersionsList()) { 295 * // doThingsWith(element); 296 * } 297 * String nextPageToken = response.getNextPageToken(); 298 * if (!Strings.isNullOrEmpty(nextPageToken)) { 299 * request = request.toBuilder().setPageToken(nextPageToken).build(); 300 * } else { 301 * break; 302 * } 303 * } 304 * } 305 * }</pre> 306 */ listVersionsCallable()307 public final UnaryCallable<ListVersionsRequest, ListVersionsResponse> listVersionsCallable() { 308 return stub.listVersionsCallable(); 309 } 310 311 // AUTO-GENERATED DOCUMENTATION AND METHOD. 312 /** 313 * Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify 314 * the `FULL_VIEW` parameter to get the full resource. 315 * 316 * <p>Sample code: 317 * 318 * <pre>{@code 319 * // This snippet has been automatically generated and should be regarded as a code template only. 320 * // It will require modifications to work: 321 * // - It may require correct/in-range values for request initialization. 322 * // - It may require specifying regional endpoints when creating the service client as shown in 323 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 324 * try (VersionsClient versionsClient = VersionsClient.create()) { 325 * GetVersionRequest request = 326 * GetVersionRequest.newBuilder() 327 * .setName("name3373707") 328 * .setView(VersionView.forNumber(0)) 329 * .build(); 330 * Version response = versionsClient.getVersion(request); 331 * } 332 * }</pre> 333 * 334 * @param request The request object containing all of the parameters for the API call. 335 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 336 */ getVersion(GetVersionRequest request)337 public final Version getVersion(GetVersionRequest request) { 338 return getVersionCallable().call(request); 339 } 340 341 // AUTO-GENERATED DOCUMENTATION AND METHOD. 342 /** 343 * Gets the specified Version resource. By default, only a `BASIC_VIEW` will be returned. Specify 344 * the `FULL_VIEW` parameter to get the full resource. 345 * 346 * <p>Sample code: 347 * 348 * <pre>{@code 349 * // This snippet has been automatically generated and should be regarded as a code template only. 350 * // It will require modifications to work: 351 * // - It may require correct/in-range values for request initialization. 352 * // - It may require specifying regional endpoints when creating the service client as shown in 353 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 354 * try (VersionsClient versionsClient = VersionsClient.create()) { 355 * GetVersionRequest request = 356 * GetVersionRequest.newBuilder() 357 * .setName("name3373707") 358 * .setView(VersionView.forNumber(0)) 359 * .build(); 360 * ApiFuture<Version> future = versionsClient.getVersionCallable().futureCall(request); 361 * // Do something. 362 * Version response = future.get(); 363 * } 364 * }</pre> 365 */ getVersionCallable()366 public final UnaryCallable<GetVersionRequest, Version> getVersionCallable() { 367 return stub.getVersionCallable(); 368 } 369 370 // AUTO-GENERATED DOCUMENTATION AND METHOD. 371 /** 372 * Deploys code and resource files to a new version. 373 * 374 * <p>Sample code: 375 * 376 * <pre>{@code 377 * // This snippet has been automatically generated and should be regarded as a code template only. 378 * // It will require modifications to work: 379 * // - It may require correct/in-range values for request initialization. 380 * // - It may require specifying regional endpoints when creating the service client as shown in 381 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 382 * try (VersionsClient versionsClient = VersionsClient.create()) { 383 * CreateVersionRequest request = 384 * CreateVersionRequest.newBuilder() 385 * .setParent("parent-995424086") 386 * .setVersion(Version.newBuilder().build()) 387 * .build(); 388 * Version response = versionsClient.createVersionAsync(request).get(); 389 * } 390 * }</pre> 391 * 392 * @param request The request object containing all of the parameters for the API call. 393 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 394 */ createVersionAsync( CreateVersionRequest request)395 public final OperationFuture<Version, CreateVersionMetadataV1> createVersionAsync( 396 CreateVersionRequest request) { 397 return createVersionOperationCallable().futureCall(request); 398 } 399 400 // AUTO-GENERATED DOCUMENTATION AND METHOD. 401 /** 402 * Deploys code and resource files to a new version. 403 * 404 * <p>Sample code: 405 * 406 * <pre>{@code 407 * // This snippet has been automatically generated and should be regarded as a code template only. 408 * // It will require modifications to work: 409 * // - It may require correct/in-range values for request initialization. 410 * // - It may require specifying regional endpoints when creating the service client as shown in 411 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 412 * try (VersionsClient versionsClient = VersionsClient.create()) { 413 * CreateVersionRequest request = 414 * CreateVersionRequest.newBuilder() 415 * .setParent("parent-995424086") 416 * .setVersion(Version.newBuilder().build()) 417 * .build(); 418 * OperationFuture<Version, CreateVersionMetadataV1> future = 419 * versionsClient.createVersionOperationCallable().futureCall(request); 420 * // Do something. 421 * Version response = future.get(); 422 * } 423 * }</pre> 424 */ 425 public final OperationCallable<CreateVersionRequest, Version, CreateVersionMetadataV1> createVersionOperationCallable()426 createVersionOperationCallable() { 427 return stub.createVersionOperationCallable(); 428 } 429 430 // AUTO-GENERATED DOCUMENTATION AND METHOD. 431 /** 432 * Deploys code and resource files to a new version. 433 * 434 * <p>Sample code: 435 * 436 * <pre>{@code 437 * // This snippet has been automatically generated and should be regarded as a code template only. 438 * // It will require modifications to work: 439 * // - It may require correct/in-range values for request initialization. 440 * // - It may require specifying regional endpoints when creating the service client as shown in 441 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 442 * try (VersionsClient versionsClient = VersionsClient.create()) { 443 * CreateVersionRequest request = 444 * CreateVersionRequest.newBuilder() 445 * .setParent("parent-995424086") 446 * .setVersion(Version.newBuilder().build()) 447 * .build(); 448 * ApiFuture<Operation> future = versionsClient.createVersionCallable().futureCall(request); 449 * // Do something. 450 * Operation response = future.get(); 451 * } 452 * }</pre> 453 */ createVersionCallable()454 public final UnaryCallable<CreateVersionRequest, Operation> createVersionCallable() { 455 return stub.createVersionCallable(); 456 } 457 458 // AUTO-GENERATED DOCUMENTATION AND METHOD. 459 /** 460 * Updates the specified Version resource. You can specify the following fields depending on the 461 * App Engine environment and type of scaling that the version resource uses: 462 * 463 * <p>**Standard environment** 464 * 465 * <ul> 466 * <li>[`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class) 467 * </ul> 468 * 469 * <p>*automatic scaling* in the standard environment: 470 * 471 * <ul> 472 * <li>[`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 473 * <li>[`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 474 * <li>[`automaticScaling.standard_scheduler_settings.max_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 475 * <li>[`automaticScaling.standard_scheduler_settings.min_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 476 * <li>[`automaticScaling.standard_scheduler_settings.target_cpu_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 477 * <li>[`automaticScaling.standard_scheduler_settings.target_throughput_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 478 * </ul> 479 * 480 * <p>*basic scaling* or *manual scaling* in the standard environment: 481 * 482 * <ul> 483 * <li>[`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) 484 * <li>[`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) 485 * </ul> 486 * 487 * <p>**Flexible environment** 488 * 489 * <ul> 490 * <li>[`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) 491 * </ul> 492 * 493 * <p>*automatic scaling* in the flexible environment: 494 * 495 * <ul> 496 * <li>[`automatic_scaling.min_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 497 * <li>[`automatic_scaling.max_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 498 * <li>[`automatic_scaling.cool_down_period_sec`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 499 * <li>[`automatic_scaling.cpu_utilization.target_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 500 * </ul> 501 * 502 * <p>*manual scaling* in the flexible environment: 503 * 504 * <ul> 505 * <li>[`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) 506 * </ul> 507 * 508 * <p>Sample code: 509 * 510 * <pre>{@code 511 * // This snippet has been automatically generated and should be regarded as a code template only. 512 * // It will require modifications to work: 513 * // - It may require correct/in-range values for request initialization. 514 * // - It may require specifying regional endpoints when creating the service client as shown in 515 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 516 * try (VersionsClient versionsClient = VersionsClient.create()) { 517 * UpdateVersionRequest request = 518 * UpdateVersionRequest.newBuilder() 519 * .setName("name3373707") 520 * .setVersion(Version.newBuilder().build()) 521 * .setUpdateMask(FieldMask.newBuilder().build()) 522 * .build(); 523 * Version response = versionsClient.updateVersionAsync(request).get(); 524 * } 525 * }</pre> 526 * 527 * @param request The request object containing all of the parameters for the API call. 528 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 529 */ updateVersionAsync( UpdateVersionRequest request)530 public final OperationFuture<Version, OperationMetadataV1> updateVersionAsync( 531 UpdateVersionRequest request) { 532 return updateVersionOperationCallable().futureCall(request); 533 } 534 535 // AUTO-GENERATED DOCUMENTATION AND METHOD. 536 /** 537 * Updates the specified Version resource. You can specify the following fields depending on the 538 * App Engine environment and type of scaling that the version resource uses: 539 * 540 * <p>**Standard environment** 541 * 542 * <ul> 543 * <li>[`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class) 544 * </ul> 545 * 546 * <p>*automatic scaling* in the standard environment: 547 * 548 * <ul> 549 * <li>[`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 550 * <li>[`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 551 * <li>[`automaticScaling.standard_scheduler_settings.max_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 552 * <li>[`automaticScaling.standard_scheduler_settings.min_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 553 * <li>[`automaticScaling.standard_scheduler_settings.target_cpu_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 554 * <li>[`automaticScaling.standard_scheduler_settings.target_throughput_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 555 * </ul> 556 * 557 * <p>*basic scaling* or *manual scaling* in the standard environment: 558 * 559 * <ul> 560 * <li>[`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) 561 * <li>[`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) 562 * </ul> 563 * 564 * <p>**Flexible environment** 565 * 566 * <ul> 567 * <li>[`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) 568 * </ul> 569 * 570 * <p>*automatic scaling* in the flexible environment: 571 * 572 * <ul> 573 * <li>[`automatic_scaling.min_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 574 * <li>[`automatic_scaling.max_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 575 * <li>[`automatic_scaling.cool_down_period_sec`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 576 * <li>[`automatic_scaling.cpu_utilization.target_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 577 * </ul> 578 * 579 * <p>*manual scaling* in the flexible environment: 580 * 581 * <ul> 582 * <li>[`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) 583 * </ul> 584 * 585 * <p>Sample code: 586 * 587 * <pre>{@code 588 * // This snippet has been automatically generated and should be regarded as a code template only. 589 * // It will require modifications to work: 590 * // - It may require correct/in-range values for request initialization. 591 * // - It may require specifying regional endpoints when creating the service client as shown in 592 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 593 * try (VersionsClient versionsClient = VersionsClient.create()) { 594 * UpdateVersionRequest request = 595 * UpdateVersionRequest.newBuilder() 596 * .setName("name3373707") 597 * .setVersion(Version.newBuilder().build()) 598 * .setUpdateMask(FieldMask.newBuilder().build()) 599 * .build(); 600 * OperationFuture<Version, OperationMetadataV1> future = 601 * versionsClient.updateVersionOperationCallable().futureCall(request); 602 * // Do something. 603 * Version response = future.get(); 604 * } 605 * }</pre> 606 */ 607 public final OperationCallable<UpdateVersionRequest, Version, OperationMetadataV1> updateVersionOperationCallable()608 updateVersionOperationCallable() { 609 return stub.updateVersionOperationCallable(); 610 } 611 612 // AUTO-GENERATED DOCUMENTATION AND METHOD. 613 /** 614 * Updates the specified Version resource. You can specify the following fields depending on the 615 * App Engine environment and type of scaling that the version resource uses: 616 * 617 * <p>**Standard environment** 618 * 619 * <ul> 620 * <li>[`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class) 621 * </ul> 622 * 623 * <p>*automatic scaling* in the standard environment: 624 * 625 * <ul> 626 * <li>[`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 627 * <li>[`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 628 * <li>[`automaticScaling.standard_scheduler_settings.max_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 629 * <li>[`automaticScaling.standard_scheduler_settings.min_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 630 * <li>[`automaticScaling.standard_scheduler_settings.target_cpu_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 631 * <li>[`automaticScaling.standard_scheduler_settings.target_throughput_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) 632 * </ul> 633 * 634 * <p>*basic scaling* or *manual scaling* in the standard environment: 635 * 636 * <ul> 637 * <li>[`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) 638 * <li>[`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) 639 * </ul> 640 * 641 * <p>**Flexible environment** 642 * 643 * <ul> 644 * <li>[`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) 645 * </ul> 646 * 647 * <p>*automatic scaling* in the flexible environment: 648 * 649 * <ul> 650 * <li>[`automatic_scaling.min_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 651 * <li>[`automatic_scaling.max_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 652 * <li>[`automatic_scaling.cool_down_period_sec`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 653 * <li>[`automatic_scaling.cpu_utilization.target_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) 654 * </ul> 655 * 656 * <p>*manual scaling* in the flexible environment: 657 * 658 * <ul> 659 * <li>[`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) 660 * </ul> 661 * 662 * <p>Sample code: 663 * 664 * <pre>{@code 665 * // This snippet has been automatically generated and should be regarded as a code template only. 666 * // It will require modifications to work: 667 * // - It may require correct/in-range values for request initialization. 668 * // - It may require specifying regional endpoints when creating the service client as shown in 669 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 670 * try (VersionsClient versionsClient = VersionsClient.create()) { 671 * UpdateVersionRequest request = 672 * UpdateVersionRequest.newBuilder() 673 * .setName("name3373707") 674 * .setVersion(Version.newBuilder().build()) 675 * .setUpdateMask(FieldMask.newBuilder().build()) 676 * .build(); 677 * ApiFuture<Operation> future = versionsClient.updateVersionCallable().futureCall(request); 678 * // Do something. 679 * Operation response = future.get(); 680 * } 681 * }</pre> 682 */ updateVersionCallable()683 public final UnaryCallable<UpdateVersionRequest, Operation> updateVersionCallable() { 684 return stub.updateVersionCallable(); 685 } 686 687 // AUTO-GENERATED DOCUMENTATION AND METHOD. 688 /** 689 * Deletes an existing Version resource. 690 * 691 * <p>Sample code: 692 * 693 * <pre>{@code 694 * // This snippet has been automatically generated and should be regarded as a code template only. 695 * // It will require modifications to work: 696 * // - It may require correct/in-range values for request initialization. 697 * // - It may require specifying regional endpoints when creating the service client as shown in 698 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 699 * try (VersionsClient versionsClient = VersionsClient.create()) { 700 * DeleteVersionRequest request = 701 * DeleteVersionRequest.newBuilder().setName("name3373707").build(); 702 * versionsClient.deleteVersionAsync(request).get(); 703 * } 704 * }</pre> 705 * 706 * @param request The request object containing all of the parameters for the API call. 707 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 708 */ deleteVersionAsync( DeleteVersionRequest request)709 public final OperationFuture<Empty, OperationMetadataV1> deleteVersionAsync( 710 DeleteVersionRequest request) { 711 return deleteVersionOperationCallable().futureCall(request); 712 } 713 714 // AUTO-GENERATED DOCUMENTATION AND METHOD. 715 /** 716 * Deletes an existing Version resource. 717 * 718 * <p>Sample code: 719 * 720 * <pre>{@code 721 * // This snippet has been automatically generated and should be regarded as a code template only. 722 * // It will require modifications to work: 723 * // - It may require correct/in-range values for request initialization. 724 * // - It may require specifying regional endpoints when creating the service client as shown in 725 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 726 * try (VersionsClient versionsClient = VersionsClient.create()) { 727 * DeleteVersionRequest request = 728 * DeleteVersionRequest.newBuilder().setName("name3373707").build(); 729 * OperationFuture<Empty, OperationMetadataV1> future = 730 * versionsClient.deleteVersionOperationCallable().futureCall(request); 731 * // Do something. 732 * future.get(); 733 * } 734 * }</pre> 735 */ 736 public final OperationCallable<DeleteVersionRequest, Empty, OperationMetadataV1> deleteVersionOperationCallable()737 deleteVersionOperationCallable() { 738 return stub.deleteVersionOperationCallable(); 739 } 740 741 // AUTO-GENERATED DOCUMENTATION AND METHOD. 742 /** 743 * Deletes an existing Version resource. 744 * 745 * <p>Sample code: 746 * 747 * <pre>{@code 748 * // This snippet has been automatically generated and should be regarded as a code template only. 749 * // It will require modifications to work: 750 * // - It may require correct/in-range values for request initialization. 751 * // - It may require specifying regional endpoints when creating the service client as shown in 752 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 753 * try (VersionsClient versionsClient = VersionsClient.create()) { 754 * DeleteVersionRequest request = 755 * DeleteVersionRequest.newBuilder().setName("name3373707").build(); 756 * ApiFuture<Operation> future = versionsClient.deleteVersionCallable().futureCall(request); 757 * // Do something. 758 * future.get(); 759 * } 760 * }</pre> 761 */ deleteVersionCallable()762 public final UnaryCallable<DeleteVersionRequest, Operation> deleteVersionCallable() { 763 return stub.deleteVersionCallable(); 764 } 765 766 @Override close()767 public final void close() { 768 stub.close(); 769 } 770 771 @Override shutdown()772 public void shutdown() { 773 stub.shutdown(); 774 } 775 776 @Override isShutdown()777 public boolean isShutdown() { 778 return stub.isShutdown(); 779 } 780 781 @Override isTerminated()782 public boolean isTerminated() { 783 return stub.isTerminated(); 784 } 785 786 @Override shutdownNow()787 public void shutdownNow() { 788 stub.shutdownNow(); 789 } 790 791 @Override awaitTermination(long duration, TimeUnit unit)792 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 793 return stub.awaitTermination(duration, unit); 794 } 795 796 public static class ListVersionsPagedResponse 797 extends AbstractPagedListResponse< 798 ListVersionsRequest, 799 ListVersionsResponse, 800 Version, 801 ListVersionsPage, 802 ListVersionsFixedSizeCollection> { 803 createAsync( PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, ApiFuture<ListVersionsResponse> futureResponse)804 public static ApiFuture<ListVersionsPagedResponse> createAsync( 805 PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, 806 ApiFuture<ListVersionsResponse> futureResponse) { 807 ApiFuture<ListVersionsPage> futurePage = 808 ListVersionsPage.createEmptyPage().createPageAsync(context, futureResponse); 809 return ApiFutures.transform( 810 futurePage, 811 input -> new ListVersionsPagedResponse(input), 812 MoreExecutors.directExecutor()); 813 } 814 ListVersionsPagedResponse(ListVersionsPage page)815 private ListVersionsPagedResponse(ListVersionsPage page) { 816 super(page, ListVersionsFixedSizeCollection.createEmptyCollection()); 817 } 818 } 819 820 public static class ListVersionsPage 821 extends AbstractPage<ListVersionsRequest, ListVersionsResponse, Version, ListVersionsPage> { 822 ListVersionsPage( PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, ListVersionsResponse response)823 private ListVersionsPage( 824 PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, 825 ListVersionsResponse response) { 826 super(context, response); 827 } 828 createEmptyPage()829 private static ListVersionsPage createEmptyPage() { 830 return new ListVersionsPage(null, null); 831 } 832 833 @Override createPage( PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, ListVersionsResponse response)834 protected ListVersionsPage createPage( 835 PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, 836 ListVersionsResponse response) { 837 return new ListVersionsPage(context, response); 838 } 839 840 @Override createPageAsync( PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, ApiFuture<ListVersionsResponse> futureResponse)841 public ApiFuture<ListVersionsPage> createPageAsync( 842 PageContext<ListVersionsRequest, ListVersionsResponse, Version> context, 843 ApiFuture<ListVersionsResponse> futureResponse) { 844 return super.createPageAsync(context, futureResponse); 845 } 846 } 847 848 public static class ListVersionsFixedSizeCollection 849 extends AbstractFixedSizeCollection< 850 ListVersionsRequest, 851 ListVersionsResponse, 852 Version, 853 ListVersionsPage, 854 ListVersionsFixedSizeCollection> { 855 ListVersionsFixedSizeCollection(List<ListVersionsPage> pages, int collectionSize)856 private ListVersionsFixedSizeCollection(List<ListVersionsPage> pages, int collectionSize) { 857 super(pages, collectionSize); 858 } 859 createEmptyCollection()860 private static ListVersionsFixedSizeCollection createEmptyCollection() { 861 return new ListVersionsFixedSizeCollection(null, 0); 862 } 863 864 @Override createCollection( List<ListVersionsPage> pages, int collectionSize)865 protected ListVersionsFixedSizeCollection createCollection( 866 List<ListVersionsPage> pages, int collectionSize) { 867 return new ListVersionsFixedSizeCollection(pages, collectionSize); 868 } 869 } 870 } 871