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

Commit ca7e9fa

Browse files
feat: Enable REST transport for most of Java and Go clients (#6)
- [ ] 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 feat: add client library BUILD rules, API proto option, v1alpha service config file and service YAML file PiperOrigin-RevId: 456598021 Source-Link: googleapis/googleapis@bf12acd Source-Link: https://github.com/googleapis/googleapis-gen/commit/e0e994c3d7c01652ae59870da7b7ece1a9532c5b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTBlOTk0YzNkN2MwMTY1MmFlNTk4NzBkYTdiN2VjZTFhOTUzMmM1YiJ9
1 parent f7db6ef commit ca7e9fa

File tree

127 files changed

+82017
-577
lines changed

Some content is hidden

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

127 files changed

+82017
-577
lines changed

google-cloud-batch-bom/pom.xml

+10
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,21 @@
7272
<artifactId>grpc-google-cloud-batch-v1</artifactId>
7373
<version>0.1.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-batch-v1:current} -->
7474
</dependency>
75+
<dependency>
76+
<groupId>com.google.api.grpc</groupId>
77+
<artifactId>grpc-google-cloud-batch-v1alpha</artifactId>
78+
<version>0.1.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-batch-v1alpha:current} -->
79+
</dependency>
7580
<dependency>
7681
<groupId>com.google.api.grpc</groupId>
7782
<artifactId>proto-google-cloud-batch-v1</artifactId>
7883
<version>0.1.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-batch-v1:current} -->
7984
</dependency>
85+
<dependency>
86+
<groupId>com.google.api.grpc</groupId>
87+
<artifactId>proto-google-cloud-batch-v1alpha</artifactId>
88+
<version>0.1.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-batch-v1alpha:current} -->
89+
</dependency>
8090
</dependencies>
8191
</dependencyManagement>
8292

google-cloud-batch/pom.xml

+25
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,19 @@
4141
<groupId>com.google.api.grpc</groupId>
4242
<artifactId>proto-google-common-protos</artifactId>
4343
</dependency>
44+
<dependency>
45+
<groupId>com.google.api.grpc</groupId>
46+
<artifactId>proto-google-cloud-batch-v1alpha</artifactId>
47+
</dependency>
4448
<dependency>
4549
<groupId>com.google.api.grpc</groupId>
4650
<artifactId>grpc-google-common-protos</artifactId>
4751
</dependency>
52+
<dependency>
53+
<groupId>com.google.api.grpc</groupId>
54+
<artifactId>grpc-google-cloud-batch-v1alpha</artifactId>
55+
<scope>test</scope>
56+
</dependency>
4857
<dependency>
4958
<groupId>com.google.api.grpc</groupId>
5059
<artifactId>grpc-google-iam-v1</artifactId>
@@ -65,6 +74,10 @@
6574
<groupId>com.google.api</groupId>
6675
<artifactId>gax-grpc</artifactId>
6776
</dependency>
77+
<dependency>
78+
<groupId>com.google.api</groupId>
79+
<artifactId>gax-httpjson</artifactId>
80+
</dependency>
6881
<dependency>
6982
<groupId>org.threeten</groupId>
7083
<artifactId>threetenbp</artifactId>
@@ -84,12 +97,24 @@
8497
<scope>test</scope>
8598
</dependency>
8699
<!-- 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>
87106
<dependency>
88107
<groupId>com.google.api</groupId>
89108
<artifactId>gax-grpc</artifactId>
90109
<classifier>testlib</classifier>
91110
<scope>test</scope>
92111
</dependency>
112+
<dependency>
113+
<groupId>com.google.api</groupId>
114+
<artifactId>gax-httpjson</artifactId>
115+
<classifier>testlib</classifier>
116+
<scope>test</scope>
117+
</dependency>
93118
</dependencies>
94119

95120
<profiles>

google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceClient.java

+46-17
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;
@@ -30,7 +31,6 @@
3031
import com.google.cloud.batch.v1.stub.BatchServiceStubSettings;
3132
import com.google.common.util.concurrent.MoreExecutors;
3233
import com.google.longrunning.Operation;
33-
import com.google.longrunning.OperationsClient;
3434
import com.google.protobuf.Empty;
3535
import java.io.IOException;
3636
import java.util.List;
@@ -39,8 +39,8 @@
3939

