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.devtools.cloudbuild.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.cloud.devtools.cloudbuild.v1.stub.CloudBuildStub; 32 import com.google.cloud.devtools.cloudbuild.v1.stub.CloudBuildStubSettings; 33 import com.google.cloudbuild.v1.ApprovalResult; 34 import com.google.cloudbuild.v1.ApproveBuildRequest; 35 import com.google.cloudbuild.v1.Build; 36 import com.google.cloudbuild.v1.BuildOperationMetadata; 37 import com.google.cloudbuild.v1.BuildTrigger; 38 import com.google.cloudbuild.v1.CancelBuildRequest; 39 import com.google.cloudbuild.v1.CreateBuildRequest; 40 import com.google.cloudbuild.v1.CreateBuildTriggerRequest; 41 import com.google.cloudbuild.v1.CreateWorkerPoolOperationMetadata; 42 import com.google.cloudbuild.v1.CreateWorkerPoolRequest; 43 import com.google.cloudbuild.v1.DeleteBuildTriggerRequest; 44 import com.google.cloudbuild.v1.DeleteWorkerPoolOperationMetadata; 45 import com.google.cloudbuild.v1.DeleteWorkerPoolRequest; 46 import com.google.cloudbuild.v1.GetBuildRequest; 47 import com.google.cloudbuild.v1.GetBuildTriggerRequest; 48 import com.google.cloudbuild.v1.GetWorkerPoolRequest; 49 import com.google.cloudbuild.v1.ListBuildTriggersRequest; 50 import com.google.cloudbuild.v1.ListBuildTriggersResponse; 51 import com.google.cloudbuild.v1.ListBuildsRequest; 52 import com.google.cloudbuild.v1.ListBuildsResponse; 53 import com.google.cloudbuild.v1.ListWorkerPoolsRequest; 54 import com.google.cloudbuild.v1.ListWorkerPoolsResponse; 55 import com.google.cloudbuild.v1.LocationName; 56 import com.google.cloudbuild.v1.ReceiveTriggerWebhookRequest; 57 import com.google.cloudbuild.v1.ReceiveTriggerWebhookResponse; 58 import com.google.cloudbuild.v1.RepoSource; 59 import com.google.cloudbuild.v1.RetryBuildRequest; 60 import com.google.cloudbuild.v1.RunBuildTriggerRequest; 61 import com.google.cloudbuild.v1.UpdateBuildTriggerRequest; 62 import com.google.cloudbuild.v1.UpdateWorkerPoolOperationMetadata; 63 import com.google.cloudbuild.v1.UpdateWorkerPoolRequest; 64 import com.google.cloudbuild.v1.WorkerPool; 65 import com.google.cloudbuild.v1.WorkerPoolName; 66 import com.google.common.util.concurrent.MoreExecutors; 67 import com.google.longrunning.Operation; 68 import com.google.protobuf.Empty; 69 import com.google.protobuf.FieldMask; 70 import java.io.IOException; 71 import java.util.List; 72 import java.util.concurrent.TimeUnit; 73 import javax.annotation.Generated; 74 75 // AUTO-GENERATED DOCUMENTATION AND CLASS. 76 /** 77 * Service Description: Creates and manages builds on Google Cloud Platform. 78 * 79 * <p>The main concept used by this API is a `Build`, which describes the location of the source to 80 * build, how to build the source, and where to store the built artifacts, if any. 81 * 82 * <p>A user can list previously-requested builds or get builds by their ID to determine the status 83 * of the build. 84 * 85 * <p>This class provides the ability to make remote calls to the backing service through method 86 * calls that map to API methods. Sample code to get started: 87 * 88 * <pre>{@code 89 * // This snippet has been automatically generated and should be regarded as a code template only. 90 * // It will require modifications to work: 91 * // - It may require correct/in-range values for request initialization. 92 * // - It may require specifying regional endpoints when creating the service client as shown in 93 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 94 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 95 * String projectId = "projectId-894832108"; 96 * String id = "id3355"; 97 * Build response = cloudBuildClient.getBuild(projectId, id); 98 * } 99 * }</pre> 100 * 101 * <p>Note: close() needs to be called on the CloudBuildClient object to clean up resources such as 102 * threads. In the example above, try-with-resources is used, which automatically calls close(). 103 * 104 * <p>The surface of this class includes several types of Java methods for each of the API's 105 * methods: 106 * 107 * <ol> 108 * <li>A "flattened" method. With this type of method, the fields of the request type have been 109 * converted into function parameters. It may be the case that not all fields are available as 110 * parameters, and not every API method will have a flattened method entry point. 111 * <li>A "request object" method. This type of method only takes one parameter, a request object, 112 * which must be constructed before the call. Not every API method will have a request object 113 * method. 114 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 115 * callable object, which can be used to initiate calls to the service. 116 * </ol> 117 * 118 * <p>See the individual methods for example code. 119 * 120 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 121 * these names, this class includes a format method for each type of name, and additionally a parse 122 * method to extract the individual identifiers contained within names that are returned. 123 * 124 * <p>This class can be customized by passing in a custom instance of CloudBuildSettings to 125 * create(). For example: 126 * 127 * <p>To customize credentials: 128 * 129 * <pre>{@code 130 * // This snippet has been automatically generated and should be regarded as a code template only. 131 * // It will require modifications to work: 132 * // - It may require correct/in-range values for request initialization. 133 * // - It may require specifying regional endpoints when creating the service client as shown in 134 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 135 * CloudBuildSettings cloudBuildSettings = 136 * CloudBuildSettings.newBuilder() 137 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 138 * .build(); 139 * CloudBuildClient cloudBuildClient = CloudBuildClient.create(cloudBuildSettings); 140 * }</pre> 141 * 142 * <p>To customize the endpoint: 143 * 144 * <pre>{@code 145 * // This snippet has been automatically generated and should be regarded as a code template only. 146 * // It will require modifications to work: 147 * // - It may require correct/in-range values for request initialization. 148 * // - It may require specifying regional endpoints when creating the service client as shown in 149 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 150 * CloudBuildSettings cloudBuildSettings = 151 * CloudBuildSettings.newBuilder().setEndpoint(myEndpoint).build(); 152 * CloudBuildClient cloudBuildClient = CloudBuildClient.create(cloudBuildSettings); 153 * }</pre> 154 * 155 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 156 * the wire: 157 * 158 * <pre>{@code 159 * // This snippet has been automatically generated and should be regarded as a code template only. 160 * // It will require modifications to work: 161 * // - It may require correct/in-range values for request initialization. 162 * // - It may require specifying regional endpoints when creating the service client as shown in 163 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 164 * CloudBuildSettings cloudBuildSettings = CloudBuildSettings.newHttpJsonBuilder().build(); 165 * CloudBuildClient cloudBuildClient = CloudBuildClient.create(cloudBuildSettings); 166 * }</pre> 167 * 168 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 169 */ 170 @Generated("by gapic-generator-java") 171 public class CloudBuildClient implements BackgroundResource { 172 private final CloudBuildSettings settings; 173 private final CloudBuildStub stub; 174 private final OperationsClient httpJsonOperationsClient; 175 private final com.google.longrunning.OperationsClient operationsClient; 176 177 /** Constructs an instance of CloudBuildClient with default settings. */ create()178 public static final CloudBuildClient create() throws IOException { 179 return create(CloudBuildSettings.newBuilder().build()); 180 } 181 182 /** 183 * Constructs an instance of CloudBuildClient, using the given settings. The channels are created 184 * based on the settings passed in, or defaults for any settings that are not set. 185 */ create(CloudBuildSettings settings)186 public static final CloudBuildClient create(CloudBuildSettings settings) throws IOException { 187 return new CloudBuildClient(settings); 188 } 189 190 /** 191 * Constructs an instance of CloudBuildClient, using the given stub for making calls. This is for 192 * advanced usage - prefer using create(CloudBuildSettings). 193 */ create(CloudBuildStub stub)194 public static final CloudBuildClient create(CloudBuildStub stub) { 195 return new CloudBuildClient(stub); 196 } 197 198 /** 199 * Constructs an instance of CloudBuildClient, using the given settings. This is protected so that 200 * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. 201 */ CloudBuildClient(CloudBuildSettings settings)202 protected CloudBuildClient(CloudBuildSettings settings) throws IOException { 203 this.settings = settings; 204 this.stub = ((CloudBuildStubSettings) settings.getStubSettings()).createStub(); 205 this.operationsClient = 206 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 207 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 208 } 209 CloudBuildClient(CloudBuildStub stub)210 protected CloudBuildClient(CloudBuildStub stub) { 211 this.settings = null; 212 this.stub = stub; 213 this.operationsClient = 214 com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); 215 this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); 216 } 217 getSettings()218 public final CloudBuildSettings getSettings() { 219 return settings; 220 } 221 getStub()222 public CloudBuildStub getStub() { 223 return stub; 224 } 225 226 /** 227 * Returns the OperationsClient that can be used to query the status of a long-running operation 228 * returned by another API method call. 229 */ getOperationsClient()230 public final com.google.longrunning.OperationsClient getOperationsClient() { 231 return operationsClient; 232 } 233 234 /** 235 * Returns the OperationsClient that can be used to query the status of a long-running operation 236 * returned by another API method call. 237 */ 238 @BetaApi getHttpJsonOperationsClient()239 public final OperationsClient getHttpJsonOperationsClient() { 240 return httpJsonOperationsClient; 241 } 242 243 // AUTO-GENERATED DOCUMENTATION AND METHOD. 244 /** 245 * Starts a build with the specified configuration. 246 * 247 * <p>This method returns a long-running `Operation`, which includes the build ID. Pass the build 248 * ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`). 249 * 250 * <p>Sample code: 251 * 252 * <pre>{@code 253 * // This snippet has been automatically generated and should be regarded as a code template only. 254 * // It will require modifications to work: 255 * // - It may require correct/in-range values for request initialization. 256 * // - It may require specifying regional endpoints when creating the service client as shown in 257 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 258 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 259 * String projectId = "projectId-894832108"; 260 * Build build = Build.newBuilder().build(); 261 * Build response = cloudBuildClient.createBuildAsync(projectId, build).get(); 262 * } 263 * }</pre> 264 * 265 * @param projectId Required. ID of the project. 266 * @param build Required. Build resource to create. 267 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 268 */ createBuildAsync( String projectId, Build build)269 public final OperationFuture<Build, BuildOperationMetadata> createBuildAsync( 270 String projectId, Build build) { 271 CreateBuildRequest request = 272 CreateBuildRequest.newBuilder().setProjectId(projectId).setBuild(build).build(); 273 return createBuildAsync(request); 274 } 275 276 // AUTO-GENERATED DOCUMENTATION AND METHOD. 277 /** 278 * Starts a build with the specified configuration. 279 * 280 * <p>This method returns a long-running `Operation`, which includes the build ID. Pass the build 281 * ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`). 282 * 283 * <p>Sample code: 284 * 285 * <pre>{@code 286 * // This snippet has been automatically generated and should be regarded as a code template only. 287 * // It will require modifications to work: 288 * // - It may require correct/in-range values for request initialization. 289 * // - It may require specifying regional endpoints when creating the service client as shown in 290 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 291 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 292 * CreateBuildRequest request = 293 * CreateBuildRequest.newBuilder() 294 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 295 * .setProjectId("projectId-894832108") 296 * .setBuild(Build.newBuilder().build()) 297 * .build(); 298 * Build response = cloudBuildClient.createBuildAsync(request).get(); 299 * } 300 * }</pre> 301 * 302 * @param request The request object containing all of the parameters for the API call. 303 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 304 */ createBuildAsync( CreateBuildRequest request)305 public final OperationFuture<Build, BuildOperationMetadata> createBuildAsync( 306 CreateBuildRequest request) { 307 return createBuildOperationCallable().futureCall(request); 308 } 309 310 // AUTO-GENERATED DOCUMENTATION AND METHOD. 311 /** 312 * Starts a build with the specified configuration. 313 * 314 * <p>This method returns a long-running `Operation`, which includes the build ID. Pass the build 315 * ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`). 316 * 317 * <p>Sample code: 318 * 319 * <pre>{@code 320 * // This snippet has been automatically generated and should be regarded as a code template only. 321 * // It will require modifications to work: 322 * // - It may require correct/in-range values for request initialization. 323 * // - It may require specifying regional endpoints when creating the service client as shown in 324 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 325 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 326 * CreateBuildRequest request = 327 * CreateBuildRequest.newBuilder() 328 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 329 * .setProjectId("projectId-894832108") 330 * .setBuild(Build.newBuilder().build()) 331 * .build(); 332 * OperationFuture<Build, BuildOperationMetadata> future = 333 * cloudBuildClient.createBuildOperationCallable().futureCall(request); 334 * // Do something. 335 * Build response = future.get(); 336 * } 337 * }</pre> 338 */ 339 public final OperationCallable<CreateBuildRequest, Build, BuildOperationMetadata> createBuildOperationCallable()340 createBuildOperationCallable() { 341 return stub.createBuildOperationCallable(); 342 } 343 344 // AUTO-GENERATED DOCUMENTATION AND METHOD. 345 /** 346 * Starts a build with the specified configuration. 347 * 348 * <p>This method returns a long-running `Operation`, which includes the build ID. Pass the build 349 * ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`). 350 * 351 * <p>Sample code: 352 * 353 * <pre>{@code 354 * // This snippet has been automatically generated and should be regarded as a code template only. 355 * // It will require modifications to work: 356 * // - It may require correct/in-range values for request initialization. 357 * // - It may require specifying regional endpoints when creating the service client as shown in 358 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 359 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 360 * CreateBuildRequest request = 361 * CreateBuildRequest.newBuilder() 362 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 363 * .setProjectId("projectId-894832108") 364 * .setBuild(Build.newBuilder().build()) 365 * .build(); 366 * ApiFuture<Operation> future = cloudBuildClient.createBuildCallable().futureCall(request); 367 * // Do something. 368 * Operation response = future.get(); 369 * } 370 * }</pre> 371 */ createBuildCallable()372 public final UnaryCallable<CreateBuildRequest, Operation> createBuildCallable() { 373 return stub.createBuildCallable(); 374 } 375 376 // AUTO-GENERATED DOCUMENTATION AND METHOD. 377 /** 378 * Returns information about a previously requested build. 379 * 380 * <p>The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or 381 * `WORKING`), and timing information. 382 * 383 * <p>Sample code: 384 * 385 * <pre>{@code 386 * // This snippet has been automatically generated and should be regarded as a code template only. 387 * // It will require modifications to work: 388 * // - It may require correct/in-range values for request initialization. 389 * // - It may require specifying regional endpoints when creating the service client as shown in 390 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 391 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 392 * String projectId = "projectId-894832108"; 393 * String id = "id3355"; 394 * Build response = cloudBuildClient.getBuild(projectId, id); 395 * } 396 * }</pre> 397 * 398 * @param projectId Required. ID of the project. 399 * @param id Required. ID of the build. 400 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 401 */ getBuild(String projectId, String id)402 public final Build getBuild(String projectId, String id) { 403 GetBuildRequest request = 404 GetBuildRequest.newBuilder().setProjectId(projectId).setId(id).build(); 405 return getBuild(request); 406 } 407 408 // AUTO-GENERATED DOCUMENTATION AND METHOD. 409 /** 410 * Returns information about a previously requested build. 411 * 412 * <p>The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or 413 * `WORKING`), and timing information. 414 * 415 * <p>Sample code: 416 * 417 * <pre>{@code 418 * // This snippet has been automatically generated and should be regarded as a code template only. 419 * // It will require modifications to work: 420 * // - It may require correct/in-range values for request initialization. 421 * // - It may require specifying regional endpoints when creating the service client as shown in 422 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 423 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 424 * GetBuildRequest request = 425 * GetBuildRequest.newBuilder() 426 * .setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString()) 427 * .setProjectId("projectId-894832108") 428 * .setId("id3355") 429 * .build(); 430 * Build response = cloudBuildClient.getBuild(request); 431 * } 432 * }</pre> 433 * 434 * @param request The request object containing all of the parameters for the API call. 435 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 436 */ getBuild(GetBuildRequest request)437 public final Build getBuild(GetBuildRequest request) { 438 return getBuildCallable().call(request); 439 } 440 441 // AUTO-GENERATED DOCUMENTATION AND METHOD. 442 /** 443 * Returns information about a previously requested build. 444 * 445 * <p>The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or 446 * `WORKING`), and timing information. 447 * 448 * <p>Sample code: 449 * 450 * <pre>{@code 451 * // This snippet has been automatically generated and should be regarded as a code template only. 452 * // It will require modifications to work: 453 * // - It may require correct/in-range values for request initialization. 454 * // - It may require specifying regional endpoints when creating the service client as shown in 455 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 456 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 457 * GetBuildRequest request = 458 * GetBuildRequest.newBuilder() 459 * .setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString()) 460 * .setProjectId("projectId-894832108") 461 * .setId("id3355") 462 * .build(); 463 * ApiFuture<Build> future = cloudBuildClient.getBuildCallable().futureCall(request); 464 * // Do something. 465 * Build response = future.get(); 466 * } 467 * }</pre> 468 */ getBuildCallable()469 public final UnaryCallable<GetBuildRequest, Build> getBuildCallable() { 470 return stub.getBuildCallable(); 471 } 472 473 // AUTO-GENERATED DOCUMENTATION AND METHOD. 474 /** 475 * Lists previously requested builds. 476 * 477 * <p>Previously requested builds may still be in-progress, or may have finished successfully or 478 * unsuccessfully. 479 * 480 * <p>Sample code: 481 * 482 * <pre>{@code 483 * // This snippet has been automatically generated and should be regarded as a code template only. 484 * // It will require modifications to work: 485 * // - It may require correct/in-range values for request initialization. 486 * // - It may require specifying regional endpoints when creating the service client as shown in 487 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 488 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 489 * String projectId = "projectId-894832108"; 490 * String filter = "filter-1274492040"; 491 * for (Build element : cloudBuildClient.listBuilds(projectId, filter).iterateAll()) { 492 * // doThingsWith(element); 493 * } 494 * } 495 * }</pre> 496 * 497 * @param projectId Required. ID of the project. 498 * @param filter The raw filter text to constrain the results. 499 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 500 */ listBuilds(String projectId, String filter)501 public final ListBuildsPagedResponse listBuilds(String projectId, String filter) { 502 ListBuildsRequest request = 503 ListBuildsRequest.newBuilder().setProjectId(projectId).setFilter(filter).build(); 504 return listBuilds(request); 505 } 506 507 // AUTO-GENERATED DOCUMENTATION AND METHOD. 508 /** 509 * Lists previously requested builds. 510 * 511 * <p>Previously requested builds may still be in-progress, or may have finished successfully or 512 * unsuccessfully. 513 * 514 * <p>Sample code: 515 * 516 * <pre>{@code 517 * // This snippet has been automatically generated and should be regarded as a code template only. 518 * // It will require modifications to work: 519 * // - It may require correct/in-range values for request initialization. 520 * // - It may require specifying regional endpoints when creating the service client as shown in 521 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 522 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 523 * ListBuildsRequest request = 524 * ListBuildsRequest.newBuilder() 525 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 526 * .setProjectId("projectId-894832108") 527 * .setPageSize(883849137) 528 * .setPageToken("pageToken873572522") 529 * .setFilter("filter-1274492040") 530 * .build(); 531 * for (Build element : cloudBuildClient.listBuilds(request).iterateAll()) { 532 * // doThingsWith(element); 533 * } 534 * } 535 * }</pre> 536 * 537 * @param request The request object containing all of the parameters for the API call. 538 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 539 */ listBuilds(ListBuildsRequest request)540 public final ListBuildsPagedResponse listBuilds(ListBuildsRequest request) { 541 return listBuildsPagedCallable().call(request); 542 } 543 544 // AUTO-GENERATED DOCUMENTATION AND METHOD. 545 /** 546 * Lists previously requested builds. 547 * 548 * <p>Previously requested builds may still be in-progress, or may have finished successfully or 549 * unsuccessfully. 550 * 551 * <p>Sample code: 552 * 553 * <pre>{@code 554 * // This snippet has been automatically generated and should be regarded as a code template only. 555 * // It will require modifications to work: 556 * // - It may require correct/in-range values for request initialization. 557 * // - It may require specifying regional endpoints when creating the service client as shown in 558 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 559 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 560 * ListBuildsRequest request = 561 * ListBuildsRequest.newBuilder() 562 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 563 * .setProjectId("projectId-894832108") 564 * .setPageSize(883849137) 565 * .setPageToken("pageToken873572522") 566 * .setFilter("filter-1274492040") 567 * .build(); 568 * ApiFuture<Build> future = cloudBuildClient.listBuildsPagedCallable().futureCall(request); 569 * // Do something. 570 * for (Build element : future.get().iterateAll()) { 571 * // doThingsWith(element); 572 * } 573 * } 574 * }</pre> 575 */ listBuildsPagedCallable()576 public final UnaryCallable<ListBuildsRequest, ListBuildsPagedResponse> listBuildsPagedCallable() { 577 return stub.listBuildsPagedCallable(); 578 } 579 580 // AUTO-GENERATED DOCUMENTATION AND METHOD. 581 /** 582 * Lists previously requested builds. 583 * 584 * <p>Previously requested builds may still be in-progress, or may have finished successfully or 585 * unsuccessfully. 586 * 587 * <p>Sample code: 588 * 589 * <pre>{@code 590 * // This snippet has been automatically generated and should be regarded as a code template only. 591 * // It will require modifications to work: 592 * // - It may require correct/in-range values for request initialization. 593 * // - It may require specifying regional endpoints when creating the service client as shown in 594 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 595 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 596 * ListBuildsRequest request = 597 * ListBuildsRequest.newBuilder() 598 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 599 * .setProjectId("projectId-894832108") 600 * .setPageSize(883849137) 601 * .setPageToken("pageToken873572522") 602 * .setFilter("filter-1274492040") 603 * .build(); 604 * while (true) { 605 * ListBuildsResponse response = cloudBuildClient.listBuildsCallable().call(request); 606 * for (Build element : response.getBuildsList()) { 607 * // doThingsWith(element); 608 * } 609 * String nextPageToken = response.getNextPageToken(); 610 * if (!Strings.isNullOrEmpty(nextPageToken)) { 611 * request = request.toBuilder().setPageToken(nextPageToken).build(); 612 * } else { 613 * break; 614 * } 615 * } 616 * } 617 * }</pre> 618 */ listBuildsCallable()619 public final UnaryCallable<ListBuildsRequest, ListBuildsResponse> listBuildsCallable() { 620 return stub.listBuildsCallable(); 621 } 622 623 // AUTO-GENERATED DOCUMENTATION AND METHOD. 624 /** 625 * Cancels a build in progress. 626 * 627 * <p>Sample code: 628 * 629 * <pre>{@code 630 * // This snippet has been automatically generated and should be regarded as a code template only. 631 * // It will require modifications to work: 632 * // - It may require correct/in-range values for request initialization. 633 * // - It may require specifying regional endpoints when creating the service client as shown in 634 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 635 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 636 * String projectId = "projectId-894832108"; 637 * String id = "id3355"; 638 * Build response = cloudBuildClient.cancelBuild(projectId, id); 639 * } 640 * }</pre> 641 * 642 * @param projectId Required. ID of the project. 643 * @param id Required. ID of the build. 644 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 645 */ cancelBuild(String projectId, String id)646 public final Build cancelBuild(String projectId, String id) { 647 CancelBuildRequest request = 648 CancelBuildRequest.newBuilder().setProjectId(projectId).setId(id).build(); 649 return cancelBuild(request); 650 } 651 652 // AUTO-GENERATED DOCUMENTATION AND METHOD. 653 /** 654 * Cancels a build in progress. 655 * 656 * <p>Sample code: 657 * 658 * <pre>{@code 659 * // This snippet has been automatically generated and should be regarded as a code template only. 660 * // It will require modifications to work: 661 * // - It may require correct/in-range values for request initialization. 662 * // - It may require specifying regional endpoints when creating the service client as shown in 663 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 664 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 665 * CancelBuildRequest request = 666 * CancelBuildRequest.newBuilder() 667 * .setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString()) 668 * .setProjectId("projectId-894832108") 669 * .setId("id3355") 670 * .build(); 671 * Build response = cloudBuildClient.cancelBuild(request); 672 * } 673 * }</pre> 674 * 675 * @param request The request object containing all of the parameters for the API call. 676 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 677 */ cancelBuild(CancelBuildRequest request)678 public final Build cancelBuild(CancelBuildRequest request) { 679 return cancelBuildCallable().call(request); 680 } 681 682 // AUTO-GENERATED DOCUMENTATION AND METHOD. 683 /** 684 * Cancels a build in progress. 685 * 686 * <p>Sample code: 687 * 688 * <pre>{@code 689 * // This snippet has been automatically generated and should be regarded as a code template only. 690 * // It will require modifications to work: 691 * // - It may require correct/in-range values for request initialization. 692 * // - It may require specifying regional endpoints when creating the service client as shown in 693 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 694 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 695 * CancelBuildRequest request = 696 * CancelBuildRequest.newBuilder() 697 * .setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString()) 698 * .setProjectId("projectId-894832108") 699 * .setId("id3355") 700 * .build(); 701 * ApiFuture<Build> future = cloudBuildClient.cancelBuildCallable().futureCall(request); 702 * // Do something. 703 * Build response = future.get(); 704 * } 705 * }</pre> 706 */ cancelBuildCallable()707 public final UnaryCallable<CancelBuildRequest, Build> cancelBuildCallable() { 708 return stub.cancelBuildCallable(); 709 } 710 711 // AUTO-GENERATED DOCUMENTATION AND METHOD. 712 /** 713 * Creates a new build based on the specified build. 714 * 715 * <p>This method creates a new build using the original build request, which may or may not 716 * result in an identical build. 717 * 718 * <p>For triggered builds: 719 * 720 * <ul> 721 * <li>Triggered builds resolve to a precise revision; therefore a retry of a triggered build 722 * will result in a build that uses the same revision. 723 * </ul> 724 * 725 * <p>For non-triggered builds that specify `RepoSource`: 726 * 727 * <ul> 728 * <li>If the original build built from the tip of a branch, the retried build will build from 729 * the tip of that branch, which may not be the same revision as the original build. 730 * <li>If the original build specified a commit sha or revision ID, the retried build will use 731 * the identical source. 732 * </ul> 733 * 734 * <p>For builds that specify `StorageSource`: 735 * 736 * <ul> 737 * <li>If the original build pulled source from Google Cloud Storage without specifying the 738 * generation of the object, the new build will use the current object, which may be 739 * different from the original build source. 740 * <li>If the original build pulled source from Cloud Storage and specified the generation of 741 * the object, the new build will attempt to use the same object, which may or may not be 742 * available depending on the bucket's lifecycle management settings. 743 * </ul> 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 754 * String projectId = "projectId-894832108"; 755 * String id = "id3355"; 756 * Build response = cloudBuildClient.retryBuildAsync(projectId, id).get(); 757 * } 758 * }</pre> 759 * 760 * @param projectId Required. ID of the project. 761 * @param id Required. Build ID of the original build. 762 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 763 */ retryBuildAsync( String projectId, String id)764 public final OperationFuture<Build, BuildOperationMetadata> retryBuildAsync( 765 String projectId, String id) { 766 RetryBuildRequest request = 767 RetryBuildRequest.newBuilder().setProjectId(projectId).setId(id).build(); 768 return retryBuildAsync(request); 769 } 770 771 // AUTO-GENERATED DOCUMENTATION AND METHOD. 772 /** 773 * Creates a new build based on the specified build. 774 * 775 * <p>This method creates a new build using the original build request, which may or may not 776 * result in an identical build. 777 * 778 * <p>For triggered builds: 779 * 780 * <ul> 781 * <li>Triggered builds resolve to a precise revision; therefore a retry of a triggered build 782 * will result in a build that uses the same revision. 783 * </ul> 784 * 785 * <p>For non-triggered builds that specify `RepoSource`: 786 * 787 * <ul> 788 * <li>If the original build built from the tip of a branch, the retried build will build from 789 * the tip of that branch, which may not be the same revision as the original build. 790 * <li>If the original build specified a commit sha or revision ID, the retried build will use 791 * the identical source. 792 * </ul> 793 * 794 * <p>For builds that specify `StorageSource`: 795 * 796 * <ul> 797 * <li>If the original build pulled source from Google Cloud Storage without specifying the 798 * generation of the object, the new build will use the current object, which may be 799 * different from the original build source. 800 * <li>If the original build pulled source from Cloud Storage and specified the generation of 801 * the object, the new build will attempt to use the same object, which may or may not be 802 * available depending on the bucket's lifecycle management settings. 803 * </ul> 804 * 805 * <p>Sample code: 806 * 807 * <pre>{@code 808 * // This snippet has been automatically generated and should be regarded as a code template only. 809 * // It will require modifications to work: 810 * // - It may require correct/in-range values for request initialization. 811 * // - It may require specifying regional endpoints when creating the service client as shown in 812 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 813 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 814 * RetryBuildRequest request = 815 * RetryBuildRequest.newBuilder() 816 * .setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString()) 817 * .setProjectId("projectId-894832108") 818 * .setId("id3355") 819 * .build(); 820 * Build response = cloudBuildClient.retryBuildAsync(request).get(); 821 * } 822 * }</pre> 823 * 824 * @param request The request object containing all of the parameters for the API call. 825 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 826 */ retryBuildAsync( RetryBuildRequest request)827 public final OperationFuture<Build, BuildOperationMetadata> retryBuildAsync( 828 RetryBuildRequest request) { 829 return retryBuildOperationCallable().futureCall(request); 830 } 831 832 // AUTO-GENERATED DOCUMENTATION AND METHOD. 833 /** 834 * Creates a new build based on the specified build. 835 * 836 * <p>This method creates a new build using the original build request, which may or may not 837 * result in an identical build. 838 * 839 * <p>For triggered builds: 840 * 841 * <ul> 842 * <li>Triggered builds resolve to a precise revision; therefore a retry of a triggered build 843 * will result in a build that uses the same revision. 844 * </ul> 845 * 846 * <p>For non-triggered builds that specify `RepoSource`: 847 * 848 * <ul> 849 * <li>If the original build built from the tip of a branch, the retried build will build from 850 * the tip of that branch, which may not be the same revision as the original build. 851 * <li>If the original build specified a commit sha or revision ID, the retried build will use 852 * the identical source. 853 * </ul> 854 * 855 * <p>For builds that specify `StorageSource`: 856 * 857 * <ul> 858 * <li>If the original build pulled source from Google Cloud Storage without specifying the 859 * generation of the object, the new build will use the current object, which may be 860 * different from the original build source. 861 * <li>If the original build pulled source from Cloud Storage and specified the generation of 862 * the object, the new build will attempt to use the same object, which may or may not be 863 * available depending on the bucket's lifecycle management settings. 864 * </ul> 865 * 866 * <p>Sample code: 867 * 868 * <pre>{@code 869 * // This snippet has been automatically generated and should be regarded as a code template only. 870 * // It will require modifications to work: 871 * // - It may require correct/in-range values for request initialization. 872 * // - It may require specifying regional endpoints when creating the service client as shown in 873 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 874 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 875 * RetryBuildRequest request = 876 * RetryBuildRequest.newBuilder() 877 * .setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString()) 878 * .setProjectId("projectId-894832108") 879 * .setId("id3355") 880 * .build(); 881 * OperationFuture<Build, BuildOperationMetadata> future = 882 * cloudBuildClient.retryBuildOperationCallable().futureCall(request); 883 * // Do something. 884 * Build response = future.get(); 885 * } 886 * }</pre> 887 */ 888 public final OperationCallable<RetryBuildRequest, Build, BuildOperationMetadata> retryBuildOperationCallable()889 retryBuildOperationCallable() { 890 return stub.retryBuildOperationCallable(); 891 } 892 893 // AUTO-GENERATED DOCUMENTATION AND METHOD. 894 /** 895 * Creates a new build based on the specified build. 896 * 897 * <p>This method creates a new build using the original build request, which may or may not 898 * result in an identical build. 899 * 900 * <p>For triggered builds: 901 * 902 * <ul> 903 * <li>Triggered builds resolve to a precise revision; therefore a retry of a triggered build 904 * will result in a build that uses the same revision. 905 * </ul> 906 * 907 * <p>For non-triggered builds that specify `RepoSource`: 908 * 909 * <ul> 910 * <li>If the original build built from the tip of a branch, the retried build will build from 911 * the tip of that branch, which may not be the same revision as the original build. 912 * <li>If the original build specified a commit sha or revision ID, the retried build will use 913 * the identical source. 914 * </ul> 915 * 916 * <p>For builds that specify `StorageSource`: 917 * 918 * <ul> 919 * <li>If the original build pulled source from Google Cloud Storage without specifying the 920 * generation of the object, the new build will use the current object, which may be 921 * different from the original build source. 922 * <li>If the original build pulled source from Cloud Storage and specified the generation of 923 * the object, the new build will attempt to use the same object, which may or may not be 924 * available depending on the bucket's lifecycle management settings. 925 * </ul> 926 * 927 * <p>Sample code: 928 * 929 * <pre>{@code 930 * // This snippet has been automatically generated and should be regarded as a code template only. 931 * // It will require modifications to work: 932 * // - It may require correct/in-range values for request initialization. 933 * // - It may require specifying regional endpoints when creating the service client as shown in 934 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 935 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 936 * RetryBuildRequest request = 937 * RetryBuildRequest.newBuilder() 938 * .setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString()) 939 * .setProjectId("projectId-894832108") 940 * .setId("id3355") 941 * .build(); 942 * ApiFuture<Operation> future = cloudBuildClient.retryBuildCallable().futureCall(request); 943 * // Do something. 944 * Operation response = future.get(); 945 * } 946 * }</pre> 947 */ retryBuildCallable()948 public final UnaryCallable<RetryBuildRequest, Operation> retryBuildCallable() { 949 return stub.retryBuildCallable(); 950 } 951 952 // AUTO-GENERATED DOCUMENTATION AND METHOD. 953 /** 954 * Approves or rejects a pending build. 955 * 956 * <p>If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. 957 * 958 * <p>If rejected, the returned LRO will be immediately done. 959 * 960 * <p>Sample code: 961 * 962 * <pre>{@code 963 * // This snippet has been automatically generated and should be regarded as a code template only. 964 * // It will require modifications to work: 965 * // - It may require correct/in-range values for request initialization. 966 * // - It may require specifying regional endpoints when creating the service client as shown in 967 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 968 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 969 * String name = "name3373707"; 970 * ApprovalResult approvalResult = ApprovalResult.newBuilder().build(); 971 * Build response = cloudBuildClient.approveBuildAsync(name, approvalResult).get(); 972 * } 973 * }</pre> 974 * 975 * @param name Required. Name of the target build. For example: 976 * "projects/{$project_id}/builds/{$build_id}" 977 * @param approvalResult Approval decision and metadata. 978 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 979 */ approveBuildAsync( String name, ApprovalResult approvalResult)980 public final OperationFuture<Build, BuildOperationMetadata> approveBuildAsync( 981 String name, ApprovalResult approvalResult) { 982 ApproveBuildRequest request = 983 ApproveBuildRequest.newBuilder().setName(name).setApprovalResult(approvalResult).build(); 984 return approveBuildAsync(request); 985 } 986 987 // AUTO-GENERATED DOCUMENTATION AND METHOD. 988 /** 989 * Approves or rejects a pending build. 990 * 991 * <p>If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. 992 * 993 * <p>If rejected, the returned LRO will be immediately done. 994 * 995 * <p>Sample code: 996 * 997 * <pre>{@code 998 * // This snippet has been automatically generated and should be regarded as a code template only. 999 * // It will require modifications to work: 1000 * // - It may require correct/in-range values for request initialization. 1001 * // - It may require specifying regional endpoints when creating the service client as shown in 1002 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1003 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1004 * ApproveBuildRequest request = 1005 * ApproveBuildRequest.newBuilder() 1006 * .setName("name3373707") 1007 * .setApprovalResult(ApprovalResult.newBuilder().build()) 1008 * .build(); 1009 * Build response = cloudBuildClient.approveBuildAsync(request).get(); 1010 * } 1011 * }</pre> 1012 * 1013 * @param request The request object containing all of the parameters for the API call. 1014 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1015 */ approveBuildAsync( ApproveBuildRequest request)1016 public final OperationFuture<Build, BuildOperationMetadata> approveBuildAsync( 1017 ApproveBuildRequest request) { 1018 return approveBuildOperationCallable().futureCall(request); 1019 } 1020 1021 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1022 /** 1023 * Approves or rejects a pending build. 1024 * 1025 * <p>If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. 1026 * 1027 * <p>If rejected, the returned LRO will be immediately done. 1028 * 1029 * <p>Sample code: 1030 * 1031 * <pre>{@code 1032 * // This snippet has been automatically generated and should be regarded as a code template only. 1033 * // It will require modifications to work: 1034 * // - It may require correct/in-range values for request initialization. 1035 * // - It may require specifying regional endpoints when creating the service client as shown in 1036 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1037 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1038 * ApproveBuildRequest request = 1039 * ApproveBuildRequest.newBuilder() 1040 * .setName("name3373707") 1041 * .setApprovalResult(ApprovalResult.newBuilder().build()) 1042 * .build(); 1043 * OperationFuture<Build, BuildOperationMetadata> future = 1044 * cloudBuildClient.approveBuildOperationCallable().futureCall(request); 1045 * // Do something. 1046 * Build response = future.get(); 1047 * } 1048 * }</pre> 1049 */ 1050 public final OperationCallable<ApproveBuildRequest, Build, BuildOperationMetadata> approveBuildOperationCallable()1051 approveBuildOperationCallable() { 1052 return stub.approveBuildOperationCallable(); 1053 } 1054 1055 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1056 /** 1057 * Approves or rejects a pending build. 1058 * 1059 * <p>If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. 1060 * 1061 * <p>If rejected, the returned LRO will be immediately done. 1062 * 1063 * <p>Sample code: 1064 * 1065 * <pre>{@code 1066 * // This snippet has been automatically generated and should be regarded as a code template only. 1067 * // It will require modifications to work: 1068 * // - It may require correct/in-range values for request initialization. 1069 * // - It may require specifying regional endpoints when creating the service client as shown in 1070 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1071 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1072 * ApproveBuildRequest request = 1073 * ApproveBuildRequest.newBuilder() 1074 * .setName("name3373707") 1075 * .setApprovalResult(ApprovalResult.newBuilder().build()) 1076 * .build(); 1077 * ApiFuture<Operation> future = cloudBuildClient.approveBuildCallable().futureCall(request); 1078 * // Do something. 1079 * Operation response = future.get(); 1080 * } 1081 * }</pre> 1082 */ approveBuildCallable()1083 public final UnaryCallable<ApproveBuildRequest, Operation> approveBuildCallable() { 1084 return stub.approveBuildCallable(); 1085 } 1086 1087 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1088 /** 1089 * Creates a new `BuildTrigger`. 1090 * 1091 * <p>This API is experimental. 1092 * 1093 * <p>Sample code: 1094 * 1095 * <pre>{@code 1096 * // This snippet has been automatically generated and should be regarded as a code template only. 1097 * // It will require modifications to work: 1098 * // - It may require correct/in-range values for request initialization. 1099 * // - It may require specifying regional endpoints when creating the service client as shown in 1100 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1101 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1102 * String projectId = "projectId-894832108"; 1103 * BuildTrigger trigger = BuildTrigger.newBuilder().build(); 1104 * BuildTrigger response = cloudBuildClient.createBuildTrigger(projectId, trigger); 1105 * } 1106 * }</pre> 1107 * 1108 * @param projectId Required. ID of the project for which to configure automatic builds. 1109 * @param trigger Required. `BuildTrigger` to create. 1110 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1111 */ createBuildTrigger(String projectId, BuildTrigger trigger)1112 public final BuildTrigger createBuildTrigger(String projectId, BuildTrigger trigger) { 1113 CreateBuildTriggerRequest request = 1114 CreateBuildTriggerRequest.newBuilder().setProjectId(projectId).setTrigger(trigger).build(); 1115 return createBuildTrigger(request); 1116 } 1117 1118 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1119 /** 1120 * Creates a new `BuildTrigger`. 1121 * 1122 * <p>This API is experimental. 1123 * 1124 * <p>Sample code: 1125 * 1126 * <pre>{@code 1127 * // This snippet has been automatically generated and should be regarded as a code template only. 1128 * // It will require modifications to work: 1129 * // - It may require correct/in-range values for request initialization. 1130 * // - It may require specifying regional endpoints when creating the service client as shown in 1131 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1132 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1133 * CreateBuildTriggerRequest request = 1134 * CreateBuildTriggerRequest.newBuilder() 1135 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1136 * .setProjectId("projectId-894832108") 1137 * .setTrigger(BuildTrigger.newBuilder().build()) 1138 * .build(); 1139 * BuildTrigger response = cloudBuildClient.createBuildTrigger(request); 1140 * } 1141 * }</pre> 1142 * 1143 * @param request The request object containing all of the parameters for the API call. 1144 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1145 */ createBuildTrigger(CreateBuildTriggerRequest request)1146 public final BuildTrigger createBuildTrigger(CreateBuildTriggerRequest request) { 1147 return createBuildTriggerCallable().call(request); 1148 } 1149 1150 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1151 /** 1152 * Creates a new `BuildTrigger`. 1153 * 1154 * <p>This API is experimental. 1155 * 1156 * <p>Sample code: 1157 * 1158 * <pre>{@code 1159 * // This snippet has been automatically generated and should be regarded as a code template only. 1160 * // It will require modifications to work: 1161 * // - It may require correct/in-range values for request initialization. 1162 * // - It may require specifying regional endpoints when creating the service client as shown in 1163 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1164 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1165 * CreateBuildTriggerRequest request = 1166 * CreateBuildTriggerRequest.newBuilder() 1167 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1168 * .setProjectId("projectId-894832108") 1169 * .setTrigger(BuildTrigger.newBuilder().build()) 1170 * .build(); 1171 * ApiFuture<BuildTrigger> future = 1172 * cloudBuildClient.createBuildTriggerCallable().futureCall(request); 1173 * // Do something. 1174 * BuildTrigger response = future.get(); 1175 * } 1176 * }</pre> 1177 */ createBuildTriggerCallable()1178 public final UnaryCallable<CreateBuildTriggerRequest, BuildTrigger> createBuildTriggerCallable() { 1179 return stub.createBuildTriggerCallable(); 1180 } 1181 1182 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1183 /** 1184 * Returns information about a `BuildTrigger`. 1185 * 1186 * <p>This API is experimental. 1187 * 1188 * <p>Sample code: 1189 * 1190 * <pre>{@code 1191 * // This snippet has been automatically generated and should be regarded as a code template only. 1192 * // It will require modifications to work: 1193 * // - It may require correct/in-range values for request initialization. 1194 * // - It may require specifying regional endpoints when creating the service client as shown in 1195 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1196 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1197 * String projectId = "projectId-894832108"; 1198 * String triggerId = "triggerId-648752909"; 1199 * BuildTrigger response = cloudBuildClient.getBuildTrigger(projectId, triggerId); 1200 * } 1201 * }</pre> 1202 * 1203 * @param projectId Required. ID of the project that owns the trigger. 1204 * @param triggerId Required. Identifier (`id` or `name`) of the `BuildTrigger` to get. 1205 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1206 */ getBuildTrigger(String projectId, String triggerId)1207 public final BuildTrigger getBuildTrigger(String projectId, String triggerId) { 1208 GetBuildTriggerRequest request = 1209 GetBuildTriggerRequest.newBuilder().setProjectId(projectId).setTriggerId(triggerId).build(); 1210 return getBuildTrigger(request); 1211 } 1212 1213 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1214 /** 1215 * Returns information about a `BuildTrigger`. 1216 * 1217 * <p>This API is experimental. 1218 * 1219 * <p>Sample code: 1220 * 1221 * <pre>{@code 1222 * // This snippet has been automatically generated and should be regarded as a code template only. 1223 * // It will require modifications to work: 1224 * // - It may require correct/in-range values for request initialization. 1225 * // - It may require specifying regional endpoints when creating the service client as shown in 1226 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1227 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1228 * GetBuildTriggerRequest request = 1229 * GetBuildTriggerRequest.newBuilder() 1230 * .setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString()) 1231 * .setProjectId("projectId-894832108") 1232 * .setTriggerId("triggerId-648752909") 1233 * .build(); 1234 * BuildTrigger response = cloudBuildClient.getBuildTrigger(request); 1235 * } 1236 * }</pre> 1237 * 1238 * @param request The request object containing all of the parameters for the API call. 1239 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1240 */ getBuildTrigger(GetBuildTriggerRequest request)1241 public final BuildTrigger getBuildTrigger(GetBuildTriggerRequest request) { 1242 return getBuildTriggerCallable().call(request); 1243 } 1244 1245 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1246 /** 1247 * Returns information about a `BuildTrigger`. 1248 * 1249 * <p>This API is experimental. 1250 * 1251 * <p>Sample code: 1252 * 1253 * <pre>{@code 1254 * // This snippet has been automatically generated and should be regarded as a code template only. 1255 * // It will require modifications to work: 1256 * // - It may require correct/in-range values for request initialization. 1257 * // - It may require specifying regional endpoints when creating the service client as shown in 1258 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1259 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1260 * GetBuildTriggerRequest request = 1261 * GetBuildTriggerRequest.newBuilder() 1262 * .setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString()) 1263 * .setProjectId("projectId-894832108") 1264 * .setTriggerId("triggerId-648752909") 1265 * .build(); 1266 * ApiFuture<BuildTrigger> future = 1267 * cloudBuildClient.getBuildTriggerCallable().futureCall(request); 1268 * // Do something. 1269 * BuildTrigger response = future.get(); 1270 * } 1271 * }</pre> 1272 */ getBuildTriggerCallable()1273 public final UnaryCallable<GetBuildTriggerRequest, BuildTrigger> getBuildTriggerCallable() { 1274 return stub.getBuildTriggerCallable(); 1275 } 1276 1277 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1278 /** 1279 * Lists existing `BuildTrigger`s. 1280 * 1281 * <p>This API is experimental. 1282 * 1283 * <p>Sample code: 1284 * 1285 * <pre>{@code 1286 * // This snippet has been automatically generated and should be regarded as a code template only. 1287 * // It will require modifications to work: 1288 * // - It may require correct/in-range values for request initialization. 1289 * // - It may require specifying regional endpoints when creating the service client as shown in 1290 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1291 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1292 * String projectId = "projectId-894832108"; 1293 * for (BuildTrigger element : cloudBuildClient.listBuildTriggers(projectId).iterateAll()) { 1294 * // doThingsWith(element); 1295 * } 1296 * } 1297 * }</pre> 1298 * 1299 * @param projectId Required. ID of the project for which to list BuildTriggers. 1300 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1301 */ listBuildTriggers(String projectId)1302 public final ListBuildTriggersPagedResponse listBuildTriggers(String projectId) { 1303 ListBuildTriggersRequest request = 1304 ListBuildTriggersRequest.newBuilder().setProjectId(projectId).build(); 1305 return listBuildTriggers(request); 1306 } 1307 1308 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1309 /** 1310 * Lists existing `BuildTrigger`s. 1311 * 1312 * <p>This API is experimental. 1313 * 1314 * <p>Sample code: 1315 * 1316 * <pre>{@code 1317 * // This snippet has been automatically generated and should be regarded as a code template only. 1318 * // It will require modifications to work: 1319 * // - It may require correct/in-range values for request initialization. 1320 * // - It may require specifying regional endpoints when creating the service client as shown in 1321 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1322 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1323 * ListBuildTriggersRequest request = 1324 * ListBuildTriggersRequest.newBuilder() 1325 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1326 * .setProjectId("projectId-894832108") 1327 * .setPageSize(883849137) 1328 * .setPageToken("pageToken873572522") 1329 * .build(); 1330 * for (BuildTrigger element : cloudBuildClient.listBuildTriggers(request).iterateAll()) { 1331 * // doThingsWith(element); 1332 * } 1333 * } 1334 * }</pre> 1335 * 1336 * @param request The request object containing all of the parameters for the API call. 1337 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1338 */ listBuildTriggers(ListBuildTriggersRequest request)1339 public final ListBuildTriggersPagedResponse listBuildTriggers(ListBuildTriggersRequest request) { 1340 return listBuildTriggersPagedCallable().call(request); 1341 } 1342 1343 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1344 /** 1345 * Lists existing `BuildTrigger`s. 1346 * 1347 * <p>This API is experimental. 1348 * 1349 * <p>Sample code: 1350 * 1351 * <pre>{@code 1352 * // This snippet has been automatically generated and should be regarded as a code template only. 1353 * // It will require modifications to work: 1354 * // - It may require correct/in-range values for request initialization. 1355 * // - It may require specifying regional endpoints when creating the service client as shown in 1356 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1357 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1358 * ListBuildTriggersRequest request = 1359 * ListBuildTriggersRequest.newBuilder() 1360 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1361 * .setProjectId("projectId-894832108") 1362 * .setPageSize(883849137) 1363 * .setPageToken("pageToken873572522") 1364 * .build(); 1365 * ApiFuture<BuildTrigger> future = 1366 * cloudBuildClient.listBuildTriggersPagedCallable().futureCall(request); 1367 * // Do something. 1368 * for (BuildTrigger element : future.get().iterateAll()) { 1369 * // doThingsWith(element); 1370 * } 1371 * } 1372 * }</pre> 1373 */ 1374 public final UnaryCallable<ListBuildTriggersRequest, ListBuildTriggersPagedResponse> listBuildTriggersPagedCallable()1375 listBuildTriggersPagedCallable() { 1376 return stub.listBuildTriggersPagedCallable(); 1377 } 1378 1379 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1380 /** 1381 * Lists existing `BuildTrigger`s. 1382 * 1383 * <p>This API is experimental. 1384 * 1385 * <p>Sample code: 1386 * 1387 * <pre>{@code 1388 * // This snippet has been automatically generated and should be regarded as a code template only. 1389 * // It will require modifications to work: 1390 * // - It may require correct/in-range values for request initialization. 1391 * // - It may require specifying regional endpoints when creating the service client as shown in 1392 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1393 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1394 * ListBuildTriggersRequest request = 1395 * ListBuildTriggersRequest.newBuilder() 1396 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1397 * .setProjectId("projectId-894832108") 1398 * .setPageSize(883849137) 1399 * .setPageToken("pageToken873572522") 1400 * .build(); 1401 * while (true) { 1402 * ListBuildTriggersResponse response = 1403 * cloudBuildClient.listBuildTriggersCallable().call(request); 1404 * for (BuildTrigger element : response.getTriggersList()) { 1405 * // doThingsWith(element); 1406 * } 1407 * String nextPageToken = response.getNextPageToken(); 1408 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1409 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1410 * } else { 1411 * break; 1412 * } 1413 * } 1414 * } 1415 * }</pre> 1416 */ 1417 public final UnaryCallable<ListBuildTriggersRequest, ListBuildTriggersResponse> listBuildTriggersCallable()1418 listBuildTriggersCallable() { 1419 return stub.listBuildTriggersCallable(); 1420 } 1421 1422 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1423 /** 1424 * Deletes a `BuildTrigger` by its project ID and trigger ID. 1425 * 1426 * <p>This API is experimental. 1427 * 1428 * <p>Sample code: 1429 * 1430 * <pre>{@code 1431 * // This snippet has been automatically generated and should be regarded as a code template only. 1432 * // It will require modifications to work: 1433 * // - It may require correct/in-range values for request initialization. 1434 * // - It may require specifying regional endpoints when creating the service client as shown in 1435 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1436 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1437 * String projectId = "projectId-894832108"; 1438 * String triggerId = "triggerId-648752909"; 1439 * cloudBuildClient.deleteBuildTrigger(projectId, triggerId); 1440 * } 1441 * }</pre> 1442 * 1443 * @param projectId Required. ID of the project that owns the trigger. 1444 * @param triggerId Required. ID of the `BuildTrigger` to delete. 1445 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1446 */ deleteBuildTrigger(String projectId, String triggerId)1447 public final void deleteBuildTrigger(String projectId, String triggerId) { 1448 DeleteBuildTriggerRequest request = 1449 DeleteBuildTriggerRequest.newBuilder() 1450 .setProjectId(projectId) 1451 .setTriggerId(triggerId) 1452 .build(); 1453 deleteBuildTrigger(request); 1454 } 1455 1456 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1457 /** 1458 * Deletes a `BuildTrigger` by its project ID and trigger ID. 1459 * 1460 * <p>This API is experimental. 1461 * 1462 * <p>Sample code: 1463 * 1464 * <pre>{@code 1465 * // This snippet has been automatically generated and should be regarded as a code template only. 1466 * // It will require modifications to work: 1467 * // - It may require correct/in-range values for request initialization. 1468 * // - It may require specifying regional endpoints when creating the service client as shown in 1469 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1470 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1471 * DeleteBuildTriggerRequest request = 1472 * DeleteBuildTriggerRequest.newBuilder() 1473 * .setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString()) 1474 * .setProjectId("projectId-894832108") 1475 * .setTriggerId("triggerId-648752909") 1476 * .build(); 1477 * cloudBuildClient.deleteBuildTrigger(request); 1478 * } 1479 * }</pre> 1480 * 1481 * @param request The request object containing all of the parameters for the API call. 1482 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1483 */ deleteBuildTrigger(DeleteBuildTriggerRequest request)1484 public final void deleteBuildTrigger(DeleteBuildTriggerRequest request) { 1485 deleteBuildTriggerCallable().call(request); 1486 } 1487 1488 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1489 /** 1490 * Deletes a `BuildTrigger` by its project ID and trigger ID. 1491 * 1492 * <p>This API is experimental. 1493 * 1494 * <p>Sample code: 1495 * 1496 * <pre>{@code 1497 * // This snippet has been automatically generated and should be regarded as a code template only. 1498 * // It will require modifications to work: 1499 * // - It may require correct/in-range values for request initialization. 1500 * // - It may require specifying regional endpoints when creating the service client as shown in 1501 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1502 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1503 * DeleteBuildTriggerRequest request = 1504 * DeleteBuildTriggerRequest.newBuilder() 1505 * .setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString()) 1506 * .setProjectId("projectId-894832108") 1507 * .setTriggerId("triggerId-648752909") 1508 * .build(); 1509 * ApiFuture<Empty> future = cloudBuildClient.deleteBuildTriggerCallable().futureCall(request); 1510 * // Do something. 1511 * future.get(); 1512 * } 1513 * }</pre> 1514 */ deleteBuildTriggerCallable()1515 public final UnaryCallable<DeleteBuildTriggerRequest, Empty> deleteBuildTriggerCallable() { 1516 return stub.deleteBuildTriggerCallable(); 1517 } 1518 1519 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1520 /** 1521 * Updates a `BuildTrigger` by its project ID and trigger ID. 1522 * 1523 * <p>This API is experimental. 1524 * 1525 * <p>Sample code: 1526 * 1527 * <pre>{@code 1528 * // This snippet has been automatically generated and should be regarded as a code template only. 1529 * // It will require modifications to work: 1530 * // - It may require correct/in-range values for request initialization. 1531 * // - It may require specifying regional endpoints when creating the service client as shown in 1532 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1533 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1534 * String projectId = "projectId-894832108"; 1535 * String triggerId = "triggerId-648752909"; 1536 * BuildTrigger trigger = BuildTrigger.newBuilder().build(); 1537 * BuildTrigger response = cloudBuildClient.updateBuildTrigger(projectId, triggerId, trigger); 1538 * } 1539 * }</pre> 1540 * 1541 * @param projectId Required. ID of the project that owns the trigger. 1542 * @param triggerId Required. ID of the `BuildTrigger` to update. 1543 * @param trigger Required. `BuildTrigger` to update. 1544 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1545 */ updateBuildTrigger( String projectId, String triggerId, BuildTrigger trigger)1546 public final BuildTrigger updateBuildTrigger( 1547 String projectId, String triggerId, BuildTrigger trigger) { 1548 UpdateBuildTriggerRequest request = 1549 UpdateBuildTriggerRequest.newBuilder() 1550 .setProjectId(projectId) 1551 .setTriggerId(triggerId) 1552 .setTrigger(trigger) 1553 .build(); 1554 return updateBuildTrigger(request); 1555 } 1556 1557 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1558 /** 1559 * Updates a `BuildTrigger` by its project ID and trigger ID. 1560 * 1561 * <p>This API is experimental. 1562 * 1563 * <p>Sample code: 1564 * 1565 * <pre>{@code 1566 * // This snippet has been automatically generated and should be regarded as a code template only. 1567 * // It will require modifications to work: 1568 * // - It may require correct/in-range values for request initialization. 1569 * // - It may require specifying regional endpoints when creating the service client as shown in 1570 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1571 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1572 * UpdateBuildTriggerRequest request = 1573 * UpdateBuildTriggerRequest.newBuilder() 1574 * .setProjectId("projectId-894832108") 1575 * .setTriggerId("triggerId-648752909") 1576 * .setTrigger(BuildTrigger.newBuilder().build()) 1577 * .build(); 1578 * BuildTrigger response = cloudBuildClient.updateBuildTrigger(request); 1579 * } 1580 * }</pre> 1581 * 1582 * @param request The request object containing all of the parameters for the API call. 1583 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1584 */ updateBuildTrigger(UpdateBuildTriggerRequest request)1585 public final BuildTrigger updateBuildTrigger(UpdateBuildTriggerRequest request) { 1586 return updateBuildTriggerCallable().call(request); 1587 } 1588 1589 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1590 /** 1591 * Updates a `BuildTrigger` by its project ID and trigger ID. 1592 * 1593 * <p>This API is experimental. 1594 * 1595 * <p>Sample code: 1596 * 1597 * <pre>{@code 1598 * // This snippet has been automatically generated and should be regarded as a code template only. 1599 * // It will require modifications to work: 1600 * // - It may require correct/in-range values for request initialization. 1601 * // - It may require specifying regional endpoints when creating the service client as shown in 1602 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1603 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1604 * UpdateBuildTriggerRequest request = 1605 * UpdateBuildTriggerRequest.newBuilder() 1606 * .setProjectId("projectId-894832108") 1607 * .setTriggerId("triggerId-648752909") 1608 * .setTrigger(BuildTrigger.newBuilder().build()) 1609 * .build(); 1610 * ApiFuture<BuildTrigger> future = 1611 * cloudBuildClient.updateBuildTriggerCallable().futureCall(request); 1612 * // Do something. 1613 * BuildTrigger response = future.get(); 1614 * } 1615 * }</pre> 1616 */ updateBuildTriggerCallable()1617 public final UnaryCallable<UpdateBuildTriggerRequest, BuildTrigger> updateBuildTriggerCallable() { 1618 return stub.updateBuildTriggerCallable(); 1619 } 1620 1621 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1622 /** 1623 * Runs a `BuildTrigger` at a particular source revision. 1624 * 1625 * <p>Sample code: 1626 * 1627 * <pre>{@code 1628 * // This snippet has been automatically generated and should be regarded as a code template only. 1629 * // It will require modifications to work: 1630 * // - It may require correct/in-range values for request initialization. 1631 * // - It may require specifying regional endpoints when creating the service client as shown in 1632 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1633 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1634 * String projectId = "projectId-894832108"; 1635 * String triggerId = "triggerId-648752909"; 1636 * RepoSource source = RepoSource.newBuilder().build(); 1637 * Build response = cloudBuildClient.runBuildTriggerAsync(projectId, triggerId, source).get(); 1638 * } 1639 * }</pre> 1640 * 1641 * @param projectId Required. ID of the project. 1642 * @param triggerId Required. ID of the trigger. 1643 * @param source Source to build against this trigger. 1644 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1645 */ runBuildTriggerAsync( String projectId, String triggerId, RepoSource source)1646 public final OperationFuture<Build, BuildOperationMetadata> runBuildTriggerAsync( 1647 String projectId, String triggerId, RepoSource source) { 1648 RunBuildTriggerRequest request = 1649 RunBuildTriggerRequest.newBuilder() 1650 .setProjectId(projectId) 1651 .setTriggerId(triggerId) 1652 .setSource(source) 1653 .build(); 1654 return runBuildTriggerAsync(request); 1655 } 1656 1657 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1658 /** 1659 * Runs a `BuildTrigger` at a particular source revision. 1660 * 1661 * <p>Sample code: 1662 * 1663 * <pre>{@code 1664 * // This snippet has been automatically generated and should be regarded as a code template only. 1665 * // It will require modifications to work: 1666 * // - It may require correct/in-range values for request initialization. 1667 * // - It may require specifying regional endpoints when creating the service client as shown in 1668 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1669 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1670 * RunBuildTriggerRequest request = 1671 * RunBuildTriggerRequest.newBuilder() 1672 * .setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString()) 1673 * .setProjectId("projectId-894832108") 1674 * .setTriggerId("triggerId-648752909") 1675 * .setSource(RepoSource.newBuilder().build()) 1676 * .build(); 1677 * Build response = cloudBuildClient.runBuildTriggerAsync(request).get(); 1678 * } 1679 * }</pre> 1680 * 1681 * @param request The request object containing all of the parameters for the API call. 1682 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1683 */ runBuildTriggerAsync( RunBuildTriggerRequest request)1684 public final OperationFuture<Build, BuildOperationMetadata> runBuildTriggerAsync( 1685 RunBuildTriggerRequest request) { 1686 return runBuildTriggerOperationCallable().futureCall(request); 1687 } 1688 1689 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1690 /** 1691 * Runs a `BuildTrigger` at a particular source revision. 1692 * 1693 * <p>Sample code: 1694 * 1695 * <pre>{@code 1696 * // This snippet has been automatically generated and should be regarded as a code template only. 1697 * // It will require modifications to work: 1698 * // - It may require correct/in-range values for request initialization. 1699 * // - It may require specifying regional endpoints when creating the service client as shown in 1700 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1701 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1702 * RunBuildTriggerRequest request = 1703 * RunBuildTriggerRequest.newBuilder() 1704 * .setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString()) 1705 * .setProjectId("projectId-894832108") 1706 * .setTriggerId("triggerId-648752909") 1707 * .setSource(RepoSource.newBuilder().build()) 1708 * .build(); 1709 * OperationFuture<Build, BuildOperationMetadata> future = 1710 * cloudBuildClient.runBuildTriggerOperationCallable().futureCall(request); 1711 * // Do something. 1712 * Build response = future.get(); 1713 * } 1714 * }</pre> 1715 */ 1716 public final OperationCallable<RunBuildTriggerRequest, Build, BuildOperationMetadata> runBuildTriggerOperationCallable()1717 runBuildTriggerOperationCallable() { 1718 return stub.runBuildTriggerOperationCallable(); 1719 } 1720 1721 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1722 /** 1723 * Runs a `BuildTrigger` at a particular source revision. 1724 * 1725 * <p>Sample code: 1726 * 1727 * <pre>{@code 1728 * // This snippet has been automatically generated and should be regarded as a code template only. 1729 * // It will require modifications to work: 1730 * // - It may require correct/in-range values for request initialization. 1731 * // - It may require specifying regional endpoints when creating the service client as shown in 1732 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1733 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1734 * RunBuildTriggerRequest request = 1735 * RunBuildTriggerRequest.newBuilder() 1736 * .setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString()) 1737 * .setProjectId("projectId-894832108") 1738 * .setTriggerId("triggerId-648752909") 1739 * .setSource(RepoSource.newBuilder().build()) 1740 * .build(); 1741 * ApiFuture<Operation> future = cloudBuildClient.runBuildTriggerCallable().futureCall(request); 1742 * // Do something. 1743 * Operation response = future.get(); 1744 * } 1745 * }</pre> 1746 */ runBuildTriggerCallable()1747 public final UnaryCallable<RunBuildTriggerRequest, Operation> runBuildTriggerCallable() { 1748 return stub.runBuildTriggerCallable(); 1749 } 1750 1751 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1752 /** 1753 * ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted 1754 * at a specific trigger. 1755 * 1756 * <p>Sample code: 1757 * 1758 * <pre>{@code 1759 * // This snippet has been automatically generated and should be regarded as a code template only. 1760 * // It will require modifications to work: 1761 * // - It may require correct/in-range values for request initialization. 1762 * // - It may require specifying regional endpoints when creating the service client as shown in 1763 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1764 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1765 * ReceiveTriggerWebhookRequest request = 1766 * ReceiveTriggerWebhookRequest.newBuilder() 1767 * .setName("name3373707") 1768 * .setBody(HttpBody.newBuilder().build()) 1769 * .setProjectId("projectId-894832108") 1770 * .setTrigger("trigger-1059891784") 1771 * .setSecret("secret-906277200") 1772 * .build(); 1773 * ReceiveTriggerWebhookResponse response = cloudBuildClient.receiveTriggerWebhook(request); 1774 * } 1775 * }</pre> 1776 * 1777 * @param request The request object containing all of the parameters for the API call. 1778 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1779 */ receiveTriggerWebhook( ReceiveTriggerWebhookRequest request)1780 public final ReceiveTriggerWebhookResponse receiveTriggerWebhook( 1781 ReceiveTriggerWebhookRequest request) { 1782 return receiveTriggerWebhookCallable().call(request); 1783 } 1784 1785 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1786 /** 1787 * ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted 1788 * at a specific trigger. 1789 * 1790 * <p>Sample code: 1791 * 1792 * <pre>{@code 1793 * // This snippet has been automatically generated and should be regarded as a code template only. 1794 * // It will require modifications to work: 1795 * // - It may require correct/in-range values for request initialization. 1796 * // - It may require specifying regional endpoints when creating the service client as shown in 1797 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1798 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1799 * ReceiveTriggerWebhookRequest request = 1800 * ReceiveTriggerWebhookRequest.newBuilder() 1801 * .setName("name3373707") 1802 * .setBody(HttpBody.newBuilder().build()) 1803 * .setProjectId("projectId-894832108") 1804 * .setTrigger("trigger-1059891784") 1805 * .setSecret("secret-906277200") 1806 * .build(); 1807 * ApiFuture<ReceiveTriggerWebhookResponse> future = 1808 * cloudBuildClient.receiveTriggerWebhookCallable().futureCall(request); 1809 * // Do something. 1810 * ReceiveTriggerWebhookResponse response = future.get(); 1811 * } 1812 * }</pre> 1813 */ 1814 public final UnaryCallable<ReceiveTriggerWebhookRequest, ReceiveTriggerWebhookResponse> receiveTriggerWebhookCallable()1815 receiveTriggerWebhookCallable() { 1816 return stub.receiveTriggerWebhookCallable(); 1817 } 1818 1819 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1820 /** 1821 * Creates a `WorkerPool`. 1822 * 1823 * <p>Sample code: 1824 * 1825 * <pre>{@code 1826 * // This snippet has been automatically generated and should be regarded as a code template only. 1827 * // It will require modifications to work: 1828 * // - It may require correct/in-range values for request initialization. 1829 * // - It may require specifying regional endpoints when creating the service client as shown in 1830 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1831 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1832 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 1833 * WorkerPool workerPool = WorkerPool.newBuilder().build(); 1834 * String workerPoolId = "workerPoolId-46320779"; 1835 * WorkerPool response = 1836 * cloudBuildClient.createWorkerPoolAsync(parent, workerPool, workerPoolId).get(); 1837 * } 1838 * }</pre> 1839 * 1840 * @param parent Required. The parent resource where this worker pool will be created. Format: 1841 * `projects/{project}/locations/{location}`. 1842 * @param workerPool Required. `WorkerPool` resource to create. 1843 * @param workerPoolId Required. Immutable. The ID to use for the `WorkerPool`, which will become 1844 * the final component of the resource name. 1845 * <p>This value should be 1-63 characters, and valid characters are /[a-z][0-9]-/. 1846 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1847 */ createWorkerPoolAsync( LocationName parent, WorkerPool workerPool, String workerPoolId)1848 public final OperationFuture<WorkerPool, CreateWorkerPoolOperationMetadata> createWorkerPoolAsync( 1849 LocationName parent, WorkerPool workerPool, String workerPoolId) { 1850 CreateWorkerPoolRequest request = 1851 CreateWorkerPoolRequest.newBuilder() 1852 .setParent(parent == null ? null : parent.toString()) 1853 .setWorkerPool(workerPool) 1854 .setWorkerPoolId(workerPoolId) 1855 .build(); 1856 return createWorkerPoolAsync(request); 1857 } 1858 1859 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1860 /** 1861 * Creates a `WorkerPool`. 1862 * 1863 * <p>Sample code: 1864 * 1865 * <pre>{@code 1866 * // This snippet has been automatically generated and should be regarded as a code template only. 1867 * // It will require modifications to work: 1868 * // - It may require correct/in-range values for request initialization. 1869 * // - It may require specifying regional endpoints when creating the service client as shown in 1870 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1871 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1872 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 1873 * WorkerPool workerPool = WorkerPool.newBuilder().build(); 1874 * String workerPoolId = "workerPoolId-46320779"; 1875 * WorkerPool response = 1876 * cloudBuildClient.createWorkerPoolAsync(parent, workerPool, workerPoolId).get(); 1877 * } 1878 * }</pre> 1879 * 1880 * @param parent Required. The parent resource where this worker pool will be created. Format: 1881 * `projects/{project}/locations/{location}`. 1882 * @param workerPool Required. `WorkerPool` resource to create. 1883 * @param workerPoolId Required. Immutable. The ID to use for the `WorkerPool`, which will become 1884 * the final component of the resource name. 1885 * <p>This value should be 1-63 characters, and valid characters are /[a-z][0-9]-/. 1886 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1887 */ createWorkerPoolAsync( String parent, WorkerPool workerPool, String workerPoolId)1888 public final OperationFuture<WorkerPool, CreateWorkerPoolOperationMetadata> createWorkerPoolAsync( 1889 String parent, WorkerPool workerPool, String workerPoolId) { 1890 CreateWorkerPoolRequest request = 1891 CreateWorkerPoolRequest.newBuilder() 1892 .setParent(parent) 1893 .setWorkerPool(workerPool) 1894 .setWorkerPoolId(workerPoolId) 1895 .build(); 1896 return createWorkerPoolAsync(request); 1897 } 1898 1899 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1900 /** 1901 * Creates a `WorkerPool`. 1902 * 1903 * <p>Sample code: 1904 * 1905 * <pre>{@code 1906 * // This snippet has been automatically generated and should be regarded as a code template only. 1907 * // It will require modifications to work: 1908 * // - It may require correct/in-range values for request initialization. 1909 * // - It may require specifying regional endpoints when creating the service client as shown in 1910 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1911 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1912 * CreateWorkerPoolRequest request = 1913 * CreateWorkerPoolRequest.newBuilder() 1914 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1915 * .setWorkerPool(WorkerPool.newBuilder().build()) 1916 * .setWorkerPoolId("workerPoolId-46320779") 1917 * .setValidateOnly(true) 1918 * .build(); 1919 * WorkerPool response = cloudBuildClient.createWorkerPoolAsync(request).get(); 1920 * } 1921 * }</pre> 1922 * 1923 * @param request The request object containing all of the parameters for the API call. 1924 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1925 */ createWorkerPoolAsync( CreateWorkerPoolRequest request)1926 public final OperationFuture<WorkerPool, CreateWorkerPoolOperationMetadata> createWorkerPoolAsync( 1927 CreateWorkerPoolRequest request) { 1928 return createWorkerPoolOperationCallable().futureCall(request); 1929 } 1930 1931 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1932 /** 1933 * Creates a `WorkerPool`. 1934 * 1935 * <p>Sample code: 1936 * 1937 * <pre>{@code 1938 * // This snippet has been automatically generated and should be regarded as a code template only. 1939 * // It will require modifications to work: 1940 * // - It may require correct/in-range values for request initialization. 1941 * // - It may require specifying regional endpoints when creating the service client as shown in 1942 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1943 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1944 * CreateWorkerPoolRequest request = 1945 * CreateWorkerPoolRequest.newBuilder() 1946 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1947 * .setWorkerPool(WorkerPool.newBuilder().build()) 1948 * .setWorkerPoolId("workerPoolId-46320779") 1949 * .setValidateOnly(true) 1950 * .build(); 1951 * OperationFuture<WorkerPool, CreateWorkerPoolOperationMetadata> future = 1952 * cloudBuildClient.createWorkerPoolOperationCallable().futureCall(request); 1953 * // Do something. 1954 * WorkerPool response = future.get(); 1955 * } 1956 * }</pre> 1957 */ 1958 public final OperationCallable< 1959 CreateWorkerPoolRequest, WorkerPool, CreateWorkerPoolOperationMetadata> createWorkerPoolOperationCallable()1960 createWorkerPoolOperationCallable() { 1961 return stub.createWorkerPoolOperationCallable(); 1962 } 1963 1964 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1965 /** 1966 * Creates a `WorkerPool`. 1967 * 1968 * <p>Sample code: 1969 * 1970 * <pre>{@code 1971 * // This snippet has been automatically generated and should be regarded as a code template only. 1972 * // It will require modifications to work: 1973 * // - It may require correct/in-range values for request initialization. 1974 * // - It may require specifying regional endpoints when creating the service client as shown in 1975 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1976 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 1977 * CreateWorkerPoolRequest request = 1978 * CreateWorkerPoolRequest.newBuilder() 1979 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 1980 * .setWorkerPool(WorkerPool.newBuilder().build()) 1981 * .setWorkerPoolId("workerPoolId-46320779") 1982 * .setValidateOnly(true) 1983 * .build(); 1984 * ApiFuture<Operation> future = cloudBuildClient.createWorkerPoolCallable().futureCall(request); 1985 * // Do something. 1986 * Operation response = future.get(); 1987 * } 1988 * }</pre> 1989 */ createWorkerPoolCallable()1990 public final UnaryCallable<CreateWorkerPoolRequest, Operation> createWorkerPoolCallable() { 1991 return stub.createWorkerPoolCallable(); 1992 } 1993 1994 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1995 /** 1996 * Returns details of a `WorkerPool`. 1997 * 1998 * <p>Sample code: 1999 * 2000 * <pre>{@code 2001 * // This snippet has been automatically generated and should be regarded as a code template only. 2002 * // It will require modifications to work: 2003 * // - It may require correct/in-range values for request initialization. 2004 * // - It may require specifying regional endpoints when creating the service client as shown in 2005 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2006 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2007 * WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]"); 2008 * WorkerPool response = cloudBuildClient.getWorkerPool(name); 2009 * } 2010 * }</pre> 2011 * 2012 * @param name Required. The name of the `WorkerPool` to retrieve. Format: 2013 * `projects/{project}/locations/{location}/workerPools/{workerPool}`. 2014 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2015 */ getWorkerPool(WorkerPoolName name)2016 public final WorkerPool getWorkerPool(WorkerPoolName name) { 2017 GetWorkerPoolRequest request = 2018 GetWorkerPoolRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 2019 return getWorkerPool(request); 2020 } 2021 2022 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2023 /** 2024 * Returns details of a `WorkerPool`. 2025 * 2026 * <p>Sample code: 2027 * 2028 * <pre>{@code 2029 * // This snippet has been automatically generated and should be regarded as a code template only. 2030 * // It will require modifications to work: 2031 * // - It may require correct/in-range values for request initialization. 2032 * // - It may require specifying regional endpoints when creating the service client as shown in 2033 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2034 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2035 * String name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString(); 2036 * WorkerPool response = cloudBuildClient.getWorkerPool(name); 2037 * } 2038 * }</pre> 2039 * 2040 * @param name Required. The name of the `WorkerPool` to retrieve. Format: 2041 * `projects/{project}/locations/{location}/workerPools/{workerPool}`. 2042 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2043 */ getWorkerPool(String name)2044 public final WorkerPool getWorkerPool(String name) { 2045 GetWorkerPoolRequest request = GetWorkerPoolRequest.newBuilder().setName(name).build(); 2046 return getWorkerPool(request); 2047 } 2048 2049 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2050 /** 2051 * Returns details of a `WorkerPool`. 2052 * 2053 * <p>Sample code: 2054 * 2055 * <pre>{@code 2056 * // This snippet has been automatically generated and should be regarded as a code template only. 2057 * // It will require modifications to work: 2058 * // - It may require correct/in-range values for request initialization. 2059 * // - It may require specifying regional endpoints when creating the service client as shown in 2060 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2061 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2062 * GetWorkerPoolRequest request = 2063 * GetWorkerPoolRequest.newBuilder() 2064 * .setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString()) 2065 * .build(); 2066 * WorkerPool response = cloudBuildClient.getWorkerPool(request); 2067 * } 2068 * }</pre> 2069 * 2070 * @param request The request object containing all of the parameters for the API call. 2071 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2072 */ getWorkerPool(GetWorkerPoolRequest request)2073 public final WorkerPool getWorkerPool(GetWorkerPoolRequest request) { 2074 return getWorkerPoolCallable().call(request); 2075 } 2076 2077 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2078 /** 2079 * Returns details of a `WorkerPool`. 2080 * 2081 * <p>Sample code: 2082 * 2083 * <pre>{@code 2084 * // This snippet has been automatically generated and should be regarded as a code template only. 2085 * // It will require modifications to work: 2086 * // - It may require correct/in-range values for request initialization. 2087 * // - It may require specifying regional endpoints when creating the service client as shown in 2088 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2089 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2090 * GetWorkerPoolRequest request = 2091 * GetWorkerPoolRequest.newBuilder() 2092 * .setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString()) 2093 * .build(); 2094 * ApiFuture<WorkerPool> future = cloudBuildClient.getWorkerPoolCallable().futureCall(request); 2095 * // Do something. 2096 * WorkerPool response = future.get(); 2097 * } 2098 * }</pre> 2099 */ getWorkerPoolCallable()2100 public final UnaryCallable<GetWorkerPoolRequest, WorkerPool> getWorkerPoolCallable() { 2101 return stub.getWorkerPoolCallable(); 2102 } 2103 2104 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2105 /** 2106 * Deletes a `WorkerPool`. 2107 * 2108 * <p>Sample code: 2109 * 2110 * <pre>{@code 2111 * // This snippet has been automatically generated and should be regarded as a code template only. 2112 * // It will require modifications to work: 2113 * // - It may require correct/in-range values for request initialization. 2114 * // - It may require specifying regional endpoints when creating the service client as shown in 2115 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2116 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2117 * WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]"); 2118 * cloudBuildClient.deleteWorkerPoolAsync(name).get(); 2119 * } 2120 * }</pre> 2121 * 2122 * @param name Required. The name of the `WorkerPool` to delete. Format: 2123 * `projects/{project}/locations/{location}/workerPools/{workerPool}`. 2124 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2125 */ deleteWorkerPoolAsync( WorkerPoolName name)2126 public final OperationFuture<Empty, DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync( 2127 WorkerPoolName name) { 2128 DeleteWorkerPoolRequest request = 2129 DeleteWorkerPoolRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 2130 return deleteWorkerPoolAsync(request); 2131 } 2132 2133 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2134 /** 2135 * Deletes a `WorkerPool`. 2136 * 2137 * <p>Sample code: 2138 * 2139 * <pre>{@code 2140 * // This snippet has been automatically generated and should be regarded as a code template only. 2141 * // It will require modifications to work: 2142 * // - It may require correct/in-range values for request initialization. 2143 * // - It may require specifying regional endpoints when creating the service client as shown in 2144 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2145 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2146 * String name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString(); 2147 * cloudBuildClient.deleteWorkerPoolAsync(name).get(); 2148 * } 2149 * }</pre> 2150 * 2151 * @param name Required. The name of the `WorkerPool` to delete. Format: 2152 * `projects/{project}/locations/{location}/workerPools/{workerPool}`. 2153 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2154 */ deleteWorkerPoolAsync( String name)2155 public final OperationFuture<Empty, DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync( 2156 String name) { 2157 DeleteWorkerPoolRequest request = DeleteWorkerPoolRequest.newBuilder().setName(name).build(); 2158 return deleteWorkerPoolAsync(request); 2159 } 2160 2161 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2162 /** 2163 * Deletes a `WorkerPool`. 2164 * 2165 * <p>Sample code: 2166 * 2167 * <pre>{@code 2168 * // This snippet has been automatically generated and should be regarded as a code template only. 2169 * // It will require modifications to work: 2170 * // - It may require correct/in-range values for request initialization. 2171 * // - It may require specifying regional endpoints when creating the service client as shown in 2172 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2173 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2174 * DeleteWorkerPoolRequest request = 2175 * DeleteWorkerPoolRequest.newBuilder() 2176 * .setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString()) 2177 * .setEtag("etag3123477") 2178 * .setAllowMissing(true) 2179 * .setValidateOnly(true) 2180 * .build(); 2181 * cloudBuildClient.deleteWorkerPoolAsync(request).get(); 2182 * } 2183 * }</pre> 2184 * 2185 * @param request The request object containing all of the parameters for the API call. 2186 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2187 */ deleteWorkerPoolAsync( DeleteWorkerPoolRequest request)2188 public final OperationFuture<Empty, DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync( 2189 DeleteWorkerPoolRequest request) { 2190 return deleteWorkerPoolOperationCallable().futureCall(request); 2191 } 2192 2193 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2194 /** 2195 * Deletes a `WorkerPool`. 2196 * 2197 * <p>Sample code: 2198 * 2199 * <pre>{@code 2200 * // This snippet has been automatically generated and should be regarded as a code template only. 2201 * // It will require modifications to work: 2202 * // - It may require correct/in-range values for request initialization. 2203 * // - It may require specifying regional endpoints when creating the service client as shown in 2204 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2205 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2206 * DeleteWorkerPoolRequest request = 2207 * DeleteWorkerPoolRequest.newBuilder() 2208 * .setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString()) 2209 * .setEtag("etag3123477") 2210 * .setAllowMissing(true) 2211 * .setValidateOnly(true) 2212 * .build(); 2213 * OperationFuture<Empty, DeleteWorkerPoolOperationMetadata> future = 2214 * cloudBuildClient.deleteWorkerPoolOperationCallable().futureCall(request); 2215 * // Do something. 2216 * future.get(); 2217 * } 2218 * }</pre> 2219 */ 2220 public final OperationCallable<DeleteWorkerPoolRequest, Empty, DeleteWorkerPoolOperationMetadata> deleteWorkerPoolOperationCallable()2221 deleteWorkerPoolOperationCallable() { 2222 return stub.deleteWorkerPoolOperationCallable(); 2223 } 2224 2225 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2226 /** 2227 * Deletes a `WorkerPool`. 2228 * 2229 * <p>Sample code: 2230 * 2231 * <pre>{@code 2232 * // This snippet has been automatically generated and should be regarded as a code template only. 2233 * // It will require modifications to work: 2234 * // - It may require correct/in-range values for request initialization. 2235 * // - It may require specifying regional endpoints when creating the service client as shown in 2236 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2237 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2238 * DeleteWorkerPoolRequest request = 2239 * DeleteWorkerPoolRequest.newBuilder() 2240 * .setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString()) 2241 * .setEtag("etag3123477") 2242 * .setAllowMissing(true) 2243 * .setValidateOnly(true) 2244 * .build(); 2245 * ApiFuture<Operation> future = cloudBuildClient.deleteWorkerPoolCallable().futureCall(request); 2246 * // Do something. 2247 * future.get(); 2248 * } 2249 * }</pre> 2250 */ deleteWorkerPoolCallable()2251 public final UnaryCallable<DeleteWorkerPoolRequest, Operation> deleteWorkerPoolCallable() { 2252 return stub.deleteWorkerPoolCallable(); 2253 } 2254 2255 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2256 /** 2257 * Updates a `WorkerPool`. 2258 * 2259 * <p>Sample code: 2260 * 2261 * <pre>{@code 2262 * // This snippet has been automatically generated and should be regarded as a code template only. 2263 * // It will require modifications to work: 2264 * // - It may require correct/in-range values for request initialization. 2265 * // - It may require specifying regional endpoints when creating the service client as shown in 2266 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2267 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2268 * WorkerPool workerPool = WorkerPool.newBuilder().build(); 2269 * FieldMask updateMask = FieldMask.newBuilder().build(); 2270 * WorkerPool response = cloudBuildClient.updateWorkerPoolAsync(workerPool, updateMask).get(); 2271 * } 2272 * }</pre> 2273 * 2274 * @param workerPool Required. The `WorkerPool` to update. 2275 * <p>The `name` field is used to identify the `WorkerPool` to update. Format: 2276 * `projects/{project}/locations/{location}/workerPools/{workerPool}`. 2277 * @param updateMask A mask specifying which fields in `worker_pool` to update. 2278 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2279 */ updateWorkerPoolAsync( WorkerPool workerPool, FieldMask updateMask)2280 public final OperationFuture<WorkerPool, UpdateWorkerPoolOperationMetadata> updateWorkerPoolAsync( 2281 WorkerPool workerPool, FieldMask updateMask) { 2282 UpdateWorkerPoolRequest request = 2283 UpdateWorkerPoolRequest.newBuilder() 2284 .setWorkerPool(workerPool) 2285 .setUpdateMask(updateMask) 2286 .build(); 2287 return updateWorkerPoolAsync(request); 2288 } 2289 2290 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2291 /** 2292 * Updates a `WorkerPool`. 2293 * 2294 * <p>Sample code: 2295 * 2296 * <pre>{@code 2297 * // This snippet has been automatically generated and should be regarded as a code template only. 2298 * // It will require modifications to work: 2299 * // - It may require correct/in-range values for request initialization. 2300 * // - It may require specifying regional endpoints when creating the service client as shown in 2301 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2302 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2303 * UpdateWorkerPoolRequest request = 2304 * UpdateWorkerPoolRequest.newBuilder() 2305 * .setWorkerPool(WorkerPool.newBuilder().build()) 2306 * .setUpdateMask(FieldMask.newBuilder().build()) 2307 * .setValidateOnly(true) 2308 * .build(); 2309 * WorkerPool response = cloudBuildClient.updateWorkerPoolAsync(request).get(); 2310 * } 2311 * }</pre> 2312 * 2313 * @param request The request object containing all of the parameters for the API call. 2314 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2315 */ updateWorkerPoolAsync( UpdateWorkerPoolRequest request)2316 public final OperationFuture<WorkerPool, UpdateWorkerPoolOperationMetadata> updateWorkerPoolAsync( 2317 UpdateWorkerPoolRequest request) { 2318 return updateWorkerPoolOperationCallable().futureCall(request); 2319 } 2320 2321 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2322 /** 2323 * Updates a `WorkerPool`. 2324 * 2325 * <p>Sample code: 2326 * 2327 * <pre>{@code 2328 * // This snippet has been automatically generated and should be regarded as a code template only. 2329 * // It will require modifications to work: 2330 * // - It may require correct/in-range values for request initialization. 2331 * // - It may require specifying regional endpoints when creating the service client as shown in 2332 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2333 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2334 * UpdateWorkerPoolRequest request = 2335 * UpdateWorkerPoolRequest.newBuilder() 2336 * .setWorkerPool(WorkerPool.newBuilder().build()) 2337 * .setUpdateMask(FieldMask.newBuilder().build()) 2338 * .setValidateOnly(true) 2339 * .build(); 2340 * OperationFuture<WorkerPool, UpdateWorkerPoolOperationMetadata> future = 2341 * cloudBuildClient.updateWorkerPoolOperationCallable().futureCall(request); 2342 * // Do something. 2343 * WorkerPool response = future.get(); 2344 * } 2345 * }</pre> 2346 */ 2347 public final OperationCallable< 2348 UpdateWorkerPoolRequest, WorkerPool, UpdateWorkerPoolOperationMetadata> updateWorkerPoolOperationCallable()2349 updateWorkerPoolOperationCallable() { 2350 return stub.updateWorkerPoolOperationCallable(); 2351 } 2352 2353 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2354 /** 2355 * Updates a `WorkerPool`. 2356 * 2357 * <p>Sample code: 2358 * 2359 * <pre>{@code 2360 * // This snippet has been automatically generated and should be regarded as a code template only. 2361 * // It will require modifications to work: 2362 * // - It may require correct/in-range values for request initialization. 2363 * // - It may require specifying regional endpoints when creating the service client as shown in 2364 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2365 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2366 * UpdateWorkerPoolRequest request = 2367 * UpdateWorkerPoolRequest.newBuilder() 2368 * .setWorkerPool(WorkerPool.newBuilder().build()) 2369 * .setUpdateMask(FieldMask.newBuilder().build()) 2370 * .setValidateOnly(true) 2371 * .build(); 2372 * ApiFuture<Operation> future = cloudBuildClient.updateWorkerPoolCallable().futureCall(request); 2373 * // Do something. 2374 * Operation response = future.get(); 2375 * } 2376 * }</pre> 2377 */ updateWorkerPoolCallable()2378 public final UnaryCallable<UpdateWorkerPoolRequest, Operation> updateWorkerPoolCallable() { 2379 return stub.updateWorkerPoolCallable(); 2380 } 2381 2382 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2383 /** 2384 * Lists `WorkerPool`s. 2385 * 2386 * <p>Sample code: 2387 * 2388 * <pre>{@code 2389 * // This snippet has been automatically generated and should be regarded as a code template only. 2390 * // It will require modifications to work: 2391 * // - It may require correct/in-range values for request initialization. 2392 * // - It may require specifying regional endpoints when creating the service client as shown in 2393 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2394 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2395 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 2396 * for (WorkerPool element : cloudBuildClient.listWorkerPools(parent).iterateAll()) { 2397 * // doThingsWith(element); 2398 * } 2399 * } 2400 * }</pre> 2401 * 2402 * @param parent Required. The parent of the collection of `WorkerPools`. Format: 2403 * `projects/{project}/locations/{location}`. 2404 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2405 */ listWorkerPools(LocationName parent)2406 public final ListWorkerPoolsPagedResponse listWorkerPools(LocationName parent) { 2407 ListWorkerPoolsRequest request = 2408 ListWorkerPoolsRequest.newBuilder() 2409 .setParent(parent == null ? null : parent.toString()) 2410 .build(); 2411 return listWorkerPools(request); 2412 } 2413 2414 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2415 /** 2416 * Lists `WorkerPool`s. 2417 * 2418 * <p>Sample code: 2419 * 2420 * <pre>{@code 2421 * // This snippet has been automatically generated and should be regarded as a code template only. 2422 * // It will require modifications to work: 2423 * // - It may require correct/in-range values for request initialization. 2424 * // - It may require specifying regional endpoints when creating the service client as shown in 2425 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2426 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2427 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 2428 * for (WorkerPool element : cloudBuildClient.listWorkerPools(parent).iterateAll()) { 2429 * // doThingsWith(element); 2430 * } 2431 * } 2432 * }</pre> 2433 * 2434 * @param parent Required. The parent of the collection of `WorkerPools`. Format: 2435 * `projects/{project}/locations/{location}`. 2436 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2437 */ listWorkerPools(String parent)2438 public final ListWorkerPoolsPagedResponse listWorkerPools(String parent) { 2439 ListWorkerPoolsRequest request = ListWorkerPoolsRequest.newBuilder().setParent(parent).build(); 2440 return listWorkerPools(request); 2441 } 2442 2443 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2444 /** 2445 * Lists `WorkerPool`s. 2446 * 2447 * <p>Sample code: 2448 * 2449 * <pre>{@code 2450 * // This snippet has been automatically generated and should be regarded as a code template only. 2451 * // It will require modifications to work: 2452 * // - It may require correct/in-range values for request initialization. 2453 * // - It may require specifying regional endpoints when creating the service client as shown in 2454 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2455 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2456 * ListWorkerPoolsRequest request = 2457 * ListWorkerPoolsRequest.newBuilder() 2458 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 2459 * .setPageSize(883849137) 2460 * .setPageToken("pageToken873572522") 2461 * .build(); 2462 * for (WorkerPool element : cloudBuildClient.listWorkerPools(request).iterateAll()) { 2463 * // doThingsWith(element); 2464 * } 2465 * } 2466 * }</pre> 2467 * 2468 * @param request The request object containing all of the parameters for the API call. 2469 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 2470 */ listWorkerPools(ListWorkerPoolsRequest request)2471 public final ListWorkerPoolsPagedResponse listWorkerPools(ListWorkerPoolsRequest request) { 2472 return listWorkerPoolsPagedCallable().call(request); 2473 } 2474 2475 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2476 /** 2477 * Lists `WorkerPool`s. 2478 * 2479 * <p>Sample code: 2480 * 2481 * <pre>{@code 2482 * // This snippet has been automatically generated and should be regarded as a code template only. 2483 * // It will require modifications to work: 2484 * // - It may require correct/in-range values for request initialization. 2485 * // - It may require specifying regional endpoints when creating the service client as shown in 2486 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2487 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2488 * ListWorkerPoolsRequest request = 2489 * ListWorkerPoolsRequest.newBuilder() 2490 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 2491 * .setPageSize(883849137) 2492 * .setPageToken("pageToken873572522") 2493 * .build(); 2494 * ApiFuture<WorkerPool> future = 2495 * cloudBuildClient.listWorkerPoolsPagedCallable().futureCall(request); 2496 * // Do something. 2497 * for (WorkerPool element : future.get().iterateAll()) { 2498 * // doThingsWith(element); 2499 * } 2500 * } 2501 * }</pre> 2502 */ 2503 public final UnaryCallable<ListWorkerPoolsRequest, ListWorkerPoolsPagedResponse> listWorkerPoolsPagedCallable()2504 listWorkerPoolsPagedCallable() { 2505 return stub.listWorkerPoolsPagedCallable(); 2506 } 2507 2508 // AUTO-GENERATED DOCUMENTATION AND METHOD. 2509 /** 2510 * Lists `WorkerPool`s. 2511 * 2512 * <p>Sample code: 2513 * 2514 * <pre>{@code 2515 * // This snippet has been automatically generated and should be regarded as a code template only. 2516 * // It will require modifications to work: 2517 * // - It may require correct/in-range values for request initialization. 2518 * // - It may require specifying regional endpoints when creating the service client as shown in 2519 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 2520 * try (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) { 2521 * ListWorkerPoolsRequest request = 2522 * ListWorkerPoolsRequest.newBuilder() 2523 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 2524 * .setPageSize(883849137) 2525 * .setPageToken("pageToken873572522") 2526 * .build(); 2527 * while (true) { 2528 * ListWorkerPoolsResponse response = cloudBuildClient.listWorkerPoolsCallable().call(request); 2529 * for (WorkerPool element : response.getWorkerPoolsList()) { 2530 * // doThingsWith(element); 2531 * } 2532 * String nextPageToken = response.getNextPageToken(); 2533 * if (!Strings.isNullOrEmpty(nextPageToken)) { 2534 * request = request.toBuilder().setPageToken(nextPageToken).build(); 2535 * } else { 2536 * break; 2537 * } 2538 * } 2539 * } 2540 * }</pre> 2541 */ 2542 public final UnaryCallable<ListWorkerPoolsRequest, ListWorkerPoolsResponse> listWorkerPoolsCallable()2543 listWorkerPoolsCallable() { 2544 return stub.listWorkerPoolsCallable(); 2545 } 2546 2547 @Override close()2548 public final void close() { 2549 stub.close(); 2550 } 2551 2552 @Override shutdown()2553 public void shutdown() { 2554 stub.shutdown(); 2555 } 2556 2557 @Override isShutdown()2558 public boolean isShutdown() { 2559 return stub.isShutdown(); 2560 } 2561 2562 @Override isTerminated()2563 public boolean isTerminated() { 2564 return stub.isTerminated(); 2565 } 2566 2567 @Override shutdownNow()2568 public void shutdownNow() { 2569 stub.shutdownNow(); 2570 } 2571 2572 @Override awaitTermination(long duration, TimeUnit unit)2573 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 2574 return stub.awaitTermination(duration, unit); 2575 } 2576 2577 public static class ListBuildsPagedResponse 2578 extends AbstractPagedListResponse< 2579 ListBuildsRequest, 2580 ListBuildsResponse, 2581 Build, 2582 ListBuildsPage, 2583 ListBuildsFixedSizeCollection> { 2584 createAsync( PageContext<ListBuildsRequest, ListBuildsResponse, Build> context, ApiFuture<ListBuildsResponse> futureResponse)2585 public static ApiFuture<ListBuildsPagedResponse> createAsync( 2586 PageContext<ListBuildsRequest, ListBuildsResponse, Build> context, 2587 ApiFuture<ListBuildsResponse> futureResponse) { 2588 ApiFuture<ListBuildsPage> futurePage = 2589 ListBuildsPage.createEmptyPage().createPageAsync(context, futureResponse); 2590 return ApiFutures.transform( 2591 futurePage, input -> new ListBuildsPagedResponse(input), MoreExecutors.directExecutor()); 2592 } 2593 ListBuildsPagedResponse(ListBuildsPage page)2594 private ListBuildsPagedResponse(ListBuildsPage page) { 2595 super(page, ListBuildsFixedSizeCollection.createEmptyCollection()); 2596 } 2597 } 2598 2599 public static class ListBuildsPage 2600 extends AbstractPage<ListBuildsRequest, ListBuildsResponse, Build, ListBuildsPage> { 2601 ListBuildsPage( PageContext<ListBuildsRequest, ListBuildsResponse, Build> context, ListBuildsResponse response)2602 private ListBuildsPage( 2603 PageContext<ListBuildsRequest, ListBuildsResponse, Build> context, 2604 ListBuildsResponse response) { 2605 super(context, response); 2606 } 2607 createEmptyPage()2608 private static ListBuildsPage createEmptyPage() { 2609 return new ListBuildsPage(null, null); 2610 } 2611 2612 @Override createPage( PageContext<ListBuildsRequest, ListBuildsResponse, Build> context, ListBuildsResponse response)2613 protected ListBuildsPage createPage( 2614 PageContext<ListBuildsRequest, ListBuildsResponse, Build> context, 2615 ListBuildsResponse response) { 2616 return new ListBuildsPage(context, response); 2617 } 2618 2619 @Override createPageAsync( PageContext<ListBuildsRequest, ListBuildsResponse, Build> context, ApiFuture<ListBuildsResponse> futureResponse)2620 public ApiFuture<ListBuildsPage> createPageAsync( 2621 PageContext<ListBuildsRequest, ListBuildsResponse, Build> context, 2622 ApiFuture<ListBuildsResponse> futureResponse) { 2623 return super.createPageAsync(context, futureResponse); 2624 } 2625 } 2626 2627 public static class ListBuildsFixedSizeCollection 2628 extends AbstractFixedSizeCollection< 2629 ListBuildsRequest, 2630 ListBuildsResponse, 2631 Build, 2632 ListBuildsPage, 2633 ListBuildsFixedSizeCollection> { 2634 ListBuildsFixedSizeCollection(List<ListBuildsPage> pages, int collectionSize)2635 private ListBuildsFixedSizeCollection(List<ListBuildsPage> pages, int collectionSize) { 2636 super(pages, collectionSize); 2637 } 2638 createEmptyCollection()2639 private static ListBuildsFixedSizeCollection createEmptyCollection() { 2640 return new ListBuildsFixedSizeCollection(null, 0); 2641 } 2642 2643 @Override createCollection( List<ListBuildsPage> pages, int collectionSize)2644 protected ListBuildsFixedSizeCollection createCollection( 2645 List<ListBuildsPage> pages, int collectionSize) { 2646 return new ListBuildsFixedSizeCollection(pages, collectionSize); 2647 } 2648 } 2649 2650 public static class ListBuildTriggersPagedResponse 2651 extends AbstractPagedListResponse< 2652 ListBuildTriggersRequest, 2653 ListBuildTriggersResponse, 2654 BuildTrigger, 2655 ListBuildTriggersPage, 2656 ListBuildTriggersFixedSizeCollection> { 2657 createAsync( PageContext<ListBuildTriggersRequest, ListBuildTriggersResponse, BuildTrigger> context, ApiFuture<ListBuildTriggersResponse> futureResponse)2658 public static ApiFuture<ListBuildTriggersPagedResponse> createAsync( 2659 PageContext<ListBuildTriggersRequest, ListBuildTriggersResponse, BuildTrigger> context, 2660 ApiFuture<ListBuildTriggersResponse> futureResponse) { 2661 ApiFuture<ListBuildTriggersPage> futurePage = 2662 ListBuildTriggersPage.createEmptyPage().createPageAsync(context, futureResponse); 2663 return ApiFutures.transform( 2664 futurePage, 2665 input -> new ListBuildTriggersPagedResponse(input), 2666 MoreExecutors.directExecutor()); 2667 } 2668 ListBuildTriggersPagedResponse(ListBuildTriggersPage page)2669 private ListBuildTriggersPagedResponse(ListBuildTriggersPage page) { 2670 super(page, ListBuildTriggersFixedSizeCollection.createEmptyCollection()); 2671 } 2672 } 2673 2674 public static class ListBuildTriggersPage 2675 extends AbstractPage< 2676 ListBuildTriggersRequest, 2677 ListBuildTriggersResponse, 2678 BuildTrigger, 2679 ListBuildTriggersPage> { 2680 ListBuildTriggersPage( PageContext<ListBuildTriggersRequest, ListBuildTriggersResponse, BuildTrigger> context, ListBuildTriggersResponse response)2681 private ListBuildTriggersPage( 2682 PageContext<ListBuildTriggersRequest, ListBuildTriggersResponse, BuildTrigger> context, 2683 ListBuildTriggersResponse response) { 2684 super(context, response); 2685 } 2686 createEmptyPage()2687 private static ListBuildTriggersPage createEmptyPage() { 2688 return new ListBuildTriggersPage(null, null); 2689 } 2690 2691 @Override createPage( PageContext<ListBuildTriggersRequest, ListBuildTriggersResponse, BuildTrigger> context, ListBuildTriggersResponse response)2692 protected ListBuildTriggersPage createPage( 2693 PageContext<ListBuildTriggersRequest, ListBuildTriggersResponse, BuildTrigger> context, 2694 ListBuildTriggersResponse response) { 2695 return new ListBuildTriggersPage(context, response); 2696 } 2697 2698 @Override createPageAsync( PageContext<ListBuildTriggersRequest, ListBuildTriggersResponse, BuildTrigger> context, ApiFuture<ListBuildTriggersResponse> futureResponse)2699 public ApiFuture<ListBuildTriggersPage> createPageAsync( 2700 PageContext<ListBuildTriggersRequest, ListBuildTriggersResponse, BuildTrigger> context, 2701 ApiFuture<ListBuildTriggersResponse> futureResponse) { 2702 return super.createPageAsync(context, futureResponse); 2703 } 2704 } 2705 2706 public static class ListBuildTriggersFixedSizeCollection 2707 extends AbstractFixedSizeCollection< 2708 ListBuildTriggersRequest, 2709 ListBuildTriggersResponse, 2710 BuildTrigger, 2711 ListBuildTriggersPage, 2712 ListBuildTriggersFixedSizeCollection> { 2713 ListBuildTriggersFixedSizeCollection( List<ListBuildTriggersPage> pages, int collectionSize)2714 private ListBuildTriggersFixedSizeCollection( 2715 List<ListBuildTriggersPage> pages, int collectionSize) { 2716 super(pages, collectionSize); 2717 } 2718 createEmptyCollection()2719 private static ListBuildTriggersFixedSizeCollection createEmptyCollection() { 2720 return new ListBuildTriggersFixedSizeCollection(null, 0); 2721 } 2722 2723 @Override createCollection( List<ListBuildTriggersPage> pages, int collectionSize)2724 protected ListBuildTriggersFixedSizeCollection createCollection( 2725 List<ListBuildTriggersPage> pages, int collectionSize) { 2726 return new ListBuildTriggersFixedSizeCollection(pages, collectionSize); 2727 } 2728 } 2729 2730 public static class ListWorkerPoolsPagedResponse 2731 extends AbstractPagedListResponse< 2732 ListWorkerPoolsRequest, 2733 ListWorkerPoolsResponse, 2734 WorkerPool, 2735 ListWorkerPoolsPage, 2736 ListWorkerPoolsFixedSizeCollection> { 2737 createAsync( PageContext<ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool> context, ApiFuture<ListWorkerPoolsResponse> futureResponse)2738 public static ApiFuture<ListWorkerPoolsPagedResponse> createAsync( 2739 PageContext<ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool> context, 2740 ApiFuture<ListWorkerPoolsResponse> futureResponse) { 2741 ApiFuture<ListWorkerPoolsPage> futurePage = 2742 ListWorkerPoolsPage.createEmptyPage().createPageAsync(context, futureResponse); 2743 return ApiFutures.transform( 2744 futurePage, 2745 input -> new ListWorkerPoolsPagedResponse(input), 2746 MoreExecutors.directExecutor()); 2747 } 2748 ListWorkerPoolsPagedResponse(ListWorkerPoolsPage page)2749 private ListWorkerPoolsPagedResponse(ListWorkerPoolsPage page) { 2750 super(page, ListWorkerPoolsFixedSizeCollection.createEmptyCollection()); 2751 } 2752 } 2753 2754 public static class ListWorkerPoolsPage 2755 extends AbstractPage< 2756 ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool, ListWorkerPoolsPage> { 2757 ListWorkerPoolsPage( PageContext<ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool> context, ListWorkerPoolsResponse response)2758 private ListWorkerPoolsPage( 2759 PageContext<ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool> context, 2760 ListWorkerPoolsResponse response) { 2761 super(context, response); 2762 } 2763 createEmptyPage()2764 private static ListWorkerPoolsPage createEmptyPage() { 2765 return new ListWorkerPoolsPage(null, null); 2766 } 2767 2768 @Override createPage( PageContext<ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool> context, ListWorkerPoolsResponse response)2769 protected ListWorkerPoolsPage createPage( 2770 PageContext<ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool> context, 2771 ListWorkerPoolsResponse response) { 2772 return new ListWorkerPoolsPage(context, response); 2773 } 2774 2775 @Override createPageAsync( PageContext<ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool> context, ApiFuture<ListWorkerPoolsResponse> futureResponse)2776 public ApiFuture<ListWorkerPoolsPage> createPageAsync( 2777 PageContext<ListWorkerPoolsRequest, ListWorkerPoolsResponse, WorkerPool> context, 2778 ApiFuture<ListWorkerPoolsResponse> futureResponse) { 2779 return super.createPageAsync(context, futureResponse); 2780 } 2781 } 2782 2783 public static class ListWorkerPoolsFixedSizeCollection 2784 extends AbstractFixedSizeCollection< 2785 ListWorkerPoolsRequest, 2786 ListWorkerPoolsResponse, 2787 WorkerPool, 2788 ListWorkerPoolsPage, 2789 ListWorkerPoolsFixedSizeCollection> { 2790 ListWorkerPoolsFixedSizeCollection( List<ListWorkerPoolsPage> pages, int collectionSize)2791 private ListWorkerPoolsFixedSizeCollection( 2792 List<ListWorkerPoolsPage> pages, int collectionSize) { 2793 super(pages, collectionSize); 2794 } 2795 createEmptyCollection()2796 private static ListWorkerPoolsFixedSizeCollection createEmptyCollection() { 2797 return new ListWorkerPoolsFixedSizeCollection(null, 0); 2798 } 2799 2800 @Override createCollection( List<ListWorkerPoolsPage> pages, int collectionSize)2801 protected ListWorkerPoolsFixedSizeCollection createCollection( 2802 List<ListWorkerPoolsPage> pages, int collectionSize) { 2803 return new ListWorkerPoolsFixedSizeCollection(pages, collectionSize); 2804 } 2805 } 2806 } 2807