Skip to content

Commit 022f1a2

Browse files
gcf-owl-bot[bot]Neenu1995blakeli0
authored
feat: Enable REST transport for most of Java and Go clients (#885)
* chore(deps): upgrade gapic-generator-java to 2.8.0 and update gax-java to 2.18.1 PiperOrigin-RevId: 450543911 Source-Link: googleapis/googleapis@5528344 Source-Link: https://github.com/googleapis/googleapis-gen/commit/9f6775cab1958982b88967a43e5e806af0f135db Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWY2Nzc1Y2FiMTk1ODk4MmI4ODk2N2E0M2U1ZTgwNmFmMGYxMzVkYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Integrate new gapic-generator-java and rules_gapic PiperOrigin-RevId: 454027580 Source-Link: googleapis/googleapis@1b22277 Source-Link: https://github.com/googleapis/googleapis-gen/commit/e04cea20d0d12eb5c3bdb360a9e72b654edcb638 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTA0Y2VhMjBkMGQxMmViNWMzYmRiMzYwYTllNzJiNjU0ZWRjYjYzOCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Enable REST transport for most of Java and Go clients PiperOrigin-RevId: 456641589 Source-Link: googleapis/googleapis@8a251f5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update pom.xml * Exclude a few dependencies in dependency list check * Exclude dependencies.sh from owlbot * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Exclude a few dependencies from dependency list check Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Neenu Shaji <[email protected]> Co-authored-by: Blake Li <[email protected]>
1 parent 889ddce commit 022f1a2

File tree

11 files changed

+1370
-30
lines changed

11 files changed

+1370
-30
lines changed

java-containeranalysis/.kokoro/dependencies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ function completenessCheck() {
6666
# This is stripped from the output as it is not present in the flattened pom.
6767
# Only dependencies with 'compile' or 'runtime' scope are included from original dependency list.
6868
msg "Generating dependency list using original pom..."
69-
mvn dependency:list -f pom.xml -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' | sed -e 's/ --.*//' >.org-list.txt
69+
mvn dependency:list -f pom.xml -DexcludeArtifactIds=commons-codec,commons-logging,opencensus-api,opencensus-contrib-http-util,httpclient,httpcore -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' | sed -e 's/ --.*//' >.org-list.txt
7070

7171
# Output dep list generated using the flattened pom (only 'compile' and 'runtime' scopes)
7272
msg "Generating dependency list using flattened pom..."
73-
mvn dependency:list -f .flattened-pom.xml -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' >.new-list.txt
73+
mvn dependency:list -f .flattened-pom.xml -DexcludeArtifactIds=commons-codec,commons-logging,opencensus-api,opencensus-contrib-http-util,httpclient,httpcore -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' >.new-list.txt
7474

7575
# Compare two dependency lists
7676
msg "Comparing dependency lists..."

java-containeranalysis/google-cloud-containeranalysis/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
<groupId>com.google.api</groupId>
6363
<artifactId>gax-grpc</artifactId>
6464
</dependency>
65+
<dependency>
66+
<groupId>com.google.api</groupId>
67+
<artifactId>gax-httpjson</artifactId>
68+
</dependency>
6569
<dependency>
6670
<groupId>org.threeten</groupId>
6771
<artifactId>threetenbp</artifactId>
@@ -93,12 +97,24 @@
9397
<scope>test</scope>
9498
</dependency>
9599
<!-- Need testing utility classes for generated gRPC clients tests -->
100+
<dependency>
101+
<groupId>com.google.api</groupId>
102+
<artifactId>gax</artifactId>
103+
<classifier>testlib</classifier>
104+
<scope>test</scope>
105+
</dependency>
96106
<dependency>
97107
<groupId>com.google.api</groupId>
98108
<artifactId>gax-grpc</artifactId>
99109
<classifier>testlib</classifier>
100110
<scope>test</scope>
101111
</dependency>
112+
<dependency>
113+
<groupId>com.google.api</groupId>
114+
<artifactId>gax-httpjson</artifactId>
115+
<classifier>testlib</classifier>
116+
<scope>test</scope>
117+
</dependency>
102118
</dependencies>
103119

104120
<profiles>

java-containeranalysis/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java

Lines changed: 97 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.cloud.devtools.containeranalysis.v1;
1818

19-
import com.google.api.core.BetaApi;
2019
import com.google.api.gax.core.BackgroundResource;
2120
import com.google.api.gax.rpc.UnaryCallable;
2221
import com.google.api.resourcenames.ResourceName;
@@ -57,7 +56,25 @@
5756
* // This snippet has been automatically generated for illustrative purposes only.
5857
* // It may require modifications to work in your environment.
5958
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
60-
* ResourceName resource = ProjectName.of("[PROJECT]");
59+
* ResourceName resource =
60+
* new ResourceName() {
61+
* {@literal @}Override
62+
* public Map<String, String> getFieldValuesMap() {
63+
* Map<String, String> fieldValuesMap = new HashMap<>();
64+
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
65+
* return fieldValuesMap;
66+
* }
67+
*
68+
* {@literal @}Override
69+
* public String getFieldValue(String fieldName) {
70+
* return getFieldValuesMap().get(fieldName);
71+
* }
72+
*
73+
* {@literal @}Override
74+
* public String toString() {
75+
* return "projects/project-8432/notes/note-8432";
76+
* }
77+
* };
6178
* Policy policy = Policy.newBuilder().build();
6279
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
6380
* }
@@ -114,6 +131,21 @@
114131
* ContainerAnalysisClient.create(containerAnalysisSettings);
115132
* }</pre>
116133
*
134+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
135+
* the wire:
136+
*
137+
* <pre>{@code
138+
* // This snippet has been automatically generated for illustrative purposes only.
139+
* // It may require modifications to work in your environment.
140+
* ContainerAnalysisSettings containerAnalysisSettings =
141+
* ContainerAnalysisSettings.newBuilder()
142+
* .setTransportChannelProvider(
143+
* ContainerAnalysisSettings.defaultHttpJsonTransportProviderBuilder().build())
144+
* .build();
145+
* ContainerAnalysisClient containerAnalysisClient =
146+
* ContainerAnalysisClient.create(containerAnalysisSettings);
147+
* }</pre>
148+
*
117149
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
118150
*/
119151
@Generated("by gapic-generator-java")
@@ -147,7 +179,6 @@ public static final ContainerAnalysisClient create(ContainerAnalysisSettings set
147179
* Constructs an instance of ContainerAnalysisClient, using the given stub for making calls. This
148180
* is for advanced usage - prefer using create(ContainerAnalysisSettings).
149181
*/
150-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
151182
public static final ContainerAnalysisClient create(ContainerAnalysisStub stub) {
152183
return new ContainerAnalysisClient(stub);
153184
}
@@ -162,7 +193,6 @@ protected ContainerAnalysisClient(ContainerAnalysisSettings settings) throws IOE
162193
this.stub = ((ContainerAnalysisStubSettings) settings.getStubSettings()).createStub();
163194
}
164195