4040
// AUTO-GENERATED DOCUMENTATION AND CLASS.
4141
/**
42-
* Service Description: Google Cloud Batch Service. The service manages user submitted batch jobs
43-
* and allocates Google Compute Engine VM instances to run the jobs.
42+
* Service Description: Google Batch Service. The service manages user submitted batch jobs and
43+
* allocates Google Compute Engine VM instances to run the jobs.
4444
*
4545
* <p>This class provides the ability to make remote calls to the backing service through method
4646
* calls that map to API methods. Sample code to get started:
@@ -104,13 +104,28 @@
104104
* BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
105105
* }</pre>
106106
*
107+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
108+
* the wire:
109+
*
110+
* <pre>{@code
111+
* // This snippet has been automatically generated for illustrative purposes only.
112+
* // It may require modifications to work in your environment.
113+
* BatchServiceSettings batchServiceSettings =
114+
* BatchServiceSettings.newBuilder()
115+
* .setTransportChannelProvider(
116+
* BatchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
117+
* .build();
118+
* BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
119+
* }</pre>
120+
*
107121
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
108122
*/
109123
@Generated("by gapic-generator-java")
110124
public class BatchServiceClient implements BackgroundResource {
111125
private final BatchServiceSettings settings;
112126
private final BatchServiceStub stub;
113-
private final OperationsClient operationsClient;
127+
private final OperationsClient httpJsonOperationsClient;
128+
private final com.google.longrunning.OperationsClient operationsClient;
114129

115130
/** Constructs an instance of BatchServiceClient with default settings. */
116131
public static final BatchServiceClient create() throws IOException {
@@ -141,13 +156,17 @@ public static final BatchServiceClient create(BatchServiceStub stub) {
141156
protected BatchServiceClient(BatchServiceSettings settings) throws IOException {
142157
this.settings = settings;
143158
this.stub = ((BatchServiceStubSettings) settings.getStubSettings()).createStub();
144-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
159+
this.operationsClient =
160+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
161+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
145162
}
146163

147164
protected BatchServiceClient(BatchServiceStub stub) {
148165
this.settings = null;
149166
this.stub = stub;
150-
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
167+
this.operationsClient =
168+
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
169+
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
151170
}
152171

153172
public final BatchServiceSettings getSettings() {
@@ -162,10 +181,18 @@ public BatchServiceStub getStub() {
162181
* Returns the OperationsClient that can be used to query the status of a long-running operation
163182
* returned by another API method call.
164183
*/
165-
public final OperationsClient getOperationsClient() {
184+
public final com.google.longrunning.OperationsClient getOperationsClient() {
166185
return operationsClient;
167186
}
168187

188+
/**
189+
* Returns the OperationsClient that can be used to query the status of a long-running operation
190+
* returned by another API method call.
191+
*/
192+
public final OperationsClient getHttpJsonOperationsClient() {
193+
return httpJsonOperationsClient;
194+
}
195+
169196
// AUTO-GENERATED DOCUMENTATION AND METHOD.
170197
/**
171198
* Create a Job.
@@ -183,8 +210,8 @@ public final OperationsClient getOperationsClient() {
183210
* }
184211
* }</pre>
185212
*
186-
* @param parent Required. The parent resource name where the Job will be created. Format:
187-
* projects/{project}/locations/{location}
213+
* @param parent Required. The parent resource name where the Job will be created. Pattern:
214+
* "projects/{project}/locations/{location}"
188215
* @param job Required. The Job to create.
189216
* @param jobId ID used to uniquely identify the Job within its parent scope. This field should
190217
* contain at most 63 characters. Only alphanumeric characters or '-' are accepted. The '-'
@@ -221,8 +248,8 @@ public final Job createJob(LocationName parent, Job job, String jobId) {
221248
* }
222249
* }</pre>
223250
*
224-
* @param parent Required. The parent resource name where the Job will be created. Format:
225-
* projects/{project}/locations/{location}
251+
* @param parent Required. The parent resource name where the Job will be created. Pattern:
252+
* "projects/{project}/locations/{location}"
226253
* @param job Required. The Job to create.
227254
* @param jobId ID used to uniquely identify the Job within its parent scope. This field should
228255
* contain at most 63 characters. Only alphanumeric characters or '-' are accepted. The '-'
@@ -495,7 +522,7 @@ public final UnaryCallable<DeleteJobRequest, Operation> deleteJobCallable() {
495522

496523
// AUTO-GENERATED DOCUMENTATION AND METHOD.
497524
/**
498-
* List all Jobs for a project.
525+
* List all Jobs for a project within a region.
499526
*
500527
* <p>Sample code:
501528
*
@@ -520,7 +547,7 @@ public final ListJobsPagedResponse listJobs(String parent) {
520547

521548
// AUTO-GENERATED DOCUMENTATION AND METHOD.
522549
/**
523-
* List all Jobs for a project.
550+
* List all Jobs for a project within a region.
524551
*
525552
* <p>Sample code:
526553
*
@@ -550,7 +577,7 @@ public final ListJobsPagedResponse listJobs(ListJobsRequest request) {
550577

551578
// AUTO-GENERATED DOCUMENTATION AND METHOD.
552579
/**
553-
* List all Jobs for a project.
580+
* List all Jobs for a project within a region.
554581
*
555582
* <p>Sample code:
556583
*
@@ -579,7 +606,7 @@ public final UnaryCallable<ListJobsRequest, ListJobsPagedResponse> listJobsPaged
579606

580607
// AUTO-GENERATED DOCUMENTATION AND METHOD.
581608
/**
582-
* List all Jobs for a project.
609+
* List all Jobs for a project within a region.
583610
*
584611
* <p>Sample code:
585612
*
@@ -731,7 +758,8 @@ public final UnaryCallable<GetTaskRequest, Task> getTaskCallable() {
731758
* }
732759
* }</pre>
733760
*
734-
* @param parent Required. Path of the TaskGroup from which Tasks are being requested.
761+
* @param parent Required. Name of a TaskGroup from which Tasks are being requested. Pattern:
762+
* "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"
735763
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
736764
*/
737765
public final ListTasksPagedResponse listTasks(TaskGroupName parent) {
@@ -758,7 +786,8 @@ public final ListTasksPagedResponse listTasks(TaskGroupName parent) {
758786
* }
759787
* }</pre>
760788
*
761-
* @param parent Required. Path of the TaskGroup from which Tasks are being requested.
789+
* @param parent Required. Name of a TaskGroup from which Tasks are being requested. Pattern:
790+
* "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"
762791
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
763792
*/
764793
public final ListTasksPagedResponse listTasks(String parent) {

google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceSettings.java

+21-2
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;
@@ -137,11 +138,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
137138
return BatchServiceStubSettings.defaultCredentialsProviderBuilder();
138139
}
139140

140-
/** Returns a builder for the default ChannelProvider for this service. */
141+
/** Returns a builder for the default gRPC ChannelProvider for this service. */
141142
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
142143
return BatchServiceStubSettings.defaultGrpcTransportProviderBuilder();
143144
}
144145

146+
/** Returns a builder for the default REST ChannelProvider for this service. */
147+
@BetaApi
148+
public static InstantiatingHttpJsonChannelProvider.Builder
149+
defaultHttpJsonTransportProviderBuilder() {
150+
return BatchServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
151+
}
152+
145153
public static TransportChannelProvider defaultTransportChannelProvider() {
146154
return BatchServiceStubSettings.defaultTransportChannelProvider();
147155
}
@@ -151,11 +159,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
151159
return BatchServiceStubSettings.defaultApiClientHeaderProviderBuilder();
152160
}
153161

154-
/** Returns a new builder for this class. */
162+
/** Returns a new gRPC builder for this class. */
155163
public static Builder newBuilder() {
156164
return Builder.createDefault();
157165
}
158166

167+
/** Returns a new REST builder for this class. */
168+
@BetaApi
169+
public static Builder newHttpJsonBuilder() {
170+
return Builder.createHttpJsonDefault();
171+
}
172+
159173
/** Returns a new builder for this class. */
160174
public static Builder newBuilder(ClientContext clientContext) {
161175
return new Builder(clientContext);
@@ -193,6 +207,11 @@ private static Builder createDefault() {
193207
return new Builder(BatchServiceStubSettings.newBuilder());
194208
}
195209

210+
@BetaApi
211+
private static Builder createHttpJsonDefault() {
212+
return new Builder(BatchServiceStubSettings.newHttpJsonBuilder());
213+
}
214+
196215
public BatchServiceStubSettings.Builder getStubSettingsBuilder() {
197216
return ((BatchServiceStubSettings.Builder) getStubSettings());
198217
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*
2222
* <p>======================= BatchServiceClient =======================
2323
*
24-
* <p>Service Description: Google Cloud Batch Service. The service manages user submitted batch jobs
25-
* and allocates Google Compute Engine VM instances to run the jobs.
24+
* <p>Service Description: Google Batch Service. The service manages user submitted batch jobs and
25+
* allocates Google Compute Engine VM instances to run the jobs.
2626
*
2727
* <p>Sample for BatchServiceClient:
2828
*

google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStub.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848
public abstract class BatchServiceStub implements BackgroundResource {
4949

5050
public OperationsStub getOperationsStub() {
51-
throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
51+
return null;
52+
}
53+
54+
public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
55+
return null;
5256
}
5357

5458
public UnaryCallable<CreateJobRequest, Job> createJobCallable() {

0 commit comments

Comments
 (0)