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

Commit

Permalink
feat: Enable REST transport for most of Java and Go clients (#6)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 456641589

Source-Link: googleapis/googleapis@8a251f5

Source-Link: googleapis/googleapis-gen@4ca52a5
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: googleapis/googleapis-gen@e0e994c
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTBlOTk0YzNkN2MwMTY1MmFlNTk4NzBkYTdiN2VjZTFhOTUzMmM1YiJ9
  • Loading branch information
gcf-owl-bot[bot] committed Jun 24, 2022
1 parent f7db6ef commit ca7e9fa
Show file tree
Hide file tree
Showing 127 changed files with 82,017 additions and 577 deletions.
10 changes: 10 additions & 0 deletions google-cloud-batch-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,21 @@
<artifactId>grpc-google-cloud-batch-v1</artifactId>
<version>0.1.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-batch-v1:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-batch-v1alpha</artifactId>
<version>0.1.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-batch-v1alpha:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-batch-v1</artifactId>
<version>0.1.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-batch-v1:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-batch-v1alpha</artifactId>
<version>0.1.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-batch-v1alpha:current} -->
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
25 changes: 25 additions & 0 deletions google-cloud-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-batch-v1alpha</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-batch-v1alpha</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-iam-v1</artifactId>
Expand All @@ -65,6 +74,10 @@
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
Expand All @@ -84,12 +97,24 @@
<scope>test</scope>
</dependency>
<!-- Need testing utility classes for generated gRPC clients tests -->
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
Expand All @@ -30,7 +31,6 @@
import com.google.cloud.batch.v1.stub.BatchServiceStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
import com.google.longrunning.OperationsClient;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.List;
Expand All @@ -39,8 +39,8 @@

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: Google Cloud Batch Service. The service manages user submitted batch jobs
* and allocates Google Compute Engine VM instances to run the jobs.
* Service Description: Google Batch Service. The service manages user submitted batch jobs and
* allocates Google Compute Engine VM instances to run the jobs.
*
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
Expand Down Expand Up @@ -104,13 +104,28 @@
* BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
* }</pre>
*
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
* the wire:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* BatchServiceSettings batchServiceSettings =
* BatchServiceSettings.newBuilder()
* .setTransportChannelProvider(
* BatchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
* }</pre>
*
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class BatchServiceClient implements BackgroundResource {
private final BatchServiceSettings settings;
private final BatchServiceStub stub;
private final OperationsClient operationsClient;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;

/** Constructs an instance of BatchServiceClient with default settings. */
public static final BatchServiceClient create() throws IOException {
Expand Down Expand Up @@ -141,13 +156,17 @@ public static final BatchServiceClient create(BatchServiceStub stub) {
protected BatchServiceClient(BatchServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((BatchServiceStubSettings) settings.getStubSettings()).createStub();
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}

protected BatchServiceClient(BatchServiceStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}

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

/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
public final OperationsClient getHttpJsonOperationsClient() {
return httpJsonOperationsClient;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Create a Job.
Expand All @@ -183,8 +210,8 @@ public final OperationsClient getOperationsClient() {
* }
* }</pre>
*
* @param parent Required. The parent resource name where the Job will be created. Format:
* projects/{project}/locations/{location}
* @param parent Required. The parent resource name where the Job will be created. Pattern:
* "projects/{project}/locations/{location}"
* @param job Required. The Job to create.
* @param jobId ID used to uniquely identify the Job within its parent scope. This field should
* contain at most 63 characters. Only alphanumeric characters or '-' are accepted. The '-'
Expand Down Expand Up @@ -221,8 +248,8 @@ public final Job createJob(LocationName parent, Job job, String jobId) {
* }
* }</pre>
*
* @param parent Required. The parent resource name where the Job will be created. Format:
* projects/{project}/locations/{location}
* @param parent Required. The parent resource name where the Job will be created. Pattern:
* "projects/{project}/locations/{location}"
* @param job Required. The Job to create.
* @param jobId ID used to uniquely identify the Job within its parent scope. This field should
* contain at most 63 characters. Only alphanumeric characters or '-' are accepted. The '-'
Expand Down Expand Up @@ -495,7 +522,7 @@ public final UnaryCallable<DeleteJobRequest, Operation> deleteJobCallable() {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all Jobs for a project.
* List all Jobs for a project within a region.
*
* <p>Sample code:
*
Expand All @@ -520,7 +547,7 @@ public final ListJobsPagedResponse listJobs(String parent) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all Jobs for a project.
* List all Jobs for a project within a region.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -550,7 +577,7 @@ public final ListJobsPagedResponse listJobs(ListJobsRequest request) {

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all Jobs for a project.
* List all Jobs for a project within a region.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -579,7 +606,7 @@ public final UnaryCallable<ListJobsRequest, ListJobsPagedResponse> listJobsPaged

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all Jobs for a project.
* List all Jobs for a project within a region.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -731,7 +758,8 @@ public final UnaryCallable<GetTaskRequest, Task> getTaskCallable() {
* }
* }</pre>
*
* @param parent Required. Path of the TaskGroup from which Tasks are being requested.
* @param parent Required. Name of a TaskGroup from which Tasks are being requested. Pattern:
* "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListTasksPagedResponse listTasks(TaskGroupName parent) {
Expand All @@ -758,7 +786,8 @@ public final ListTasksPagedResponse listTasks(TaskGroupName parent) {
* }
* }</pre>
*
* @param parent Required. Path of the TaskGroup from which Tasks are being requested.
* @param parent Required. Name of a TaskGroup from which Tasks are being requested. Pattern:
* "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}"
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListTasksPagedResponse listTasks(String parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
Expand Down Expand Up @@ -137,11 +138,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return BatchServiceStubSettings.defaultCredentialsProviderBuilder();
}

/** Returns a builder for the default ChannelProvider for this service. */
/** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return BatchServiceStubSettings.defaultGrpcTransportProviderBuilder();
}

/** Returns a builder for the default REST ChannelProvider for this service. */
@BetaApi
public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder() {
return BatchServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
}

public static TransportChannelProvider defaultTransportChannelProvider() {
return BatchServiceStubSettings.defaultTransportChannelProvider();
}
Expand All @@ -151,11 +159,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return BatchServiceStubSettings.defaultApiClientHeaderProviderBuilder();
}

/** Returns a new builder for this class. */
/** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}

/** Returns a new REST builder for this class. */
@BetaApi
public static Builder newHttpJsonBuilder() {
return Builder.createHttpJsonDefault();
}

/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
Expand Down Expand Up @@ -193,6 +207,11 @@ private static Builder createDefault() {
return new Builder(BatchServiceStubSettings.newBuilder());
}

@BetaApi
private static Builder createHttpJsonDefault() {
return new Builder(BatchServiceStubSettings.newHttpJsonBuilder());
}

public BatchServiceStubSettings.Builder getStubSettingsBuilder() {
return ((BatchServiceStubSettings.Builder) getStubSettings());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*
* <p>======================= BatchServiceClient =======================
*
* <p>Service Description: Google Cloud Batch Service. The service manages user submitted batch jobs
* and allocates Google Compute Engine VM instances to run the jobs.
* <p>Service Description: Google Batch Service. The service manages user submitted batch jobs and
* allocates Google Compute Engine VM instances to run the jobs.
*
* <p>Sample for BatchServiceClient:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@
public abstract class BatchServiceStub implements BackgroundResource {

public OperationsStub getOperationsStub() {
throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
return null;
}

public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
return null;
}

public UnaryCallable<CreateJobRequest, Job> createJobCallable() {
Expand Down
Loading

0 comments on commit ca7e9fa

Please sign in to comment.