Skip to content

Commit d732072

Browse files
feat: Enable REST transport for most of Java and Go clients (googleapis#794)
* 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 * chore: fix deps Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Neenu1995 <[email protected]>
1 parent edfaad3 commit d732072

File tree

274 files changed

+20129
-60
lines changed

Some content is hidden

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

274 files changed

+20129
-60
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@
142142
<groupId>com.google.api</groupId>
143143
<artifactId>gax-grpc</artifactId>
144144
</dependency>
145+
<dependency>
146+
<groupId>com.google.api</groupId>
147+
<artifactId>gax-httpjson</artifactId>
148+
</dependency>
145149
<dependency>
146150
<groupId>com.google.api</groupId>
147151
<artifactId>gax</artifactId>
@@ -188,12 +192,24 @@
188192
<artifactId>grpc-google-cloud-resourcemanager-v3</artifactId>
189193
<scope>test</scope>
190194
</dependency>
195+
<dependency>
196+
<groupId>com.google.api</groupId>
197+
<artifactId>gax</artifactId>
198+
<classifier>testlib</classifier>
199+
<scope>test</scope>
200+
</dependency>
191201
<dependency>
192202
<groupId>com.google.api</groupId>
193203
<artifactId>gax-grpc</artifactId>
194204
<classifier>testlib</classifier>
195205
<scope>test</scope>
196206
</dependency>
207+
<dependency>
208+
<groupId>com.google.api</groupId>
209+
<artifactId>gax-httpjson</artifactId>
210+
<classifier>testlib</classifier>
211+
<scope>test</scope>
212+
</dependency>
197213
</dependencies>
198214

199215
<build>

java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersClient.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.api.core.ApiFuture;
2020
import com.google.api.core.ApiFutures;
2121
import com.google.api.gax.core.BackgroundResource;
22+
import com.google.api.gax.httpjson.longrunning.OperationsClient;
2223
import com.google.api.gax.longrunning.OperationFuture;
2324
import com.google.api.gax.paging.AbstractFixedSizeCollection;
2425
import com.google.api.gax.paging.AbstractPage;
@@ -36,7 +37,6 @@
3637
import com.google.iam.v1.TestIamPermissionsRequest;
3738
import com.google.iam.v1.TestIamPermissionsResponse;
3839
import com.google.longrunning.Operation;
39-
import com.google.longrunning.OperationsClient;
4040
import com.google.protobuf.FieldMask;
4141
import java.io.IOException;
4242
import java.util.List;
@@ -107,13 +107,28 @@
107107
* FoldersClient foldersClient = FoldersClient.create(foldersSettings);
108108
* }</pre>
109109
*
110+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
111+
* the wire:
112+
*
113+
* <pre>{@code
114+
* // This snippet has been automatically generated for illustrative purposes only.
115+
* // It may require modifications to work in your environment.
116+
* FoldersSettings foldersSettings =
117+
* FoldersSettings.newBuilder()
118+
* .setTransportChannelProvider(
119+
* FoldersSettings.defaultHttpJsonTransportProviderBuilder().build())
120+
* .build();
121+
* FoldersClient foldersClient = FoldersClient.create(foldersSettings);
122+
* }</pre>
123+
*
110124
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
111125
*/
112126
@Generated("by gapic-generator-java")
113127
public class FoldersClient implements BackgroundResource {
114128
private final FoldersSettings settings;
115129
private final FoldersStub stub;
116-
private final OperationsClient operationsClient;
130+
private final OperationsClient httpJsonOperationsClient;
131+
private final com.google.longrunning.OperationsClient operationsClient;
117132

118133
/** Constructs an instance of FoldersClient with default settings. */
119134
public static final FoldersClient create() throws IOException {
@@ -143,13 +158,17 @@ public static final FoldersClient create(FoldersStub stub) {
143158
protected FoldersClient(FoldersSettings settings) throws IOException {
144159
this.settings = settings;
145160
this.stub = ((FoldersStubSettings) settings.getStubSettings()).createStub();
146-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
161+
this.operationsClient =
162+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
163+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
147164
}
148165

149166
protected FoldersClient(FoldersStub stub) {
150167
this.settings = null;
151168
this.stub = stub;
152-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
169+
this.operationsClient =
170+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
171+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
153172
}
154173

155174
public final FoldersSettings getSettings() {
@@ -164,10 +183,18 @@ public FoldersStub getStub() {
164183
* Returns the OperationsClient that can be used to query the status of a long-running operation
165184
* returned by another API method call.
166185
*/
167-
public final OperationsClient getOperationsClient() {
186+
public final com.google.longrunning.OperationsClient getOperationsClient() {
168187
return operationsClient;
169188
}
170189

190+
/**
191+
* Returns the OperationsClient that can be used to query the status of a long-running operation
192+
* returned by another API method call.
193+
*/
194+
public final OperationsClient getHttpJsonOperationsClient() {
195+
return httpJsonOperationsClient;
196+
}
197+
171198
// AUTO-GENERATED DOCUMENTATION AND METHOD.
172199
/**
173200
* Retrieves a folder identified by the supplied resource name. Valid folder resource names have

java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/FoldersSettings.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;
@@ -191,11 +192,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
191192
return FoldersStubSettings.defaultCredentialsProviderBuilder();
192193
}
193194

194-
/** Returns a builder for the default ChannelProvider for this service. */
195+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
195196
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
196197
return FoldersStubSettings.defaultGrpcTransportProviderBuilder();
197198
}
198199

200+
/** Returns a builder for the default REST ChannelProvider for this service. */
201+
@BetaApi
202+
public static InstantiatingHttpJsonChannelProvider.Builder
203+
defaultHttpJsonTransportProviderBuilder() {
204+
return FoldersStubSettings.defaultHttpJsonTransportProviderBuilder();
205+
}
206+
199207
public static TransportChannelProvider defaultTransportChannelProvider() {
200208
return FoldersStubSettings.defaultTransportChannelProvider();
201209
}
@@ -205,11 +213,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
205213
return FoldersStubSettings.defaultApiClientHeaderProviderBuilder();
206214
}
207215

208-
/** Returns a new builder for this class. */
216+
/** Returns a new gRPC builder for this class. */
209217
public static Builder newBuilder() {
210218
return Builder.createDefault();
211219
}
212220

221+
/** Returns a new REST builder for this class. */
222+
@BetaApi
223+
public static Builder newHttpJsonBuilder() {
224+
return Builder.createHttpJsonDefault();
225+
}
226+
213227
/** Returns a new builder for this class. */
214228
public static Builder newBuilder(ClientContext clientContext) {
215229
return new Builder(clientContext);
@@ -247,6 +261,11 @@ private static Builder createDefault() {
247261
return new Builder(FoldersStubSettings.newBuilder());
248262
}
249263

264+
@BetaApi
265+
private static Builder createHttpJsonDefault() {
266+
return new Builder(FoldersStubSettings.newHttpJsonBuilder());
267+
}
268+
250269
public FoldersStubSettings.Builder getStubSettingsBuilder() {
251270
return ((FoldersStubSettings.Builder) getStubSettings());
252271
}

java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsClient.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@
102102
* OrganizationsClient organizationsClient = OrganizationsClient.create(organizationsSettings);
103103
* }</pre>
104104
*
105+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
106+
* the wire:
107+
*
108+
* <pre>{@code
109+
* // This snippet has been automatically generated for illustrative purposes only.
110+
* // It may require modifications to work in your environment.
111+
* OrganizationsSettings organizationsSettings =
112+
* OrganizationsSettings.newBuilder()
113+
* .setTransportChannelProvider(
114+
* OrganizationsSettings.defaultHttpJsonTransportProviderBuilder().build())
115+
* .build();
116+
* OrganizationsClient organizationsClient = OrganizationsClient.create(organizationsSettings);
117+
* }</pre>
118+
*
105119
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
106120
*/
107121
@Generated("by gapic-generator-java")

java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/OrganizationsSettings.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.api.gax.core.GoogleCredentialsProvider;
2424
import com.google.api.gax.core.InstantiatingExecutorProvider;
2525
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
26+
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
2627
import com.google.api.gax.rpc.ApiClientHeaderProvider;
2728
import com.google.api.gax.rpc.ClientContext;
2829
import com.google.api.gax.rpc.ClientSettings;
@@ -129,11 +130,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
129130
return OrganizationsStubSettings.defaultCredentialsProviderBuilder();
130131
}
131132

132-
/** Returns a builder for the default ChannelProvider for this service. */
133+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
133134
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
134135
return OrganizationsStubSettings.defaultGrpcTransportProviderBuilder();
135136
}
136137

138+
/** Returns a builder for the default REST ChannelProvider for this service. */
139+
@BetaApi
140+
public static InstantiatingHttpJsonChannelProvider.Builder
141+
defaultHttpJsonTransportProviderBuilder() {
142+
return OrganizationsStubSettings.defaultHttpJsonTransportProviderBuilder();
143+
}
144+
137145
public static TransportChannelProvider defaultTransportChannelProvider() {
138146
return OrganizationsStubSettings.defaultTransportChannelProvider();
139147
}
@@ -143,11 +151,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
143151
return OrganizationsStubSettings.defaultApiClientHeaderProviderBuilder();
144152
}
145153

146-
/** Returns a new builder for this class. */
154+
/** Returns a new gRPC builder for this class. */
147155
public static Builder newBuilder() {
148156
return Builder.createDefault();
149157
}
150158

159+
/** Returns a new REST builder for this class. */
160+
@BetaApi
161+
public static Builder newHttpJsonBuilder() {
162+
return Builder.createHttpJsonDefault();
163+
}
164+
151165
/** Returns a new builder for this class. */
152166
public static Builder newBuilder(ClientContext clientContext) {
153167
return new Builder(clientContext);
@@ -185,6 +199,11 @@ private static Builder createDefault() {
185199
return new Builder(OrganizationsStubSettings.newBuilder());
186200
}
187201

202+
@BetaApi
203+
private static Builder createHttpJsonDefault() {
204+
return new Builder(OrganizationsStubSettings.newHttpJsonBuilder());
205+
}
206+
188207
public OrganizationsStubSettings.Builder getStubSettingsBuilder() {
189208
return ((OrganizationsStubSettings.Builder) getStubSettings());
190209
}

java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/v3/ProjectsClient.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.api.core.ApiFuture;
2020
import com.google.api.core.ApiFutures;
2121
import com.google.api.gax.core.BackgroundResource;
22+
import com.google.api.gax.httpjson.longrunning.OperationsClient;
2223
import com.google.api.gax.longrunning.OperationFuture;
2324
import com.google.api.gax.paging.AbstractFixedSizeCollection;
2425
import com.google.api.gax.paging.AbstractPage;
@@ -36,7 +37,6 @@
3637
import com.google.iam.v1.TestIamPermissionsRequest;
3738
import com.google.iam.v1.TestIamPermissionsResponse;
3839
import com.google.longrunning.Operation;
39-
import com.google.longrunning.OperationsClient;
4040
import com.google.protobuf.FieldMask;
4141
import java.io.IOException;
4242
import java.util.List;
@@ -107,13 +107,28 @@
107107
* ProjectsClient projectsClient = ProjectsClient.create(projectsSettings);
108108
* }</pre>
109109
*
110+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
111+
* the wire:
112+
*
113+
* <pre>{@code
114+
* // This snippet has been automatically generated for illustrative purposes only.
115+
* // It may require modifications to work in your environment.
116+
* ProjectsSettings projectsSettings =
117+
* ProjectsSettings.newBuilder()
118+
* .setTransportChannelProvider(
119+
* ProjectsSettings.defaultHttpJsonTransportProviderBuilder().build())
120+
* .build();
121+
* ProjectsClient projectsClient = ProjectsClient.create(projectsSettings);
122+
* }</pre>
123+
*
110124
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
111125
*/
112126
@Generated("by gapic-generator-java")
113127
public class ProjectsClient implements BackgroundResource {
114128
private final ProjectsSettings settings;
115129
private final ProjectsStub stub;
116-
private final OperationsClient operationsClient;
130+
private final OperationsClient httpJsonOperationsClient;
131+
private final com.google.longrunning.OperationsClient operationsClient;
117132

118133
/** Constructs an instance of ProjectsClient with default settings. */
119134
public static final ProjectsClient create() throws IOException {
@@ -143,13 +158,17 @@ public static final ProjectsClient create(ProjectsStub stub) {
143158
protected ProjectsClient(ProjectsSettings settings) throws IOException {
144159
this.settings = settings;
145160
this.stub = ((ProjectsStubSettings) settings.getStubSettings()).createStub();
146-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
161+
this.operationsClient =
162+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
163+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
147164
}
148165

149166
protected ProjectsClient(ProjectsStub stub) {
150167
this.settings = null;
151168
this.stub = stub;
152-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
169+
this.operationsClient =
170+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
171+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
153172
}
154173

155174
public final ProjectsSettings getSettings() {
@@ -164,10 +183,18 @@ public ProjectsStub getStub() {
164183
* Returns the OperationsClient that can be used to query the status of a long-running operation
165184
* returned by another API method call.
166185
*/
167-
public final OperationsClient getOperationsClient() {
186+
public final com.google.longrunning.OperationsClient getOperationsClient() {
168187
return operationsClient;
169188
}
170189

190+
/**
191+
* Returns the OperationsClient that can be used to query the status of a long-running operation
192+
* returned by another API method call.
193+
*/
194+
public final OperationsClient getHttpJsonOperationsClient() {
195+
return httpJsonOperationsClient;
196+
}
197+
171198
// AUTO-GENERATED DOCUMENTATION AND METHOD.
172199
/**
173200
* Retrieves the project identified by the specified `name` (for example,

0 commit comments

Comments
 (0)