Skip to content

Commit 6a86faa

Browse files
feat: Enable REST transport for most of Java and Go clients (googleapis#685)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: googleapis/googleapis@8a251f5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9
1 parent 21a9330 commit 6a86faa

File tree

17 files changed

+989
-7
lines changed

17 files changed

+989
-7
lines changed

java-phishingprotection/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ implementation 'com.google.cloud:google-cloud-phishingprotection'
5959
If you are using Gradle without BOM, add this to your dependencies
6060

6161
```Groovy
62-
implementation 'com.google.cloud:google-cloud-phishingprotection:0.33.0'
62+
implementation 'com.google.cloud:google-cloud-phishingprotection:0.33.1'
6363
```
6464

6565
If you are using SBT, add this to your dependencies
6666

6767
```Scala
68-
libraryDependencies += "com.google.cloud" % "google-cloud-phishingprotection" % "0.33.0"
68+
libraryDependencies += "com.google.cloud" % "google-cloud-phishingprotection" % "0.33.1"
6969
```
7070

7171
## Authentication

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

+16
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
<dependency>
6266
<groupId>org.threeten</groupId>
6367
<artifactId>threetenbp</artifactId>
@@ -76,12 +80,24 @@
7680
<scope>test</scope>
7781
</dependency>
7882
<!-- Need testing utility classes for generated gRPC clients tests -->
83+
<dependency>
84+
<groupId>com.google.api</groupId>
85+
<artifactId>gax</artifactId>
86+
<classifier>testlib</classifier>
87+
<scope>test</scope>
88+
</dependency>
7989
<dependency>
8090
<groupId>com.google.api</groupId>
8191
<artifactId>gax-grpc</artifactId>
8292
<classifier>testlib</classifier>
8393
<scope>test</scope>
8494
</dependency>
95+
<dependency>
96+
<groupId>com.google.api</groupId>
97+
<artifactId>gax-httpjson</artifactId>
98+
<classifier>testlib</classifier>
99+
<scope>test</scope>
100+
</dependency>
85101
</dependencies>
86102

87103
<profiles>

java-phishingprotection/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Client.java

+16
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,22 @@
9898
* PhishingProtectionServiceV1Beta1Client.create(phishingProtectionServiceV1Beta1Settings);
9999
* }</pre>
100100
*
101+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
102+
* the wire:
103+
*
104+
* <pre>{@code
105+
* // This snippet has been automatically generated for illustrative purposes only.
106+
* // It may require modifications to work in your environment.
107+
* PhishingProtectionServiceV1Beta1Settings phishingProtectionServiceV1Beta1Settings =
108+
* PhishingProtectionServiceV1Beta1Settings.newBuilder()
109+
* .setTransportChannelProvider(
110+
* PhishingProtectionServiceV1Beta1Settings.defaultHttpJsonTransportProviderBuilder()
111+
* .build())
112+
* .build();
113+
* PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client =
114+
* PhishingProtectionServiceV1Beta1Client.create(phishingProtectionServiceV1Beta1Settings);
115+
* }</pre>
116+
*
101117
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
102118
*/
103119
@BetaApi

java-phishingprotection/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Settings.java

+21-2
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;
@@ -106,11 +107,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
106107
return PhishingProtectionServiceV1Beta1StubSettings.defaultCredentialsProviderBuilder();
107108
}
108109

109-
/** Returns a builder for the default ChannelProvider for this service. */
110+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
110111
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
111112
return PhishingProtectionServiceV1Beta1StubSettings.defaultGrpcTransportProviderBuilder();
112113
}
113114

115+
/** Returns a builder for the default REST ChannelProvider for this service. */
116+
@BetaApi
117+
public static InstantiatingHttpJsonChannelProvider.Builder
118+
defaultHttpJsonTransportProviderBuilder() {
119+
return PhishingProtectionServiceV1Beta1StubSettings.defaultHttpJsonTransportProviderBuilder();
120+
}
121+
114122
public static TransportChannelProvider defaultTransportChannelProvider() {
115123
return PhishingProtectionServiceV1Beta1StubSettings.defaultTransportChannelProvider();
116124
}
@@ -120,11 +128,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
120128
return PhishingProtectionServiceV1Beta1StubSettings.defaultApiClientHeaderProviderBuilder();
121129
}
122130

123-
/** Returns a new builder for this class. */
131+
/** Returns a new gRPC builder for this class. */
124132
public static Builder newBuilder() {
125133
return Builder.createDefault();
126134
}
127135

136+
/** Returns a new REST builder for this class. */
137+
@BetaApi
138+
public static Builder newHttpJsonBuilder() {
139+
return Builder.createHttpJsonDefault();
140+
}
141+
128142
/** Returns a new builder for this class. */
129143
public static Builder newBuilder(ClientContext clientContext) {
130144
return new Builder(clientContext);
@@ -163,6 +177,11 @@ private static Builder createDefault() {
163177
return new Builder(PhishingProtectionServiceV1Beta1StubSettings.newBuilder());
164178
}
165179

180+
@BetaApi
181+
private static Builder createHttpJsonDefault() {
182+
return new Builder(PhishingProtectionServiceV1Beta1StubSettings.newHttpJsonBuilder());
183+
}
184+
166185
public PhishingProtectionServiceV1Beta1StubSettings.Builder getStubSettingsBuilder() {
167186
return ((PhishingProtectionServiceV1Beta1StubSettings.Builder) getStubSettings());
168187
}
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.phishingprotection.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 PhishingProtectionServiceV1Beta1 service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@BetaApi
44+
@Generated("by gapic-generator-java")
45+
public class HttpJsonPhishingProtectionServiceV1Beta1CallableFactory
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)