Skip to content

Commit 88ad198

Browse files
feat: [cloudbuild] Add routing information in Cloud Build GRPC clients (#9635)
* feat: Add routing information in Cloud Build GRPC clients PiperOrigin-RevId: 547283196 Source-Link: googleapis/googleapis@64d54ff Source-Link: https://github.com/googleapis/googleapis-gen/commit/1de18221109b4a025c0b2e8c25324cb01b6df626 Copy-Tag: eyJwIjoiamF2YS1jbG91ZGJ1aWxkLy5Pd2xCb3QueWFtbCIsImgiOiIxZGUxODIyMTEwOWI0YTAyNWMwYjJlOGMyNTMyNGNiMDFiNmRmNjI2In0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: Revert breaking change of main pattern PiperOrigin-RevId: 547506413 Source-Link: googleapis/googleapis@8080bbe Source-Link: https://github.com/googleapis/googleapis-gen/commit/ac98388bb832dbebc0bcd6b7480010573c0bbdc4 Copy-Tag: eyJwIjoiamF2YS1jbG91ZGJ1aWxkLy5Pd2xCb3QueWFtbCIsImgiOiJhYzk4Mzg4YmI4MzJkYmViYzBiY2Q2Yjc0ODAwMTA1NzNjMGJiZGM0In0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 1e8aa17 commit 88ad198

26 files changed

+1150
-854
lines changed

java-cloudbuild/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ If you are using Maven without the BOM, add this to your dependencies:
4242
<dependency>
4343
<groupId>com.google.cloud</groupId>
4444
<artifactId>google-cloud-build</artifactId>
45-
<version>3.23.0</version>
45+
<version>3.22.0</version>
4646
</dependency>
4747
```
4848

4949
If you are using Gradle without BOM, add this to your dependencies:
5050

5151
```Groovy
52-
implementation 'com.google.cloud:google-cloud-build:3.23.0'
52+
implementation 'com.google.cloud:google-cloud-build:3.22.0'
5353
```
5454

5555
If you are using SBT, add this to your dependencies:
5656

5757
```Scala
58-
libraryDependencies += "com.google.cloud" % "google-cloud-build" % "3.23.0"
58+
libraryDependencies += "com.google.cloud" % "google-cloud-build" % "3.22.0"
5959
```
6060
<!-- {x-version-update-end} -->
6161

java-cloudbuild/google-cloud-build/src/main/java/com/google/cloud/devtools/cloudbuild/v1/CloudBuildClient.java

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,9 @@ public final UnaryCallable<CancelBuildRequest, Build> cancelBuildCallable() {
734734
* <p>For builds that specify `StorageSource`:
735735
*
736736
* <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.
737+
* <li>If the original build pulled source from Cloud Storage without specifying the generation
738+
* of the object, the new build will use the current object, which may be different from the
739+
* original build source.
740740
* <li>If the original build pulled source from Cloud Storage and specified the generation of
741741
* the object, the new build will attempt to use the same object, which may or may not be
742742
* available depending on the bucket's lifecycle management settings.
@@ -794,9 +794,9 @@ public final OperationFuture<Build, BuildOperationMetadata> retryBuildAsync(
794794
* <p>For builds that specify `StorageSource`:
795795
*
796796
* <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.
797+
* <li>If the original build pulled source from Cloud Storage without specifying the generation
798+
* of the object, the new build will use the current object, which may be different from the
799+
* original build source.
800800
* <li>If the original build pulled source from Cloud Storage and specified the generation of
801801
* the object, the new build will attempt to use the same object, which may or may not be
802802
* available depending on the bucket's lifecycle management settings.
@@ -855,9 +855,9 @@ public final OperationFuture<Build, BuildOperationMetadata> retryBuildAsync(
855855
* <p>For builds that specify `StorageSource`:
856856
*
857857
* <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.
858+
* <li>If the original build pulled source from Cloud Storage without specifying the generation
859+
* of the object, the new build will use the current object, which may be different from the
860+
* original build source.
861861
* <li>If the original build pulled source from Cloud Storage and specified the generation of
862862
* the object, the new build will attempt to use the same object, which may or may not be
863863
* available depending on the bucket's lifecycle management settings.
@@ -916,9 +916,9 @@ public final OperationFuture<Build, BuildOperationMetadata> retryBuildAsync(
916916
* <p>For builds that specify `StorageSource`:
917917
*
918918
* <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.
919+
* <li>If the original build pulled source from Cloud Storage without specifying the generation
920+
* of the object, the new build will use the current object, which may be different from the
921+
* original build source.
922922
* <li>If the original build pulled source from Cloud Storage and specified the generation of
923923
* the object, the new build will attempt to use the same object, which may or may not be
924924
* available depending on the bucket's lifecycle management settings.
@@ -1622,6 +1622,11 @@ public final UnaryCallable<UpdateBuildTriggerRequest, BuildTrigger> updateBuildT
16221622
/**
16231623
* Runs a `BuildTrigger` at a particular source revision.
16241624
*
1625+
* <p>To run a regional or global trigger, use the POST request that includes the location
1626+
* endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run).
1627+
* The POST request that does not include the location endpoint in the path can only be used when
1628+
* running global triggers.
1629+
*
16251630
* <p>Sample code:
16261631
*
16271632
* <pre>{@code
@@ -1640,7 +1645,8 @@ public final UnaryCallable<UpdateBuildTriggerRequest, BuildTrigger> updateBuildT
16401645
*
16411646
* @param projectId Required. ID of the project.
16421647
* @param triggerId Required. ID of the trigger.
1643-
* @param source Source to build against this trigger.
1648+
* @param source Source to build against this trigger. Branch and tag names cannot consist of
1649+
* regular expressions.
16441650
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
16451651
*/
16461652
public final OperationFuture<Build, BuildOperationMetadata> runBuildTriggerAsync(
@@ -1658,6 +1664,11 @@ public final OperationFuture<Build, BuildOperationMetadata> runBuildTriggerAsync
16581664
/**
16591665
* Runs a `BuildTrigger` at a particular source revision.
16601666
*
1667+
* <p>To run a regional or global trigger, use the POST request that includes the location
1668+
* endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run).
1669+
* The POST request that does not include the location endpoint in the path can only be used when
1670+
* running global triggers.
1671+
*
16611672
* <p>Sample code:
16621673
*
16631674
* <pre>{@code
@@ -1690,6 +1701,11 @@ public final OperationFuture<Build, BuildOperationMetadata> runBuildTriggerAsync
16901701
/**
16911702
* Runs a `BuildTrigger` at a particular source revision.
16921703
*
1704+
* <p>To run a regional or global trigger, use the POST request that includes the location
1705+
* endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run).
1706+
* The POST request that does not include the location endpoint in the path can only be used when
1707+
* running global triggers.
1708+
*
16931709
* <p>Sample code:
16941710
*
16951711
* <pre>{@code
@@ -1722,6 +1738,11 @@ public final OperationFuture<Build, BuildOperationMetadata> runBuildTriggerAsync
17221738
/**
17231739
* Runs a `BuildTrigger` at a particular source revision.
17241740
*
1741+
* <p>To run a regional or global trigger, use the POST request that includes the location
1742+
* endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run).
1743+
* The POST request that does not include the location endpoint in the path can only be used when
1744+
* running global triggers.
1745+
*
17251746
* <p>Sample code:
17261747
*
17271748
* <pre>{@code

java-cloudbuild/google-cloud-build/src/main/java/com/google/cloud/devtools/cloudbuild/v1/stub/GrpcCloudBuildStub.java

Lines changed: 66 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.api.gax.rpc.OperationCallable;
2929
import com.google.api.gax.rpc.RequestParamsBuilder;
3030
import com.google.api.gax.rpc.UnaryCallable;
31+
import com.google.api.pathtemplate.PathTemplate;
3132
import com.google.cloudbuild.v1.ApproveBuildRequest;
3233
import com.google.cloudbuild.v1.Build;
3334
import com.google.cloudbuild.v1.BuildOperationMetadata;
@@ -294,6 +295,41 @@ public class GrpcCloudBuildStub extends CloudBuildStub {
294295
private final GrpcOperationsStub operationsStub;
295296
private final GrpcStubCallableFactory callableFactory;
296297

298+
private static final PathTemplate CREATE_BUILD_0_PATH_TEMPLATE =
299+
PathTemplate.create("projects/*/locations/{location=*}");
300+
private static final PathTemplate GET_BUILD_0_PATH_TEMPLATE =
301+
PathTemplate.create("projects/*/locations/{location=*}/builds/*");
302+
private static final PathTemplate LIST_BUILDS_0_PATH_TEMPLATE =
303+
PathTemplate.create("projects/*/locations/{location=*}");
304+
private static final PathTemplate CANCEL_BUILD_0_PATH_TEMPLATE =
305+
PathTemplate.create("projects/*/locations/{location=*}/builds/*");
306+
private static final PathTemplate RETRY_BUILD_0_PATH_TEMPLATE =
307+
PathTemplate.create("projects/*/locations/{location=*}/builds/*");
308+
private static final PathTemplate APPROVE_BUILD_0_PATH_TEMPLATE =
309+
PathTemplate.create("projects/*/locations/{location=*}/builds/*");
310+
private static final PathTemplate CREATE_BUILD_TRIGGER_0_PATH_TEMPLATE =
311+
PathTemplate.create("projects/*/locations/{location=*}");
312+
private static final PathTemplate GET_BUILD_TRIGGER_0_PATH_TEMPLATE =
313+
PathTemplate.create("projects/*/locations/{location=*}/triggers/*");
314+
private static final PathTemplate LIST_BUILD_TRIGGERS_0_PATH_TEMPLATE =
315+
PathTemplate.create("projects/*/locations/{location=*}");
316+
private static final PathTemplate DELETE_BUILD_TRIGGER_0_PATH_TEMPLATE =
317+
PathTemplate.create("projects/*/locations/{location=*}/triggers/*");
318+
private static final PathTemplate UPDATE_BUILD_TRIGGER_0_PATH_TEMPLATE =
319+
PathTemplate.create("projects/*/locations/{location=*}/triggers/*");
320+
private static final PathTemplate RUN_BUILD_TRIGGER_0_PATH_TEMPLATE =
321+
PathTemplate.create("projects/*/locations/{location=*}/triggers/*");
322+
private static final PathTemplate CREATE_WORKER_POOL_0_PATH_TEMPLATE =
323+
PathTemplate.create("projects/*/locations/{location=*}");
324+
private static final PathTemplate GET_WORKER_POOL_0_PATH_TEMPLATE =
325+
PathTemplate.create("projects/*/locations/{location=*}/workerPools/*");
326+
private static final PathTemplate DELETE_WORKER_POOL_0_PATH_TEMPLATE =
327+
PathTemplate.create("projects/*/locations/{location=*}/workerPools/*");
328+
private static final PathTemplate UPDATE_WORKER_POOL_0_PATH_TEMPLATE =
329+
PathTemplate.create("projects/*/locations/{location=*}/workerPools/*");
330+
private static final PathTemplate LIST_WORKER_POOLS_0_PATH_TEMPLATE =
331+
PathTemplate.create("projects/*/locations/{location=*}");
332+
297333
public static final GrpcCloudBuildStub create(CloudBuildStubSettings settings)
298334
throws IOException {
299335
return new GrpcCloudBuildStub(settings, ClientContext.create(settings));
@@ -338,8 +374,7 @@ protected GrpcCloudBuildStub(
338374
.setParamsExtractor(
339375
request -> {
340376
RequestParamsBuilder builder = RequestParamsBuilder.create();
341-
builder.add("parent", String.valueOf(request.getParent()));
342-
builder.add("project_id", String.valueOf(request.getProjectId()));
377+
builder.add(request.getParent(), "location", CREATE_BUILD_0_PATH_TEMPLATE);
343378
return builder.build();
344379
})
345380
.build();
@@ -349,9 +384,7 @@ protected GrpcCloudBuildStub(
349384
.setParamsExtractor(
350385
request -> {
351386
RequestParamsBuilder builder = RequestParamsBuilder.create();
352-
builder.add("id", String.valueOf(request.getId()));
353-
builder.add("name", String.valueOf(request.getName()));
354-
builder.add("project_id", String.valueOf(request.getProjectId()));
387+
builder.add(request.getName(), "location", GET_BUILD_0_PATH_TEMPLATE);
355388
return builder.build();
356389
})
357390
.build();
@@ -361,8 +394,7 @@ protected GrpcCloudBuildStub(
361394
.setParamsExtractor(
362395
request -> {
363396
RequestParamsBuilder builder = RequestParamsBuilder.create();
364-
builder.add("parent", String.valueOf(request.getParent()));
365-
builder.add("project_id", String.valueOf(request.getProjectId()));
397+
builder.add(request.getParent(), "location", LIST_BUILDS_0_PATH_TEMPLATE);
366398
return builder.build();
367399
})
368400
.build();
@@ -372,9 +404,7 @@ protected GrpcCloudBuildStub(
372404
.setParamsExtractor(
373405
request -> {
374406
RequestParamsBuilder builder = RequestParamsBuilder.create();
375-
builder.add("id", String.valueOf(request.getId()));
376-
builder.add("name", String.valueOf(request.getName()));
377-
builder.add("project_id", String.valueOf(request.getProjectId()));
407+
builder.add(request.getName(), "location", CANCEL_BUILD_0_PATH_TEMPLATE);
378408
return builder.build();
379409
})
380410
.build();
@@ -384,9 +414,7 @@ protected GrpcCloudBuildStub(
384414
.setParamsExtractor(
385415
request -> {
386416
RequestParamsBuilder builder = RequestParamsBuilder.create();
387-
builder.add("id", String.valueOf(request.getId()));
388-
builder.add("name", String.valueOf(request.getName()));
389-
builder.add("project_id", String.valueOf(request.getProjectId()));
417+
builder.add(request.getName(), "location", RETRY_BUILD_0_PATH_TEMPLATE);
390418
return builder.build();
391419
})
392420
.build();
@@ -396,7 +424,7 @@ protected GrpcCloudBuildStub(
396424
.setParamsExtractor(
397425
request -> {
398426
RequestParamsBuilder builder = RequestParamsBuilder.create();
399-
builder.add("name", String.valueOf(request.getName()));
427+
builder.add(request.getName(), "location", APPROVE_BUILD_0_PATH_TEMPLATE);
400428
return builder.build();
401429
})
402430
.build();
@@ -406,8 +434,8 @@ protected GrpcCloudBuildStub(
406434
.setParamsExtractor(
407435
request -> {
408436
RequestParamsBuilder builder = RequestParamsBuilder.create();
409-
builder.add("parent", String.valueOf(request.getParent()));
410-
builder.add("project_id", String.valueOf(request.getProjectId()));
437+
builder.add(
438+
request.getParent(), "location", CREATE_BUILD_TRIGGER_0_PATH_TEMPLATE);
411439
return builder.build();
412440
})
413441
.build();
@@ -417,9 +445,7 @@ protected GrpcCloudBuildStub(
417445
.setParamsExtractor(
418446
request -> {
419447
RequestParamsBuilder builder = RequestParamsBuilder.create();
420-
builder.add("name", String.valueOf(request.getName()));
421-
builder.add("project_id", String.valueOf(request.getProjectId()));
422-
builder.add("trigger_id", String.valueOf(request.getTriggerId()));
448+
builder.add(request.getName(), "location", GET_BUILD_TRIGGER_0_PATH_TEMPLATE);
423449
return builder.build();
424450
})
425451
.build();
@@ -430,8 +456,8 @@ protected GrpcCloudBuildStub(
430456
.setParamsExtractor(
431457
request -> {
432458
RequestParamsBuilder builder = RequestParamsBuilder.create();
433-
builder.add("parent", String.valueOf(request.getParent()));
434-
builder.add("project_id", String.valueOf(request.getProjectId()));
459+
builder.add(
460+
request.getParent(), "location", LIST_BUILD_TRIGGERS_0_PATH_TEMPLATE);
435461
return builder.build();
436462
})
437463
.build();
@@ -441,9 +467,7 @@ protected GrpcCloudBuildStub(
441467
.setParamsExtractor(
442468
request -> {
443469
RequestParamsBuilder builder = RequestParamsBuilder.create();
444-
builder.add("name", String.valueOf(request.getName()));
445-
builder.add("project_id", String.valueOf(request.getProjectId()));
446-
builder.add("trigger_id", String.valueOf(request.getTriggerId()));
470+
builder.add(request.getName(), "location", DELETE_BUILD_TRIGGER_0_PATH_TEMPLATE);
447471
return builder.build();
448472
})
449473
.build();
@@ -453,11 +477,12 @@ protected GrpcCloudBuildStub(
453477
.setParamsExtractor(
454478
request -> {
455479
RequestParamsBuilder builder = RequestParamsBuilder.create();
456-
builder.add("project_id", String.valueOf(request.getProjectId()));
457-
builder.add(
458-
"trigger.resource_name",
459-
String.valueOf(request.getTrigger().getResourceName()));
460-
builder.add("trigger_id", String.valueOf(request.getTriggerId()));
480+
if (request.getTrigger() != null) {
481+
builder.add(
482+
request.getTrigger().getResourceName(),
483+
"location",
484+
UPDATE_BUILD_TRIGGER_0_PATH_TEMPLATE);
485+
}
461486
return builder.build();
462487
})
463488
.build();
@@ -467,9 +492,7 @@ protected GrpcCloudBuildStub(
467492
.setParamsExtractor(
468493
request -> {
469494
RequestParamsBuilder builder = RequestParamsBuilder.create();
470-
builder.add("name", String.valueOf(request.getName()));
471-
builder.add("project_id", String.valueOf(request.getProjectId()));
472-
builder.add("trigger_id", String.valueOf(request.getTriggerId()));
495+
builder.add(request.getName(), "location", RUN_BUILD_TRIGGER_0_PATH_TEMPLATE);
473496
return builder.build();
474497
})
475498
.build();
@@ -493,7 +516,7 @@ protected GrpcCloudBuildStub(
493516
.setParamsExtractor(
494517
request -> {
495518
RequestParamsBuilder builder = RequestParamsBuilder.create();
496-
builder.add("parent", String.valueOf(request.getParent()));
519+
builder.add(request.getParent(), "location", CREATE_WORKER_POOL_0_PATH_TEMPLATE);
497520
return builder.build();
498521
})
499522
.build();
@@ -503,7 +526,7 @@ protected GrpcCloudBuildStub(
503526
.setParamsExtractor(
504527
request -> {
505528
RequestParamsBuilder builder = RequestParamsBuilder.create();
506-
builder.add("name", String.valueOf(request.getName()));
529+
builder.add(request.getName(), "location", GET_WORKER_POOL_0_PATH_TEMPLATE);
507530
return builder.build();
508531
})
509532
.build();
@@ -513,7 +536,7 @@ protected GrpcCloudBuildStub(
513536
.setParamsExtractor(
514537
request -> {
515538
RequestParamsBuilder builder = RequestParamsBuilder.create();
516-
builder.add("name", String.valueOf(request.getName()));
539+
builder.add(request.getName(), "location", DELETE_WORKER_POOL_0_PATH_TEMPLATE);
517540
return builder.build();
518541
})
519542
.build();
@@ -523,8 +546,12 @@ protected GrpcCloudBuildStub(
523546
.setParamsExtractor(
524547
request -> {
525548
RequestParamsBuilder builder = RequestParamsBuilder.create();
526-
builder.add(
527-
"worker_pool.name", String.valueOf(request.getWorkerPool().getName()));
549+
if (request.getWorkerPool() != null) {
550+
builder.add(
551+
request.getWorkerPool().getName(),
552+
"location",
553+
UPDATE_WORKER_POOL_0_PATH_TEMPLATE);
554+
}
528555
return builder.build();
529556
})
530557
.build();
@@ -535,7 +562,8 @@ protected GrpcCloudBuildStub(
535562
.setParamsExtractor(
536563
request -> {
537564
RequestParamsBuilder builder = RequestParamsBuilder.create();
538-
builder.add("parent", String.valueOf(request.getParent()));
565+
builder.add(
566+
request.getParent(), "location", LIST_WORKER_POOLS_0_PATH_TEMPLATE);
539567
return builder.build();
540568
})
541569
.build();

0 commit comments

Comments
 (0)