Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit ec64ba7

Browse files
feat: Enable REST transport for most of Java and Go clients (#190)
* 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 * deps: adding gax-httpjson * 🦉 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> Co-authored-by: Tomo Suzuki <[email protected]>
1 parent 44e44e0 commit ec64ba7

File tree

22 files changed

+1508
-8
lines changed

22 files changed

+1508
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ If you are using Maven, add this to your pom.xml file:
2222
<dependency>
2323
<groupId>com.google.cloud</groupId>
2424
<artifactId>google-cloud-private-catalog</artifactId>
25-
<version>0.4.0</version>
25+
<version>0.4.1</version>
2626
</dependency>
2727
```
2828

2929
If you are using Gradle without BOM, add this to your dependencies
3030

3131
```Groovy
32-
implementation 'com.google.cloud:google-cloud-private-catalog:0.4.0'
32+
implementation 'com.google.cloud:google-cloud-private-catalog:0.4.1'
3333
```
3434

3535
If you are using SBT, add this to your dependencies
3636

3737
```Scala
38-
libraryDependencies += "com.google.cloud" % "google-cloud-private-catalog" % "0.4.0"
38+
libraryDependencies += "com.google.cloud" % "google-cloud-private-catalog" % "0.4.1"
3939
```
4040

4141
## Authentication

google-cloud-private-catalog/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
<groupId>com.google.api</groupId>
5959
<artifactId>gax-grpc</artifactId>
6060
</dependency>
61+
<dependency>
62+
<groupId>com.google.api</groupId>
63+
<artifactId>gax-httpjson</artifactId>
64+
</dependency>
6165

6266
<!-- Test dependencies -->
6367
<dependency>
@@ -73,12 +77,24 @@
7377
<scope>test</scope>
7478
</dependency>
7579
<!-- Need testing utility classes for generated gRPC clients tests -->
80+
<dependency>
81+
<groupId>com.google.api</groupId>
82+
<artifactId>gax</artifactId>
83+
<classifier>testlib</classifier>
84+
<scope>test</scope>
85+
</dependency>
7686
<dependency>
7787
<groupId>com.google.api</groupId>
7888
<artifactId>gax-grpc</artifactId>
7989
<classifier>testlib</classifier>
8090
<scope>test</scope>
8191
</dependency>
92+
<dependency>
93+
<groupId>com.google.api</groupId>
94+
<artifactId>gax-httpjson</artifactId>
95+
<classifier>testlib</classifier>
96+
<scope>test</scope>
97+
</dependency>
8298
</dependencies>
8399

84100
<profiles>

google-cloud-private-catalog/src/main/java/com/google/cloud/privatecatalog/v1beta1/PrivateCatalogClient.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@
120120
* PrivateCatalogClient privateCatalogClient = PrivateCatalogClient.create(privateCatalogSettings);
121121
* }</pre>
122122
*
123+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
124+
* the wire:
125+
*
126+
* <pre>{@code
127+
* // This snippet has been automatically generated for illustrative purposes only.
128+
* // It may require modifications to work in your environment.
129+
* PrivateCatalogSettings privateCatalogSettings =
130+
* PrivateCatalogSettings.newBuilder()
131+
* .setTransportChannelProvider(
132+
* PrivateCatalogSettings.defaultHttpJsonTransportProviderBuilder().build())
133+
* .build();
134+
* PrivateCatalogClient privateCatalogClient = PrivateCatalogClient.create(privateCatalogSettings);
135+
* }</pre>
136+
*
123137
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
124138
*/
125139
@BetaApi

google-cloud-private-catalog/src/main/java/com/google/cloud/privatecatalog/v1beta1/PrivateCatalogSettings.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.api.gax.core.GoogleCredentialsProvider;
2626
import com.google.api.gax.core.InstantiatingExecutorProvider;
2727
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
28+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2829
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2930
import com.google.api.gax.rpc.ClientContext;
3031
import com.google.api.gax.rpc.ClientSettings;
@@ -121,11 +122,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
121122
return PrivateCatalogStubSettings.defaultCredentialsProviderBuilder();
122123
}
123124

124-
/** Returns a builder for the default ChannelProvider for this service. */
125+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
125126
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
126127
return PrivateCatalogStubSettings.defaultGrpcTransportProviderBuilder();
127128
}
128129

130+
/** Returns a builder for the default REST ChannelProvider for this service. */
131+
@BetaApi
132+
public static InstantiatingHttpJsonChannelProvider.Builder
133+
defaultHttpJsonTransportProviderBuilder() {
134+
return PrivateCatalogStubSettings.defaultHttpJsonTransportProviderBuilder();
135+
}
136+
129137
public static TransportChannelProvider defaultTransportChannelProvider() {
130138
return PrivateCatalogStubSettings.defaultTransportChannelProvider();
131139
}
@@ -135,11 +143,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
135143
return PrivateCatalogStubSettings.defaultApiClientHeaderProviderBuilder();
136144
}
137145

138-
/** Returns a new builder for this class. */
146+
/** Returns a new gRPC builder for this class. */
139147
public static Builder newBuilder() {
140148
return Builder.createDefault();
141149
}
142150

151+
/** Returns a new REST builder for this class. */
152+
@BetaApi
153+
public static Builder newHttpJsonBuilder() {
154+
return Builder.createHttpJsonDefault();
155+
}
156+
143157
/** Returns a new builder for this class. */
144158
public static Builder newBuilder(ClientContext clientContext) {
145159
return new Builder(clientContext);
@@ -177,6 +191,11 @@ private static Builder createDefault() {
177191
return new Builder(PrivateCatalogStubSettings.newBuilder());
178192
}
179193

194+
@BetaApi
195+
private static Builder createHttpJsonDefault() {
196+
return new Builder(PrivateCatalogStubSettings.newHttpJsonBuilder());
197+
}
198+
180199
public PrivateCatalogStubSettings.Builder getStubSettingsBuilder() {
181200
return ((PrivateCatalogStubSettings.Builder) getStubSettings());
182201
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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.privatecatalog.v1beta1.stub;
18+
19+
import com.google.api.core.BetaApi;
20+
import com.google.api.gax.httpjson.HttpJsonCallSettings;
21+
import com.google.api.gax.httpjson.HttpJsonCallableFactory;
22+
import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable;
23+
import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
24+
import com.google.api.gax.httpjson.longrunning.stub.OperationsStub;
25+
import com.google.api.gax.rpc.BatchingCallSettings;
26+
import com.google.api.gax.rpc.ClientContext;
27+
import com.google.api.gax.rpc.OperationCallSettings;
28+
import com.google.api.gax.rpc.OperationCallable;
29+
import com.google.api.gax.rpc.PagedCallSettings;
30+
import com.google.api.gax.rpc.ServerStreamingCallSettings;
31+
import com.google.api.gax.rpc.ServerStreamingCallable;
32+
import com.google.api.gax.rpc.UnaryCallSettings;
33+
import com.google.api.gax.rpc.UnaryCallable;
34+
import com.google.longrunning.Operation;
35+
import javax.annotation.Generated;
36+
37+
// AUTO-GENERATED DOCUMENTATION AND CLASS.
38+
/**
39+
* REST callable factory implementation for the PrivateCatalog service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@BetaApi
44+
@Generated("by gapic-generator-java")
45+
public class HttpJsonPrivateCatalogCallableFactory
46+
implements HttpJsonStubCallableFactory<Operation, OperationsStub> {
47+
48+
@Override
49+
public <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUnaryCallable(
50+
HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings,
51+
UnaryCallSettings<RequestT, ResponseT> callSettings,
52+
ClientContext clientContext) {
53+
return HttpJsonCallableFactory.createUnaryCallable(
54+
httpJsonCallSettings, callSettings, clientContext);
55+
}
56+
57+
@Override
58+
public <RequestT, ResponseT, PagedListResponseT>
59+
UnaryCallable<RequestT, PagedListResponseT> createPagedCallable(
60+
HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings,
61+
PagedCallSettings<RequestT, ResponseT, PagedListResponseT> callSettings,
62+
ClientContext clientContext) {
63+
return HttpJsonCallableFactory.createPagedCallable(
64+
httpJsonCallSettings, callSettings, clientContext);
65+
}
66+
67+
@Override
68+
public <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBatchingCallable(
69+
HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings,
70+
BatchingCallSettings<RequestT, ResponseT> callSettings,
71+
ClientContext clientContext) {
72+
return HttpJsonCallableFactory.createBatchingCallable(
73+
httpJsonCallSettings, callSettings, clientContext);
74+
}
75+
76+
@BetaApi(
77+
"The surface for long-running operations is not stable yet and may change in the future.")
78+
@Override
79+
public <RequestT, ResponseT, MetadataT>
80+
OperationCallable<RequestT, ResponseT, MetadataT> createOperationCallable(
81+
HttpJsonCallSettings<RequestT, Operation> httpJsonCallSettings,
82+
OperationCallSettings<RequestT, ResponseT, MetadataT> callSettings,
83+
ClientContext clientContext,
84+
OperationsStub operationsStub) {
85+
UnaryCallable<RequestT, Operation> innerCallable =
86+
HttpJsonCallableFactory.createBaseUnaryCallable(
87+
httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
88+
HttpJsonOperationSnapshotCallable<RequestT, Operation> initialCallable =
89+
new HttpJsonOperationSnapshotCallable<RequestT, Operation>(
90+
innerCallable,
91+
httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
92+
return HttpJsonCallableFactory.createOperationCallable(
93+
callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
94+
}
95+
96+
@Override
97+
public <RequestT, ResponseT>
98+
ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable(
99+
HttpJsonCallSettings<RequestT, ResponseT> httpJsonCallSettings,
100+
ServerStreamingCallSettings<RequestT, ResponseT> callSettings,
101+
ClientContext clientContext) {
102+
return HttpJsonCallableFactory.createServerStreamingCallable(
103+
httpJsonCallSettings, callSettings, clientContext);
104+
}
105+
}

0 commit comments

Comments
 (0)