165-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
166196
protected ContainerAnalysisClient(ContainerAnalysisStub stub) {
167197
this.settings = null;
168198
this.stub = stub;
@@ -172,7 +202,6 @@ public final ContainerAnalysisSettings getSettings() {
172202
return settings;
173203
}
174204

175-
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
176205
public ContainerAnalysisStub getStub() {
177206
return stub;
178207
}
@@ -192,7 +221,25 @@ public ContainerAnalysisStub getStub() {
192221
* // This snippet has been automatically generated for illustrative purposes only.
193222
* // It may require modifications to work in your environment.
194223
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
195-
* ResourceName resource = ProjectName.of("[PROJECT]");
224+
* ResourceName resource =
225+
* new ResourceName() {
226+
* {@literal @}Override
227+
* public Map<String, String> getFieldValuesMap() {
228+
* Map<String, String> fieldValuesMap = new HashMap<>();
229+
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
230+
* return fieldValuesMap;
231+
* }
232+
*
233+
* {@literal @}Override
234+
* public String getFieldValue(String fieldName) {
235+
* return getFieldValuesMap().get(fieldName);
236+
* }
237+
*
238+
* {@literal @}Override
239+
* public String toString() {
240+
* return "projects/project-8432/notes/note-8432";
241+
* }
242+
* };
196243
* Policy policy = Policy.newBuilder().build();
197244
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
198245
* }
@@ -265,7 +312,7 @@ public final Policy setIamPolicy(String resource, Policy policy) {
265312
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
266313
* SetIamPolicyRequest request =
267314
* SetIamPolicyRequest.newBuilder()
268-
* .setResource(ProjectName.of("[PROJECT]").toString())
315+
* .setResource("SetIamPolicyRequest1223629066".toString())
269316
* .setPolicy(Policy.newBuilder().build())
270317
* .setUpdateMask(FieldMask.newBuilder().build())
271318
* .build();
@@ -297,7 +344,7 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) {
297344
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
298345
* SetIamPolicyRequest request =
299346
* SetIamPolicyRequest.newBuilder()
300-
* .setResource(ProjectName.of("[PROJECT]").toString())
347+
* .setResource("SetIamPolicyRequest1223629066".toString())
301348
* .setPolicy(Policy.newBuilder().build())
302349
* .setUpdateMask(FieldMask.newBuilder().build())
303350
* .build();
@@ -326,7 +373,25 @@ public final UnaryCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() {
326373
* // This snippet has been automatically generated for illustrative purposes only.
327374
* // It may require modifications to work in your environment.
328375
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
329-
* ResourceName resource = ProjectName.of("[PROJECT]");
376+
* ResourceName resource =
377+
* new ResourceName() {
378+
* {@literal @}Override
379+
* public Map<String, String> getFieldValuesMap() {
380+
* Map<String, String> fieldValuesMap = new HashMap<>();
381+
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
382+
* return fieldValuesMap;
383+
* }
384+
*
385+
* {@literal @}Override
386+
* public String getFieldValue(String fieldName) {
387+
* return getFieldValuesMap().get(fieldName);
388+
* }
389+
*
390+
* {@literal @}Override
391+
* public String toString() {
392+
* return "projects/project-8432/notes/note-8432";
393+
* }
394+
* };
330395
* Policy response = containerAnalysisClient.getIamPolicy(resource);
331396
* }
332397
* }</pre>
@@ -389,7 +454,7 @@ public final Policy getIamPolicy(String resource) {
389454
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
390455
* GetIamPolicyRequest request =
391456
* GetIamPolicyRequest.newBuilder()
392-
* .setResource(ProjectName.of("[PROJECT]").toString())
457+
* .setResource("GetIamPolicyRequest-1527610370".toString())
393458
* .setOptions(GetPolicyOptions.newBuilder().build())
394459
* .build();
395460
* Policy response = containerAnalysisClient.getIamPolicy(request);
@@ -420,7 +485,7 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) {
420485
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
421486
* GetIamPolicyRequest request =
422487
* GetIamPolicyRequest.newBuilder()
423-
* .setResource(ProjectName.of("[PROJECT]").toString())
488+
* .setResource("GetIamPolicyRequest-1527610370".toString())
424489
* .setOptions(GetPolicyOptions.newBuilder().build())
425490
* .build();
426491
* ApiFuture<Policy> future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
@@ -447,7 +512,25 @@ public final UnaryCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() {
447512
* // This snippet has been automatically generated for illustrative purposes only.
448513
* // It may require modifications to work in your environment.
449514
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
450-
* ResourceName resource = ProjectName.of("[PROJECT]");
515+
* ResourceName resource =
516+
* new ResourceName() {
517+
* {@literal @}Override
518+
* public Map<String, String> getFieldValuesMap() {
519+
* Map<String, String> fieldValuesMap = new HashMap<>();
520+
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
521+
* return fieldValuesMap;
522+
* }
523+
*
524+
* {@literal @}Override
525+
* public String getFieldValue(String fieldName) {
526+
* return getFieldValuesMap().get(fieldName);
527+
* }
528+
*
529+
* {@literal @}Override
530+
* public String toString() {
531+
* return "projects/project-8432/notes/note-8432";
532+
* }
533+
* };
451534
* List<String> permissions = new ArrayList<>();
452535
* TestIamPermissionsResponse response =
453536
* containerAnalysisClient.testIamPermissions(resource, permissions);
@@ -525,7 +608,7 @@ public final TestIamPermissionsResponse testIamPermissions(
525608
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
526609
* TestIamPermissionsRequest request =
527610
* TestIamPermissionsRequest.newBuilder()
528-
* .setResource(ProjectName.of("[PROJECT]").toString())
611+
* .setResource("TestIamPermissionsRequest942398222".toString())
529612
* .addAllPermissions(new ArrayList<String>())
530613
* .build();
531614
* TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
@@ -555,7 +638,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq
555638
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
556639
* TestIamPermissionsRequest request =
557640
* TestIamPermissionsRequest.newBuilder()
558-
* .setResource(ProjectName.of("[PROJECT]").toString())
641+
* .setResource("TestIamPermissionsRequest942398222".toString())
559642
* .addAllPermissions(new ArrayList<String>())
560643
* .build();
561644
* ApiFuture<TestIamPermissionsResponse> future =

java-containeranalysis/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.api.gax.core.GoogleCredentialsProvider;
2222
import com.google.api.gax.core.InstantiatingExecutorProvider;
2323
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
24+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2425
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2526
import com.google.api.gax.rpc.ClientContext;
2627
import com.google.api.gax.rpc.ClientSettings;
@@ -125,11 +126,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
125126
return ContainerAnalysisStubSettings.defaultCredentialsProviderBuilder();
126127
}
127128

128-
/** Returns a builder for the default ChannelProvider for this service. */
129+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
129130
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
130131
return ContainerAnalysisStubSettings.defaultGrpcTransportProviderBuilder();
131132
}
132133

134+
/** Returns a builder for the default REST ChannelProvider for this service. */
135+
@BetaApi
136+
public static InstantiatingHttpJsonChannelProvider.Builder
137+
defaultHttpJsonTransportProviderBuilder() {
138+
return ContainerAnalysisStubSettings.defaultHttpJsonTransportProviderBuilder();
139+
}
140+
133141
public static TransportChannelProvider defaultTransportChannelProvider() {
134142
return ContainerAnalysisStubSettings.defaultTransportChannelProvider();
135143
}
@@ -139,11 +147,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
139147
return ContainerAnalysisStubSettings.defaultApiClientHeaderProviderBuilder();
140148
}
141149

142-
/** Returns a new builder for this class. */
150+
/** Returns a new gRPC builder for this class. */
143151
public static Builder newBuilder() {
144152
return Builder.createDefault();
145153
}
146154

155+
/** Returns a new REST builder for this class. */
156+
@BetaApi
157+
public static Builder newHttpJsonBuilder() {
158+
return Builder.createHttpJsonDefault();
159+
}
160+
147161
/** Returns a new builder for this class. */
148162
public static Builder newBuilder(ClientContext clientContext) {
149163
return new Builder(clientContext);
@@ -181,6 +195,11 @@ private static Builder createDefault() {
181195
return new Builder(ContainerAnalysisStubSettings.newBuilder());
182196
}
183197

198+
@BetaApi
199+
private static Builder createHttpJsonDefault() {
200+
return new Builder(ContainerAnalysisStubSettings.newHttpJsonBuilder());
201+
}
202+
184203
public ContainerAnalysisStubSettings.Builder getStubSettingsBuilder() {
185204
return ((ContainerAnalysisStubSettings.Builder) getStubSettings());
186205
}

java-containeranalysis/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,25 @@
3939
* // This snippet has been automatically generated for illustrative purposes only.
4040
* // It may require modifications to work in your environment.
4141
* try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
42-
* ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]");
42+
* ResourceName resource =
43+
* new ResourceName() {
44+
* {@literal @}Override
45+
* public Map<String, String> getFieldValuesMap() {
46+
* Map<String, String> fieldValuesMap = new HashMap<>();
47+
* fieldValuesMap.put("resource", "projects/project-8432/notes/note-8432");
48+
* return fieldValuesMap;
49+
* }
50+
*
51+
* {@literal @}Override
52+
* public String getFieldValue(String fieldName) {
53+
* return getFieldValuesMap().get(fieldName);
54+
* }
55+
*
56+
* {@literal @}Override
57+
* public String toString() {
58+
* return "projects/project-8432/notes/note-8432";
59+
* }
60+
* };
4361
* Policy policy = Policy.newBuilder().build();
4462
* Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
4563
* }

0 commit comments

Comments
 (0)