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

Commit 566bc6f

Browse files
feat: Enable REST transport for most of Java and Go clients (#357)
- [ ] 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 2b36266 commit 566bc6f

File tree

47 files changed

+3456
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3456
-5
lines changed

google-cloud-orgpolicy/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
<groupId>com.google.api</groupId>
6262
<artifactId>gax-grpc</artifactId>
6363
</dependency>
64+
<dependency>
65+
<groupId>com.google.api</groupId>
66+
<artifactId>gax-httpjson</artifactId>
67+
</dependency>
6468
<dependency>
6569
<groupId>org.threeten</groupId>
6670
<artifactId>threetenbp</artifactId>
@@ -79,12 +83,24 @@
7983
<scope>test</scope>
8084
</dependency>
8185
<!-- Need testing utility classes for generated gRPC clients tests -->
86+
<dependency>
87+
<groupId>com.google.api</groupId>
88+
<artifactId>gax</artifactId>
89+
<classifier>testlib</classifier>
90+
<scope>test</scope>
91+
</dependency>
8292
<dependency>
8393
<groupId>com.google.api</groupId>
8494
<artifactId>gax-grpc</artifactId>
8595
<classifier>testlib</classifier>
8696
<scope>test</scope>
8797
</dependency>
98+
<dependency>
99+
<groupId>com.google.api</groupId>
100+
<artifactId>gax-httpjson</artifactId>
101+
<classifier>testlib</classifier>
102+
<scope>test</scope>
103+
</dependency>
88104
</dependencies>
89105

90106
<profiles>

google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyClient.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@
113113
* OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
114114
* }</pre>
115115
*
116+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
117+
* the wire:
118+
*
119+
* <pre>{@code
120+
* // This snippet has been automatically generated for illustrative purposes only.
121+
* // It may require modifications to work in your environment.
122+
* OrgPolicySettings orgPolicySettings =
123+
* OrgPolicySettings.newBuilder()
124+
* .setTransportChannelProvider(
125+
* OrgPolicySettings.defaultHttpJsonTransportProviderBuilder().build())
126+
* .build();
127+
* OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
128+
* }</pre>
129+
*
116130
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
117131
*/
118132
@Generated("by gapic-generator-java")

google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicySettings.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.api.gax.core.GoogleCredentialsProvider;
2525
import com.google.api.gax.core.InstantiatingExecutorProvider;
2626
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
27+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2728
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2829
import com.google.api.gax.rpc.ClientContext;
2930
import com.google.api.gax.rpc.ClientSettings;
@@ -134,11 +135,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
134135
return OrgPolicyStubSettings.defaultCredentialsProviderBuilder();
135136
}
136137

137-
/** Returns a builder for the default ChannelProvider for this service. */
138+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
138139
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
139140
return OrgPolicyStubSettings.defaultGrpcTransportProviderBuilder();
140141
}
141142

143+
/** Returns a builder for the default REST ChannelProvider for this service. */
144+
@BetaApi
145+
public static InstantiatingHttpJsonChannelProvider.Builder
146+
defaultHttpJsonTransportProviderBuilder() {
147+
return OrgPolicyStubSettings.defaultHttpJsonTransportProviderBuilder();
148+
}
149+
142150
public static TransportChannelProvider defaultTransportChannelProvider() {
143151
return OrgPolicyStubSettings.defaultTransportChannelProvider();
144152
}
@@ -148,11 +156,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
148156
return OrgPolicyStubSettings.defaultApiClientHeaderProviderBuilder();
149157
}
150158

151-
/** Returns a new builder for this class. */
159+
/** Returns a new gRPC builder for this class. */
152160
public static Builder newBuilder() {
153161
return Builder.createDefault();
154162
}
155163

164+
/** Returns a new REST builder for this class. */
165+
@BetaApi
166+
public static Builder newHttpJsonBuilder() {
167+
return Builder.createHttpJsonDefault();
168+
}
169+
156170
/** Returns a new builder for this class. */
157171
public static Builder newBuilder(ClientContext clientContext) {
158172
return new Builder(clientContext);
@@ -190,6 +204,11 @@ private static Builder createDefault() {
190204
return new Builder(OrgPolicyStubSettings.newBuilder());
191205
}
192206

207+
@BetaApi
208+
private static Builder createHttpJsonDefault() {
209+
return new Builder(OrgPolicyStubSettings.newHttpJsonBuilder());
210+
}
211+
193212
public OrgPolicyStubSettings.Builder getStubSettingsBuilder() {
194213
return ((OrgPolicyStubSettings.Builder) getStubSettings());
195214
}
Lines changed: 105 additions & 0 deletions
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.orgpolicy.v2.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 OrgPolicy service API.
40+
*
41+
* <p>This class is for advanced usage.
42+
*/
43+
@Generated("by gapic-generator-java")
44+
@BetaApi
45+
public class HttpJsonOrgPolicyCallableFactory
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)